teiid SVN: r2528 - tags.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-03 10:42:45 -0400 (Fri, 03 Sep 2010)
New Revision: 2528
Added:
tags/teiid-7.2.0.Alpha1/
Log:
[maven-release-plugin] copy for tag teiid-7.2.0.Alpha1
Copied: tags/teiid-7.2.0.Alpha1 (from rev 2527, trunk)
14 years, 3 months
teiid SVN: r2527 - in trunk: adminshell and 35 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-03 10:29:06 -0400 (Fri, 03 Sep 2010)
New Revision: 2527
Modified:
trunk/adminshell/pom.xml
trunk/api/pom.xml
trunk/build/pom.xml
trunk/cache-jbosscache/pom.xml
trunk/client/pom.xml
trunk/common-core/pom.xml
trunk/connectors/connector-file/pom.xml
trunk/connectors/connector-ldap/pom.xml
trunk/connectors/connector-salesforce/pom.xml
trunk/connectors/connector-ws/pom.xml
trunk/connectors/pom.xml
trunk/connectors/salesforce-api/pom.xml
trunk/connectors/sandbox/pom.xml
trunk/connectors/sandbox/translator-yahoo/pom.xml
trunk/connectors/translator-file/pom.xml
trunk/connectors/translator-jdbc/pom.xml
trunk/connectors/translator-ldap/pom.xml
trunk/connectors/translator-loopback/pom.xml
trunk/connectors/translator-salesforce/pom.xml
trunk/connectors/translator-ws/pom.xml
trunk/console/pom.xml
trunk/documentation/admin-guide/pom.xml
trunk/documentation/caching-guide/pom.xml
trunk/documentation/client-developers-guide/pom.xml
trunk/documentation/developer-guide/pom.xml
trunk/documentation/pom.xml
trunk/documentation/quick-start-example/pom.xml
trunk/documentation/reference/pom.xml
trunk/engine/pom.xml
trunk/hibernate-dialect/pom.xml
trunk/jboss-integration/pom.xml
trunk/metadata/pom.xml
trunk/pom.xml
trunk/runtime/pom.xml
trunk/test-integration/common/pom.xml
trunk/test-integration/db/pom.xml
trunk/test-integration/pom.xml
Log:
[maven-release-plugin] prepare release teiid-7.2.0.Alpha1
Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/adminshell/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-adminshell</artifactId>
Modified: trunk/api/pom.xml
===================================================================
--- trunk/api/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/api/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/build/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>build</artifactId>
Modified: trunk/cache-jbosscache/pom.xml
===================================================================
--- trunk/cache-jbosscache/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/cache-jbosscache/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-cache-jbosscache</artifactId>
Modified: trunk/client/pom.xml
===================================================================
--- trunk/client/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/client/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client</artifactId>
Modified: trunk/common-core/pom.xml
===================================================================
--- trunk/common-core/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/common-core/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-common-core</artifactId>
Modified: trunk/connectors/connector-file/pom.xml
===================================================================
--- trunk/connectors/connector-file/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/connector-file/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-file</artifactId>
Modified: trunk/connectors/connector-ldap/pom.xml
===================================================================
--- trunk/connectors/connector-ldap/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/connector-ldap/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ldap</artifactId>
Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/connector-salesforce/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-salesforce</artifactId>
Modified: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/connector-ws/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ws</artifactId>
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/salesforce-api/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>salesforce-api</artifactId>
Modified: trunk/connectors/sandbox/pom.xml
===================================================================
--- trunk/connectors/sandbox/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/sandbox/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid.connectors</groupId>
Modified: trunk/connectors/sandbox/translator-yahoo/pom.xml
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/sandbox/translator-yahoo/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-yahoo</artifactId>
Modified: trunk/connectors/translator-file/pom.xml
===================================================================
--- trunk/connectors/translator-file/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-file/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-file</artifactId>
Modified: trunk/connectors/translator-jdbc/pom.xml
===================================================================
--- trunk/connectors/translator-jdbc/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-jdbc/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jdbc</artifactId>
Modified: trunk/connectors/translator-ldap/pom.xml
===================================================================
--- trunk/connectors/translator-ldap/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-ldap/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ldap</artifactId>
Modified: trunk/connectors/translator-loopback/pom.xml
===================================================================
--- trunk/connectors/translator-loopback/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-loopback/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-loopback</artifactId>
Modified: trunk/connectors/translator-salesforce/pom.xml
===================================================================
--- trunk/connectors/translator-salesforce/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-salesforce/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-salesforce</artifactId>
Modified: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-ws/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/connectors/translator-ws/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/console/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/documentation/admin-guide/pom.xml
===================================================================
--- trunk/documentation/admin-guide/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/admin-guide/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>admin-guide</artifactId>
Modified: trunk/documentation/caching-guide/pom.xml
===================================================================
--- trunk/documentation/caching-guide/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/caching-guide/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>caching-guide</artifactId>
Modified: trunk/documentation/client-developers-guide/pom.xml
===================================================================
--- trunk/documentation/client-developers-guide/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/client-developers-guide/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>client-developers-guide</artifactId>
Modified: trunk/documentation/developer-guide/pom.xml
===================================================================
--- trunk/documentation/developer-guide/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/developer-guide/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>developer-guide</artifactId>
Modified: trunk/documentation/pom.xml
===================================================================
--- trunk/documentation/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/documentation/quick-start-example/pom.xml
===================================================================
--- trunk/documentation/quick-start-example/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/quick-start-example/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>quick-start-example</artifactId>
Modified: trunk/documentation/reference/pom.xml
===================================================================
--- trunk/documentation/reference/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/documentation/reference/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>reference</artifactId>
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/engine/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-engine</artifactId>
Modified: trunk/hibernate-dialect/pom.xml
===================================================================
--- trunk/hibernate-dialect/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/hibernate-dialect/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-hibernate-dialect</artifactId>
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/jboss-integration/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/metadata/pom.xml
===================================================================
--- trunk/metadata/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/metadata/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-metadata</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -5,15 +5,15 @@
<artifactId>teiid</artifactId>
<packaging>pom</packaging>
<name>Teiid</name>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
<description>Federated SQL and XML query engine.</description>
<properties>
<ant.version>1.7.0</ant.version>
<site.url>http://www.jboss.org/teiid</site.url>
</properties>
<scm>
- <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/trunk</developerConnection>
+ <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/tags/teiid-7.2.0.Alpha1</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/tags/teiid-7.2.0.Alpha1</developerConnection>
</scm>
<licenses>
<license>
Modified: trunk/runtime/pom.xml
===================================================================
--- trunk/runtime/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/runtime/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/test-integration/common/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-common</artifactId>
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/test-integration/db/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -9,7 +9,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
+++ trunk/test-integration/pom.xml 2010-09-03 14:29:06 UTC (rev 2527)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
+ <version>7.2.0.Alpha1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-test-integration</artifactId>
14 years, 3 months
teiid SVN: r2526 - in trunk: api/src/main/java/org/teiid/metadata and 101 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 21:45:43 -0400 (Thu, 02 Sep 2010)
New Revision: 2526
Added:
trunk/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
trunk/build/kits/jboss-container/teiid-examples/jca/
trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt
trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
trunk/build/kits/jboss-container/teiid-examples/simpleclient/JDBCClient.class
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java
trunk/client/src/main/java/org/teiid/adminapi/CacheStatistics.java
trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
trunk/documentation/admin-guide/src/main/docbook/en-US/content/clustering.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/results.xml
trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java
trunk/engine/src/main/java/org/teiid/query/tempdata/IndexInfo.java
Removed:
trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt
trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
trunk/build/kits/jboss-container/teiid-examples/simpleclient/JDBCClient.class
trunk/console/src/main/java/org/teiid/rhq/comm/
trunk/console/src/main/java/org/teiid/rhq/embedded/
trunk/console/src/main/java/org/teiid/rhq/enterprise/
trunk/console/src/main/java/org/teiid/rhq/plugin/log/
trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
trunk/documentation/reference/src/main/docbook/en-US/content/entitlements.xml
trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/SimpleQueryProcessorFactory.java
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
trunk/api/src/main/java/org/teiid/translator/Translator.java
trunk/build/assembly/jboss-container/dist.xml
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
trunk/client/src/main/java/org/teiid/client/plan/Annotation.java
trunk/client/src/main/java/org/teiid/client/security/ILogon.java
trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
trunk/client/src/main/java/org/teiid/jdbc/ExecutionProperties.java
trunk/client/src/main/java/org/teiid/jdbc/SocketProfile.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
trunk/client/src/main/java/org/teiid/net/HostInfo.java
trunk/client/src/main/java/org/teiid/net/ServerConnection.java
trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java
trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
trunk/client/src/main/java/org/teiid/net/socket/ServerDiscovery.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceFactory.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
trunk/client/src/main/java/org/teiid/net/socket/UrlServerDiscovery.java
trunk/client/src/main/resources/vdb-deployer.xsd
trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
trunk/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java
trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerInstanceImpl.java
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/main/java/org/teiid/core/util/Assertion.java
trunk/common-core/src/test/java/org/teiid/core/util/TestAssertion.java
trunk/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
trunk/connectors/connector-ws/pom.xml
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
trunk/console/src/main/resources/META-INF/rhq-plugin.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml
trunk/documentation/reference/src/main/docbook/en-US/Reference.xml
trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
trunk/engine/src/main/java/org/teiid/cache/Cache.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java
trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java
trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/jboss-integration/pom.xml
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java
trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
trunk/runtime/src/main/java/org/teiid/transport/PgFrontendProtocol.java
trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
trunk/test-integration/db/pom.xml
Log:
forward merge of 7.1.1
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -36,6 +36,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.CacheStatistics;
import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
@@ -154,11 +155,11 @@
return getAdmin().getCacheTypes();
}
- @Doc(text = "Cancel a request")
+ @Doc(text = "Change a VDB Connection Type")
public static void changeVDBConnectionType(
@Doc(text = "vdb name") String vdbName,
@Doc(text = "vdb version") int vdbVersion,
- @Doc(text = "Connection Type") String type)
+ @Doc(text = "Connection Type (NONE, BY_VERSION, or ANY") String type)
throws AdminException {
getAdmin().changeVDBConnectionType(vdbName, vdbVersion, ConnectionType.valueOf(type));
}
@@ -229,7 +230,13 @@
throws AdminException {
return getAdmin().getWorkManagerStats(identifier);
}
-
+
+ @Doc(text = "Get cache statistics for given cache type")
+ public static CacheStatistics getCacheStats(@Doc(text = "cacheType") String identifier)
+ throws AdminException {
+ return getAdmin().getCacheStats(identifier);
+ }
+
@Doc(text = "Remove a role for the data policy")
public static void removeDataRoleMapping(
@Doc(text = "vdb name") String vdbName,
Modified: trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -30,6 +30,7 @@
Primary,
Foreign,
Unique, //constraint
+ @Deprecated
NonUnique,
AccessPattern,
Index,
@@ -42,6 +43,9 @@
}
public Type getType() {
+ if (type == Type.NonUnique) {
+ type = Type.Index;
+ }
return type;
}
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -170,7 +170,7 @@
* @throws TranslatorException
*/
public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) throws TranslatorException {
- KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.NonUnique:KeyRecord.Type.Index);
+ KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.Index:KeyRecord.Type.Unique);
index.setParent(table);
index.setColumns(new ArrayList<Column>(columnNames.size()));
index.setName(name);
Modified: trunk/api/src/main/java/org/teiid/translator/Translator.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/Translator.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/api/src/main/java/org/teiid/translator/Translator.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -37,4 +37,5 @@
*/
public @interface Translator {
String name();
+ String description() default "";
}
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/build/assembly/jboss-container/dist.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -18,7 +18,8 @@
<includes>
<include>**/*.sh</include>
</includes>
- <fileMode>755</fileMode>
+ <fileMode>755</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -39,6 +40,7 @@
</includes>
<outputDirectory>lib</outputDirectory>
<fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -47,7 +49,8 @@
<include>vdb-deployer.xsd</include>
</includes>
<outputDirectory>teiid-docs/schema</outputDirectory>
- <fileMode>0644</fileMode>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<!-- We may want to do this if including multiple doc types or languages
Copied: trunk/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml (from rev 2524, branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml)
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml (rev 0)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ If you are running JBoss AS in clustered mode, to enable the clustered cache in
+ the Teiid rename this file to "teiid-cache-manager-jboss-beans.xml"
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Factory/registry for JBoss Cache and PojoCache instances used in the AS -->
+ <bean name="TeiidCacheManager" class="org.jboss.ha.cachemanager.CacheManager">
+ <property name="jndiName">java:TeiidCacheManager</property>
+ <property name="configurationRegistry">
+ <inject bean="TeiidCacheConfigurationRegistry" />
+ </property>
+ <property name="channelFactory">
+ <inject bean="JChannelFactory" />
+ </property>
+
+ <!-- Aliases for cache names. Allows caches to be shared across
+ services that may expect different cache config names. -->
+ <property name="configAliases">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <!-- Use the HAPartition cache for ClusteredSSO caching -->
+ <entry>
+ <key>teiid-resultset-cache</key>
+ <value>teiid-resultset-cache</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <!--
+ | Registry of named JBoss Cache configurations. Users of the CacheManager
+ | request a cache with a particular configuration by providing the name
+ | of one of these configurations.
+ -->
+ <bean name="TeiidCacheConfigurationRegistry" class="org.jboss.ha.cachemanager.DependencyInjectedConfigurationRegistry">
+
+ <!-- The configurations. A Map<String name, Configuration config> -->
+ <property name="newConfigurations">
+ <map keyClass="java.lang.String" valueClass="org.jboss.cache.config.Configuration">
+
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses mvcc locking. -->
+ <entry>
+ <key>teiid-resultset-cache</key>
+ <value>
+ <bean class="org.jboss.cache.config.Configuration">
+
+ <!-- Node locking scheme -->
+ <property name="nodeLockingScheme">MVCC</property>
+ <!-- READ_COMMITTED is as strong as necessary for most
+ 2nd Level Cache use cases. -->
+ <property name="isolationLevel">READ_COMMITTED</property>
+ <property name="useLockStriping">false</property>
+
+ <!-- Must use REPL since used for timestamp caching.
+ Must use SYNC to maintain cache coherency for entities. -->
+ <property name="cacheMode">REPL_SYNC</property>
+
+ <!-- Name of cluster. Needs to be the same for all members -->
+ <property name="clusterName">${jboss.partition.name:DefaultPartition}-resultset-cache</property>
+ <!-- Use a UDP (multicast) based stack. Need JGroups flow control (FC)
+ because timestamp communication will not require a synchronous response. -->
+ <property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>
+ <!-- Used for timestamps, so must fetch state. -->
+ <property name="fetchInMemoryState">true</property>
+
+ <!-- The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members at startup. Ignored if FetchInMemoryState=false. -->
+ <property name="stateRetrievalTimeout">60000</property>
+
+ <!-- Number of milliseconds to wait until all responses for a
+ synchronous call have been received. -->
+ <property name="syncReplTimeout">17500</property>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <property name="lockAcquisitionTimeout">15000</property>
+
+ <!-- Hibernate 2LC can replicate custom types, so we use marshalling -->
+ <property name="useRegionBasedMarshalling">true</property>
+ <!-- Must match the value of "useRegionBasedMarshalling" -->
+ <property name="inactiveOnStartup">true</property>
+
+ <!-- Disable asynchronous RPC marshalling/sending -->
+ <property name="serializationExecutorPoolSize">0</property>
+ <!-- We have no asynchronous notification listeners -->
+ <property name="listenerAsyncPoolSize">0</property>
+
+ <property name="evictionConfig">
+ <bean class="org.jboss.cache.config.EvictionConfig">
+ <property name="wakeupInterval">5000</property>
+ <!-- Overall default -->
+ <property name="defaultEvictionRegionConfig">
+ <bean class="org.jboss.cache.config.EvictionRegionConfig">
+ <property name="regionName">/</property>
+ <property name="evictionAlgorithmConfig">
+ <bean class="org.jboss.cache.eviction.LRUAlgorithmConfig">
+ <!-- Evict LRU node once we have more than this number of nodes -->
+ <property name="maxNodes">10000</property>
+ <!-- And, evict any node that hasn't been accessed in this many seconds -->
+ <property name="timeToLiveSeconds">1000</property>
+ <!-- Don't evict a node that's been accessed within this many seconds.
+ Set this to a value greater than your max expected transaction length. -->
+ <property name="minTimeToLiveSeconds">120</property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ <property name="cacheLoaderConfig">
+ <bean class="org.jboss.cache.config.CacheLoaderConfig">
+ <!-- Do not change these -->
+ <property name="passivation">false</property>
+ <property name="shared">false</property>
+
+ <property name="individualCacheLoaderConfigs">
+ <list>
+ <bean class="org.teiid.cache.jboss.TupleBatchCacheLoaderConfig">
+ <property name="bufferService"><inject bean="BufferService" /></property>
+ <property name="ignoreModifications">true</property>
+ <property name="timeout">10000</property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -46,7 +46,8 @@
<bean name="CacheFactory" class="org.teiid.cache.jboss.ClusterableCacheFactory">
<property name="enabled">true</property>
- <property name="clusteredCacheName">mvcc-shared</property>
+ <property name="cacheManager">java:TeiidCacheManager</property>
+ <property name="resultsetCacheName">teiid-resultset-cache</property>
</bean>
<!-- Configuration for result set caching.
@@ -91,12 +92,14 @@
<property name="timeSliceInMilli">2000</property>
<!-- Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480) -->
<property name="maxRowsFetchSize">20480</property>
- <!-- The max lob chunk size in KB transferred each time when processing blobs, clobs(100KB default) -->
+ <!-- The max lob chunk size in KB transferred each time when processing blobs, clobs (100KB default) -->
<property name="lobChunkSizeInKB">100</property>
- <!-- The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250) -->
- <property name="preparedPlanCacheMaxCount">250</property>
- <!-- Turn on role checking on resources based on the roles defined in VDB -->
- <property name="useDataRoles" class="java.lang.Boolean">false</property>
+ <!-- The maximum number of query plans that are cached.
+ This includes both user plans and internal prepared plans.
+ Note: this is a memory based cache. (default 512) -->
+ <property name="preparedPlanCacheMaxCount">512</property>
+ <!-- Turn on role checking of resources based on the roles defined in VDB (default true) -->
+ <property name="useDataRoles" class="java.lang.Boolean">true</property>
<!-- Long running query threshold, after which a alert can be generated by tooling if configured-->
<property name="queryThresholdInSecs">600</property>
<!-- Maximum rows allowed from a source query. -1 indicates no limit. (default -1)-->
@@ -108,7 +111,7 @@
<!-- JDBC Socket connection properties (SSL see below) -->
<bean name="JdbcSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
- <!-- property name="bindAddress">localhost</property-->
+ <property name="bindAddress">${jboss.bind.address}</property>
<property name="portNumber">31000</property>
<!-- Max number of threads dedicated to initial request processing (default 15) -->
<property name="maxSocketThreads">15</property>
@@ -136,7 +139,7 @@
<!-- Admin Socket connection settings (SSL see below) -->
<bean name="AdminSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
- <!-- property name="bindAddress">localhost</property-->
+ <property name="bindAddress">${jboss.bind.address}</property>
<property name="portNumber">31443</property>
<!-- Max number of threads dedicated to Admin and initial request processing (default 4) -->
<property name="maxSocketThreads">4</property>
@@ -164,7 +167,7 @@
<!-- JDBC Socket connection properties (SSL see below) -->
<bean name="OdbcSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
- <!-- property name="bindAddress">localhost</property-->
+ <property name="bindAddress">${jboss.bind.address}</property>
<property name="portNumber">35432</property>
<!-- Max number of threads dedicated to initial request processing (default 15) -->
<property name="maxSocketThreads">15</property>
Copied: trunk/build/kits/jboss-container/teiid-examples/jca (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca)
Deleted: trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml 2010-09-02 21:11:11 UTC (rev 2524)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<connection-factories>
-
- <no-tx-connection-factory>
- <!-- The jndi name of the DataSource -->
- <jndi-name>fileDS</jndi-name>
-
- <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
- <rar-name>teiid-connector-file.rar</rar-name>
- <!-- connection interface; (do not change this) -->
- <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
-
- <!-- Directory where the data files are stored -->
- <config-property name="ParentDirectory" type="java.lang.String">directory</config-property>
-
- <max-pool-size>20</max-pool-size>
-
- </no-tx-connection-factory>
-
-</connection-factories>
\ No newline at end of file
Copied: trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml)
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/file-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>fileDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-file.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- Directory where the data files are stored -->
+ <config-property name="ParentDirectory" type="java.lang.String">directory</config-property>
+
+ <max-pool-size>20</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Deleted: trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml 2010-09-02 21:11:11 UTC (rev 2524)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<connection-factories>
-
- <no-tx-connection-factory>
- <!-- The jndi name of the DataSource -->
- <jndi-name>ldapDS</jndi-name>
-
- <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
- <rar-name>teiid-connector-file.rar</rar-name>
- <!-- connection interface; (do not change this) -->
- <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
-
- <!-- LDAP Directroy URL (required)-->
- <config-property name="LdapUrl">ldap://ldapServer:389</config-property>
-
- <!-- Ldap Admin User DN (required)-->
- <config-property name="LdapAdminUserDN">cn=???,ou=???,dc=???</config-property>
-
- <!-- Ldap Admin Password (required)-->
- <config-property name="LdapAdminUserPassword">pass</config-property>
-
- <!-- Ldap Transaction Timeout (ms) -1 = no time out (optional) -->
- <config-property name="LdapTxnTimeoutInMillis">-1</config-property>
-
- <max-pool-size>20</max-pool-size>
-
- </no-tx-connection-factory>
-
-</connection-factories>
\ No newline at end of file
Copied: trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml)
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>ldapDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-file.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- LDAP Directroy URL (required)-->
+ <config-property name="LdapUrl">ldap://ldapServer:389</config-property>
+
+ <!-- Ldap Admin User DN (required)-->
+ <config-property name="LdapAdminUserDN">cn=???,ou=???,dc=???</config-property>
+
+ <!-- Ldap Admin Password (required)-->
+ <config-property name="LdapAdminUserPassword">pass</config-property>
+
+ <!-- Ldap Transaction Timeout (ms) -1 = no time out (optional) -->
+ <config-property name="LdapTxnTimeoutInMillis">-1</config-property>
+
+ <max-pool-size>20</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Deleted: trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt 2010-09-02 21:11:11 UTC (rev 2524)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,8 +0,0 @@
-This folder contains the sample "-ds.xml" files that can be created for Teiid sources.
-
-JDBC: Please check "<jboss-as>/docs/examples/jca" directory for creating a -ds.xml file for any type of relational database.
-Please note you can find samples for creating both "local" and "xa" data sources.
-
-Web Serivices with ws-security: Check out Admin guide for a sample with explanation on how to use it.
-
-All the others types of sources, please find a example in this directory.
\ No newline at end of file
Copied: trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt)
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/readme.txt 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,8 @@
+This folder contains the sample "-ds.xml" files that can be created for Teiid sources.
+
+JDBC: Please check "<jboss-as>/docs/examples/jca" directory for creating a -ds.xml file for any type of relational database.
+Please note you can find samples for creating both "local" and "xa" data sources.
+
+Web Serivices with ws-security: Check out Admin guide for a sample with explanation on how to use it.
+
+All the others types of sources, please find a example in this directory.
\ No newline at end of file
Deleted: trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml 2010-09-02 21:11:11 UTC (rev 2524)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<connection-factories>
- <no-tx-connection-factory>
- <!-- The jndi name of the DataSource -->
- <jndi-name>salesforceDS</jndi-name>
-
- <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
- <rar-name>teiid-connector-salesforce.rar</rar-name>
-
- <!-- connection interface; (do not change this) -->
- <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
-
- <!-- URL; the below is test; replace with actual URL you need to connect to -->
- <config-property name="URL">https://test.salesforce.com/services/Soap/u/10.0</config-property>
-
- <config-property name="username">user</config-property>
- <config-property name="password">pass</config-property>
-
- <!-- connection pool size -->
- <max-pool-size>1</max-pool-size>
- </no-tx-connection-factory>
-</connection-factories>
Copied: trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml)
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>salesforceDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-salesforce.rar</rar-name>
+
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- URL; the below is test; replace with actual URL you need to connect to -->
+ <config-property name="URL">https://test.salesforce.com/services/Soap/u/10.0</config-property>
+
+ <config-property name="username">user</config-property>
+ <config-property name="password">pass</config-property>
+
+ <!-- connection pool size -->
+ <max-pool-size>1</max-pool-size>
+ </no-tx-connection-factory>
+</connection-factories>
Deleted: trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml 2010-09-02 21:11:11 UTC (rev 2524)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<connection-factories>
-
- <no-tx-connection-factory>
- <!-- The jndi name of the DataSource -->
- <jndi-name>webserviceDS</jndi-name>
-
- <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
- <rar-name>teiid-connector-ws.rar</rar-name>
- <!-- connection interface; (do not change this) -->
- <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
-
- <!-- End point for the web service -->
- <config-property name="EndPoint">endpoint url</config-property>
-
-
- <max-pool-size>1</max-pool-size>
-
- </no-tx-connection-factory>
-
-</connection-factories>
\ No newline at end of file
Copied: trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml (from rev 2524, branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml)
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>webserviceDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- End point for the web service -->
+ <config-property name="EndPoint">endpoint url</config-property>
+
+
+ <max-pool-size>1</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Deleted: trunk/build/kits/jboss-container/teiid-examples/simpleclient/JDBCClient.class
===================================================================
(Binary files differ)
Added: trunk/build/kits/jboss-container/teiid-examples/simpleclient/JDBCClient.class
===================================================================
(Binary files differ)
Property changes on: trunk/build/kits/jboss-container/teiid-examples/simpleclient/JDBCClient.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-09-03 01:45:43 UTC (rev 2526)
@@ -10,7 +10,7 @@
<P><A HREF="http://www.teiid.org/"><IMG SRC="https://www.jboss.org/dms/teiid/images/teiid_banner.png" NAME="graphics1" ALT="Teiid" ALIGN=BOTTOM WIDTH=800></A>
<H1>Teiid ${project.version} Release Notes</H1>
-<P>Teiid ${project.version} adds ODBC, SQL, performance, and caching features.
+<P>Teiid ${project.version} adds performance and integration features.
<H2>Overview</H2>
<UL>
@@ -26,37 +26,23 @@
</UL>
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
- <LI><B>ODBC Support</B> - Support for ODBC access is now available through PostgreSQL ODBC driver clients. See the Client Developer's Guide for more on how
- to use Teiid's ODBC access.
- <LI><B>Native Materialized Tables</B> - views marked as materialized without a target table will be materialized internally by Teiid. Materialized view tables will
- be indexed by the primary key of the view if present and can be controlled through the expanded cache hint.
- There are also new system procedures refreshMatView and refreshMatViewRow to refresh internal materialized view contents.
- <LI><B>Expanded Cache Hint</B> - The cache hint can now specify pref_mem to indicate that data should prefer to be held in memory, ttl to indicate the time-to-live,
- and updatable to indicate that a materialized view with a primary key can be updated by row with the refreshMatViewRow system procedure.
- <LI><B>SQL Support</B>
- <ul>
- <li>Added NULLS FIST/LAST handling - including pushdown support.
- <li>Added enhanced numeric stat aggregate functions STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP, with pushdown and aggregate decomposition.
- <li>Added support for the boolean aggregate functions ANY, SOME, EVERY.
- <li>Added support for using boolean value expression as both criteria and expressions, e.g. "... where boolean_value" or "select x = 1 as boolean_value ...".
- <li>Changed named procedure syntax to accept param=>value, rather than param=value.
- <li>Added PRIMARY KEY and the associated index support to temp tables.
- </ul>
- <LI>
- <LI><B>Parallel Source Queries</B> - reestablished parallel execution of source queries within a query plan along with a prioritized work system to help prevent resource contention.
- <LI><B>Improved Insert Support</B> - Cross source inserts using a query expression can defer to the source to perform the entire insert atomically with source controlled batching.
- See maxPreparedInsertBatchSize on any JDBC translator supporting the InsertWithIterator capability.
- <LI><B>SHOW Statement</B> - added client handling for the SHOW statement to retrieve query plan information and see parameter values.
- <LI><B>User Identity</B> - Teiid DataSources in JBossAS connecting to a local Teiid instance can preserve the thread's user identity, rather than requiring
- a new authentication. See TeiidDataSource.setPassthroughAuthentication.
- <LI><B>VDB Versioning</B> - The VDB version may be determined by the deployed file name. The expected pattern is <VDB Name>.<Version>.vdb. See the Admin Guide
- for more on how to use VDB versioning.
+ <LI><B>Procedure Result Caching</B> - virtual procedure definitions may use a cache hint to cache results in the result set cache.
+ <LI><B>Improved Plan Caching</B> - plans used by internal materialization and stored procedure plans will be automatically cached in the prepared plan cache. Improvements were also made to reduce the memory footprint of the plans.
+ <LI><B>Refined Load Balancing and Fail Over</B> - clients can use use the statement "SET NEWINSTANCE TRUE" to allow their connection to select a new server instance. See the Client Developer's Guide for more information.
+ <LI><B>Simplified Role Usage</B> - a role can now be assigned to any authenticated user via the any-authenticated attribute on the data-role element.
+ <LI><B>Materialized View Performance</B> - materialized view tables will now automatically create and use non-unique secondary indexes for unique constraints and indexes defined on the view.
+ <LI><B>Binary Web Service Calls</B> - the ws translator now provides an invokeHttp procedure to return the blob contents and string content type of an http/https call.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
<ul>
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
</ul>
+<h4>from 7.1</h4>
+<ul>
+ <li>The jdbc:metamatrix JDBC URL prefix is no longer accepted. Use jdbc:teiid instead.
+ <li>Model visibility no longer restricts access to tables and procedures. Setting visible to false will only hide entries from system tables. Data roles should be used to restrict data access.
+</ul>
<h4>from 7.0</h4>
<ul>
<li>The term data policy was replaced with data role. The AdminAPI methods for adding role mappings have changed from addRoleToDataPolicy and removeRoleFromDataPolicy to addDataRoleMapping and removeDataRoleMapping respectively.
@@ -85,7 +71,19 @@
<h2><a name="Configuration">Configuration Issues</a></h2>
-See the See the <a href="teiid-docs/teiid_admin_guide.pdf">Admin Guide</a> for more on configuration and installation.
+See the <a href="teiid-docs/teiid_admin_guide.pdf">Admin Guide</a> for more on configuration and installation.
+
+<h4>from 7.1</h4>
+<ul>
+ <li>Apache CXF is now expected to be used as the web services stack provider through JBossWS-CXF. See the Admin Guide for instructions on
+ installing CXF for use with Teiid's Salesforce and web service connectors. The WS Resource Adapter's -ds.xml files should no longer use
+ WSSecurityConfigURL and WSSecurityConfigName, rather they should be ConfigFile and ConfigName respectively. The property values should no longer
+ refer to jboss-wsse-client.xml, but instead they should reference a CXF Spring configuration file and particular port configuration. See the Admin Guide
+ for more on using CXF configuration files.
+ <li>The default for data role checking is now "true". However only VDBs with data roles will have roles enforced.
+ <li>The default prepared plan cache size was increased to 512, since it is targeted by internal plans as well.
+</ul>
+
<h4>from 7.0</h4>
<ul>
<li>The property to enable data roles in teiid-jboss-beans.xml has changed from useEntitlements to useDataRoles.
@@ -116,32 +114,12 @@
the parseTime function cannot be pushed down. This should be addressed in future releases.
</ul>
-<h4>Salesforce as Source</h4>
-Before Salesforce is used in your data integration project, the below issues need to be resolved.
-<ul>
- <li>Manually copy the following libraries from the JBOSS_HOME/client directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used:
- <ul>
- <li>jbossws-native-saaj.jar</li>
- <li>jbossws-native-jaxrpc.jar</li>
- <li>jbossws-native-jaxws.jar</li>
- <li>jbossws-native-jaxws-ext.jar</li>
- </ul>
- </li>
- <li>There is issue with invoking "https" based URL with out specifying the either a keystore or truststore properties with JBoss remoting 2.5.1. Generally you do not need to specify the truststore as a anonymous truststore will be negotiated, however if you fail to supply the following system properties there will be a error message in the log (query will execute even with out the properties). Add these to JBOSS_INSTALL/bin/run.conf file under JAVA_OPTS
- <ul>
- <li>-Djava.net.ssl.keyStore=<path-to-truststore></li>
- <li>-Djava.net.ssl.keyStoreType=<certificate-type></li>
- <li>-Djava.net.ssl.keyStorePassword=<password></li>
- </ul>
- </li>
-</ul>
-
<h2><a name="LibraryUpdates">Thirdparty Library Updates</a></h2>
The following components have been updated:
<h4>From 7.0</h4>
<ul>
- <li>Direct integration of JBossCache jars were removed.
+ <li>Direct integration of JBossCache jars was removed.
<li>Netty was upgraded to 3.2.0
<li>JDOM was removed.
</ul>
@@ -155,174 +133,7 @@
<h2><a name="Details">Detailed Release Notes</a></h2>
Detailed Release Notes - Teiid - Version ${project.version}
-<h2> Bug
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-76'>TEIID-76</a>] - Attempting to execute a procedure from MM to MM returns error "<procedure>() does not exist"
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-108'>TEIID-108</a>] - xsd type conversion should be consistent
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1107'>TEIID-1107</a>] - Add support for raising criteria if it has been pushed too far
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1140'>TEIID-1140</a>] - Unnecessary jars in the Teiid deployment
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1141'>TEIID-1141</a>] - getCatalogs call on DatabaseMetadata is returning no rows
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1144'>TEIID-1144</a>] - PostgreSQL (simple capabilities) returning an unexpected number of rows
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1145'>TEIID-1145</a>] - Unable to deploy VDB with virtual BQT2 model
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1147'>TEIID-1147</a>] - Sybase concat function handling
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1149'>TEIID-1149</a>] - Importing tables from a deployed VDB does not import columns
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1152'>TEIID-1152</a>] - Jopr Plugin Needs to Handle Secure ProfileService Connection
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1153'>TEIID-1153</a>] - Turned of ProfileService authenticatiion and it caused an NPE in the Teiid RHQ Plugin
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1157'>TEIID-1157</a>] - NPE with texttable planning
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1166'>TEIID-1166</a>] - Receiving ASSERTION FAILED: expected reference to be not null from SQL query with sub-select
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1169'>TEIID-1169</a>] - VDBs are not being displayed in Jopr
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1172'>TEIID-1172</a>] - Loopback translator fails to be invoked when a property is set
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1178'>TEIID-1178</a>] - Jopr VDB loading error when Data Source is not available
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1180'>TEIID-1180</a>] - the deprecated input group qualifier should be replaced with inputs
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1181'>TEIID-1181</a>] - Teiid Pushdown queries producing unexpected results (Sybase 12.5)
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1182'>TEIID-1182</a>] - UDF model is not being loaded if the file is not placed in the root location of VDB
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1183'>TEIID-1183</a>] - Cannot create a SalesForce datasource throught the admin API.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1185'>TEIID-1185</a>] - Shutting down JBoss AS server causes NPE in ClusterableCacheFactory
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1186'>TEIID-1186</a>] - broken internal link in Teiid Reference Documentation
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1188'>TEIID-1188</a>] - Error while reading the template properties for LDAP
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1192'>TEIID-1192</a>] - JDBC driver doesn't accept underscores _ in server names
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1200'>TEIID-1200</a>] - Non-parsable SQL in transformation provides no help to user - NPE in stack trace
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1201'>TEIID-1201</a>] - Property 'Url' with value 'vfsfile:/home/pnittel/Teiid71/jboss-5.1.0.GA/server/default/deploy/EyeTuneZ-vdb.xml' is not a valid URL
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1203'>TEIID-1203</a>] - "connector-ws" is not visible as one of the avaialble connectors
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1206'>TEIID-1206</a>] - NPE during the JDBC Metadata read when "resultSetCacheMode=true" turned on
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1208'>TEIID-1208</a>] - VDB "getStatus" through Admin API always returning "INACTIVE"
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1216'>TEIID-1216</a>] - Cannot pass xml result from one select as critera to another select
-</li>
-</ul>
-
-<h2> Feature Request
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-168'>TEIID-168</a>] - Refine caching behavior
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-250'>TEIID-250</a>] - Enable Axis data compression in SFDC Connector, per SFDC API guidelines
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-715'>TEIID-715</a>] - Add support for nulls first/last
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-829'>TEIID-829</a>] - revamp code table caching
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-860'>TEIID-860</a>] - Add odbc support
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-886'>TEIID-886</a>] - Request for more statistical functions in Teiid
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-892'>TEIID-892</a>] - Add a capability to control bulk insert batch size
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-908'>TEIID-908</a>] - Enable access to the query plan without reference to Teiid classes.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-968'>TEIID-968</a>] - Timestamp literals with fractional seconds result in source query execution performance when being compared to less percise time types
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1006'>TEIID-1006</a>] - Dynamic vdb metadata load enhancements
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1028'>TEIID-1028</a>] - Make Materialized Views first class objects in the system
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1048'>TEIID-1048</a>] - Embedded Connection should support the pass though authentication
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1151'>TEIID-1151</a>] - Re-enable multi-threaded source query execution
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1155'>TEIID-1155</a>] - Allow boolean value expressions to be used as criteria or expressions
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1167'>TEIID-1167</a>] - Add support for primary key handling in temp tables
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1177'>TEIID-1177</a>] - Allow for implicit temp table definition with just a query, omitting the columns
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1179'>TEIID-1179</a>] - Add a CommandContext interface to the teiid api
-</li>
-</ul>
-<h2> Patch
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1184'>TEIID-1184</a>] - Patch to refactor numbered <sect> tags in documentation to <section>
-</li>
-</ul>
-
-<h2> Quality Risk
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-954'>TEIID-954</a>] - Need method to control max amount of buffer disk space
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1150'>TEIID-1150</a>] - Introduce alternative named parameter syntax
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1154'>TEIID-1154</a>] - Remove JDOM
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1187'>TEIID-1187</a>] - Refine vdb version logic
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1190'>TEIID-1190</a>] - Procedure logic clean up
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1199'>TEIID-1199</a>] - Use consistent names for security concepts
-</li>
-</ul>
-
-<h2> Task
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-749'>TEIID-749</a>] - Replace the TestNoArgConnector Test with an integration test.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-882'>TEIID-882</a>] - Look into using javax.xml.xpath in the XML-Relational connectors.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-996'>TEIID-996</a>] - Administration of the granular entitlements to data elements should be supported using the management console.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1055'>TEIID-1055</a>] - Secure profile service access
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1142'>TEIID-1142</a>] - Teiid should work with EAP 5.1
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1143'>TEIID-1143</a>] - Remove the version number from the RAR files, to promote easy migration between the versions
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1160'>TEIID-1160</a>] - Add Support for Discovery of Dynamic VDBs in Teiid Jopr Plugin
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1165'>TEIID-1165</a>] - Upgrade to Netty 3.2.0 final
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1173'>TEIID-1173</a>] - Provide a facility to create "empty" VDBs for preview purpose
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1174'>TEIID-1174</a>] - Allow '-' character in VDB names.
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1194'>TEIID-1194</a>] - Document the recommended approach to using Teiid entitlements
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1207'>TEIID-1207</a>] - Fix Yahoo Translator to work with "Dynamic Portfoilo" example
-</li>
-</ul>
-
-<h2> Sub-task
-</h2>
-<ul>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-958'>TEIID-958</a>] - Provide ability to monitor buffer manager disk space usage and free space
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1189'>TEIID-1189</a>] - JOPR support for multiple versions
-</li>
-<li>[<a href='https://jira.jboss.org/browse/TEIID-1198'>TEIID-1198</a>] - Allow specifying the VDB version as part of the VDB name in the JDBC URL connection string.
-</li>
-</ul>
-
<h2><a name="Documentation">Documentation and Help</a></h2>
The <a href="http://www.jboss.org/teiid/">Teiid community project</a> is hosted on jboss.org.
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -37,19 +37,20 @@
public class ClusterableCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -1992994494154581234L;
private CacheFactory delegate;
- private String cacheName;
+ private String resultsetCacheName;
private boolean enabled = false;
+ private String cacheManagerName;
@Override
public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
if (this.delegate == null) {
Object cacheManager = getClusteredCache();
if (cacheManager == null) {
- this.delegate = new DefaultCacheFactory();
+ this.delegate = new DefaultCacheFactory(config);
}
else {
try {
- this.delegate = new JBossCacheFactory(this.cacheName, cacheManager);
+ this.delegate = new JBossCacheFactory(this.resultsetCacheName, cacheManager);
} catch (Exception e) {
throw new TeiidRuntimeException("Failed to obtain the clusted cache"); //$NON-NLS-1$
}
@@ -58,8 +59,8 @@
return delegate.get(type, config);
}
- public void setClusteredCacheName(String name) {
- this.cacheName = name;
+ public void setResultsetCacheName(String name) {
+ this.resultsetCacheName = name;
}
@Override
@@ -70,10 +71,10 @@
}
private Object getClusteredCache() {
- if (this.enabled) {
+ if (this.enabled && this.cacheManagerName != null) {
try {
Context ctx = new InitialContext();
- return ctx.lookup("java:CacheManager"); //$NON-NLS-1$
+ return ctx.lookup(this.cacheManagerName);
} catch (NamingException e) {
return null;
}
@@ -84,4 +85,8 @@
public void setEnabled(boolean value) {
this.enabled = value;
}
+
+ public void setCacheManager(String mgrName) {
+ this.cacheManagerName = mgrName;
+ }
}
Copied: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java (from rev 2524, branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java)
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java (rev 0)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusteredTupleBatchCacheLoader.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.ReplicationException;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.cache.lock.StripedLock;
+import org.jgroups.Address;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.RspFilter;
+
+class ClusteredTupleBatchCacheLoader extends AbstractCacheLoader {
+ private StripedLock lock = new StripedLock();
+ private TupleBatchCacheLoaderConfig config;
+ private CommandsFactory commandsFactory;
+
+ private boolean init = false;
+
+ @Override
+ public void start() {
+ init();
+ }
+
+ private void init() {
+ if (!this.init) {
+ setCommandsFactory(cache.getComponentRegistry().getComponent(CommandsFactory.class));
+ this.init = true;
+ }
+ }
+
+ /**
+ * A test to check whether the cache is in its started state. If not, calls
+ * should not be made as the channel may not have properly started, blocks
+ * due to state transfers may be in progress, etc.
+ *
+ * @return true if the cache is in its STARTED state.
+ */
+ protected boolean isCacheReady() {
+ return cache.getCacheStatus() == CacheStatus.STARTED;
+ }
+
+ @Inject
+ public void setCommandsFactory(CommandsFactory commandsFactory) {
+ this.commandsFactory = commandsFactory;
+ }
+
+ /**
+ * Sets the configuration. A property <code>timeout</code> is used as the
+ * timeout value.
+ */
+ public void setConfig(IndividualCacheLoaderConfig base) {
+ this.config = (TupleBatchCacheLoaderConfig) base;
+ }
+
+ public IndividualCacheLoaderConfig getConfig() {
+ return config;
+ }
+
+ public Set getChildrenNames(Fqn fqn) throws Exception {
+ return Collections.emptySet();
+ }
+
+ private List<Object> callRemote(DataCommand dataCommand) throws Exception {
+ ClusteredGetCommand clusteredGet = commandsFactory .buildClusteredGetCommand(false, dataCommand);
+ List resps;
+ // JBCACHE-1186
+ resps = cache.getRPCManager().callRemoteMethods(null, clusteredGet, GroupRequest.GET_ALL, config.getTimeout(), new ResponseValidityFilter(cache.getMembers(), cache.getLocalAddress(), dataCommand), false);
+
+ if (resps == null) {
+ throw new ReplicationException("No replies to call " + dataCommand + ". Perhaps we're alone in the cluster?"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return resps;
+ }
+
+ public Map get(Fqn name) throws Exception {
+ return get0(name);
+ }
+
+ protected Map get0(Fqn name) throws Exception {
+ // DON'T make a remote call if this is a remote call in the first place
+ // - leads to deadlocks - JBCACHE-1103
+ if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) {
+ return null;
+ }
+ // return Collections.emptyMap();
+ lock.acquireLock(name, true);
+ try {
+ init();
+ GetDataMapCommand command = commandsFactory.buildGetDataMapCommand(name);
+ List resps = callRemote(command);
+
+ Map result = Collections.EMPTY_MAP;
+ for (Object o:resps) {
+ if (o != null && !(o instanceof Exception)) {
+ List clusteredGetResp = (List) o;
+ if ((Boolean)clusteredGetResp.get(0)) {
+ Map resp = (Map)clusteredGetResp.get(1);
+ if (!resp.isEmpty()) {
+ result = resp;
+ }
+ }
+ }
+ }
+ return result;
+ } finally {
+ lock.releaseLock(name);
+ }
+ }
+
+ public boolean exists(Fqn name) throws Exception {
+ // DON'T make a remote call if this is a remote call in the first place
+ // - leads to deadlocks - JBCACHE-1103
+ if (!isCacheReady() || !cache.getInvocationContext().isOriginLocal()) {
+ return false;
+ }
+
+ lock.acquireLock(name, false);
+ try {
+ init();
+ ExistsCommand command = commandsFactory.buildExistsNodeCommand(name);
+ List resps = callRemote(command);
+ boolean result = false;
+ for (Object o:resps) {
+ if (o != null && !(o instanceof Exception)) {
+ List<Boolean> clusteredGetResp = (List<Boolean>) o;
+ if (clusteredGetResp.get(0)) {
+ if (clusteredGetResp.get(1)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ } finally {
+ lock.releaseLock(name);
+ }
+ }
+
+ public Object put(Fqn name, Object key, Object value) throws Exception {
+ return null;
+ }
+
+ /**
+ * Does nothing; replication handles put.
+ */
+ public void put(Fqn name, Map attributes) throws Exception {
+ }
+
+ /**
+ * Does nothing; replication handles put.
+ */
+ @Override
+ public void put(List<Modification> modifications) throws Exception {
+ }
+
+ /**
+ * Fetches the remove value, does not remove. Replication handles removal.
+ */
+ public Object remove(Fqn name, Object key) throws Exception {
+ return null;
+ }
+
+ /**
+ * Does nothing; replication handles removal.
+ */
+ public void remove(Fqn name) throws Exception {
+ // do nothing
+ }
+
+ /**
+ * Does nothing; replication handles removal.
+ */
+ public void removeData(Fqn name) throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void prepare(Object tx, List modifications, boolean one_phase)
+ throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void commit(Object tx) throws Exception {
+ }
+
+ /**
+ * Does nothing.
+ */
+ @Override
+ public void rollback(Object tx) {
+ }
+
+ @Override
+ public void loadEntireState(ObjectOutputStream os) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeEntireState(ObjectInputStream is) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Exception {
+ // intentional no-op
+ }
+
+ @Override
+ public void setRegionManager(RegionManager manager) {
+ }
+
+ public static class ResponseValidityFilter implements RspFilter {
+ private int numValidResponses = 0;
+ private List<Address> pendingResponders;
+ private DataCommand command;
+
+ public ResponseValidityFilter(List<Address> expected,Address localAddress, DataCommand command) {
+ this.pendingResponders = new ArrayList<Address>(expected);
+ // We'll never get a response from ourself
+ this.pendingResponders.remove(localAddress);
+ this.command = command;
+ }
+
+ public boolean isAcceptable(Object object, Address address) {
+ pendingResponders.remove(address);
+
+ if (object instanceof List) {
+ List response = (List) object;
+ Boolean foundResult = (Boolean) response.get(0);
+ if (foundResult) {
+ if (command instanceof ExistsCommand) {
+ Boolean resp = (Boolean)response.get(1);
+ if (resp) {
+ numValidResponses++;
+ }
+ }
+ else if (command instanceof GetDataMapCommand) {
+ Map resp = (Map)response.get(1);
+ if (!resp.isEmpty()) {
+ numValidResponses++;
+ }
+ }
+ }
+ }
+ // always return true to make sure a response is logged by the
+ // JGroups RpcDispatcher.
+ return true;
+ }
+
+ public boolean needMoreResponses() {
+ return numValidResponses < 1 && pendingResponders.size() > 0;
+ }
+
+ }
+}
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -21,9 +21,6 @@
*/
package org.teiid.cache.jboss;
-import java.util.HashSet;
-import java.util.Set;
-
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -37,20 +34,6 @@
}
@Override
- public V get(K key) {
- Node<K, V> node = getRootNode();
- Node child = node.getChild(getFqn(key));
- if (child != null) {
- return (V)child.get(key);
- }
- return null;
- }
-
- private Fqn<String> getFqn(K key) {
- return Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode()));
- }
-
- @Override
public V put(K key, V value) {
return this.put(key, value, null);
}
@@ -64,32 +47,4 @@
child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
return (V)child.put(key, value);
}
-
- @Override
- public V remove(K key) {
- Node<K, V> node = getRootNode();
- Node child = node.getChild(getFqn(key));
- if (child != null) {
- return (V)child.remove(key);
- }
- return null;
- }
-
- @Override
- public void clear() {
- Node<K, V> node = getRootNode();
- node.clearData();
- Set<Node<K,V>> nodes = new HashSet<Node<K, V>>(node.getChildren());
- for (Node<K, V> child : nodes) {
- child.clearData();
- node.removeChild(child.getFqn());
- }
- }
-
- @Override
- public int size() {
- Node<K, V> node = getRootNode();
- return node.getChildren().size();
- }
-
}
Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,10 +22,7 @@
package org.teiid.cache.jboss;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.HashSet;
import java.util.Set;
import org.jboss.cache.Fqn;
@@ -50,56 +47,61 @@
this.rootFqn = fqn;
}
+ @Override
public V get(K key) {
- return this.cacheStore.get(this.rootFqn, key);
+ Node<K, V> node = getRootNode();
+ Node child = node.getChild(getFqn(key));
+ if (child != null) {
+ return (V)child.get(key);
+ }
+ return null;
}
+ protected Fqn<String> getFqn(K key) {
+ if (key.getClass().isPrimitive() || key instanceof String) {
+ return Fqn.fromString(String.valueOf(key));
+ }
+ return Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode()));
+ }
+
public V put(K key, V value) {
- return this.cacheStore.put(this.rootFqn, key, value);
+ Node<K, V> node = getRootNode();
+ Node<K, V> child = node.addChild(getFqn(key));
+ return child.put(key, value);
}
+ @Override
public V put(K key, V value, Long ttl) {
return this.put(key, value);
}
+ @Override
public V remove(K key) {
- return this.cacheStore.remove(this.rootFqn, key);
- }
-
- public Set<K> keySet() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.getKeys();
+ Node<K, V> node = getRootNode();
+ Node child = node.getChild(getFqn(key));
+ if (child != null) {
+ return (V)child.remove(key);
}
- return Collections.emptySet();
+ return null;
}
+ @Override
public int size() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.dataSize();
- }
- return 0;
+ Node<K, V> node = getRootNode();
+ return node.getChildren().size();
}
+ @Override
public void clear() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- node.clearData();
+ Node<K, V> node = getRootNode();
+ node.clearData();
+ Set<Node<K,V>> nodes = new HashSet<Node<K, V>>(node.getChildren());
+ for (Node<K, V> child : nodes) {
+ child.clearData();
+ node.removeChild(child.getFqn());
}
}
- public Collection<V> values() {
- Node<K, V> node = this.cacheStore.getRoot().getChild(this.rootFqn);
- if (node != null) {
- return node.getData().values();
- }
- return Collections.emptyList();
- }
-
- /**
- * {@inheritDoc}
- */
public synchronized void addListener(CacheListener listener) {
this.cacheListener = new JBossCacheListener(this.rootFqn, listener);
this.cacheStore.addCacheListener(this.cacheListener);
@@ -110,21 +112,6 @@
this.cacheListener = null;
}
- public Cache<K, V> addChild(String name) {
- Node<K, V> node = getRootNode();
- Node<K, V> childNode = node.addChild(Fqn.fromString(name));
- return new JBossCache<K, V>(this.cacheStore, childNode.getFqn());
- }
-
- public Cache<K, V> getChild(String name) {
- Node<K, V> node = getRootNode();
- Node<K, V> child = node.getChild(Fqn.fromString(name));
- if (child != null) {
- return new JBossCache<K, V>(this.cacheStore, child.getFqn());
- }
- return null;
- }
-
protected Node<K, V> getRootNode() {
Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
if (node == null) {
@@ -132,25 +119,7 @@
}
return node;
}
-
- public List<Cache> getChildren() {
- Node<K, V> node = getRootNode();
- Set<Node<K,V>> nodes = node.getChildren();
- if (nodes.isEmpty()) {
- return Collections.emptyList();
- }
- List<Cache> children = new ArrayList<Cache>();
- for(Node<K, V> child: nodes) {
- children.add(new JBossCache<K, V>(this.cacheStore, child.getFqn()));
- }
- return children;
- }
- public boolean removeChild(String name) {
- Node<K, V> node = getRootNode();
- return node.removeChild(Fqn.fromString(name));
- }
-
@Override
public String getName() {
return this.rootFqn.toString();
Copied: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java (from rev 2524, branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java)
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java (rev 0)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoader.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidRuntimeException;
+
+public class TupleBatchCacheLoader extends ClusteredTupleBatchCacheLoader {
+
+ private BufferManager bufferMgr;
+ private IndividualCacheLoaderConfig config;
+
+ @Override
+ public boolean exists(Fqn fqn) throws Exception {
+ String id = fqn.getLastElementAsString();
+ int index = id.indexOf(',');
+ if (index != -1) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Map<Object, Object> get(Fqn fqn) throws Exception {
+ String id = fqn.getLastElementAsString();
+ int index = id.indexOf(',');
+ if (index != -1) {
+ String uuid = id.substring(0, index);
+ int row = Integer.parseInt(id.substring(index+1));
+ TupleBuffer tb = this.bufferMgr.getTupleBuffer(uuid);
+ if (tb != null) {
+ Map map = new HashMap();
+ TupleBatch b = tb.getBatch(row);
+ b.preserveTypes();
+ map.put(id, b);
+ return map;
+ }
+ return super.get(fqn);
+ }
+ return null;
+ }
+
+ @Override
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception {
+ return super.getChildrenNames(fqn);
+ }
+
+ @Override
+ public IndividualCacheLoaderConfig getConfig() {
+ return this.config;
+ }
+
+ @Override
+ public Object put(Fqn fqn, Object key, Object value) throws Exception {
+ return super.put(fqn, key, value);
+ }
+
+ @Override
+ public void remove(Fqn fqn) throws Exception {
+ super.remove(fqn);
+ }
+
+ @Override
+ public Object remove(Fqn fqn, Object key) throws Exception {
+ return super.remove(fqn, key);
+ }
+
+ @Override
+ public void removeData(Fqn fqn) throws Exception {
+ super.removeData(fqn);
+ }
+
+ @Override
+ public void setConfig(IndividualCacheLoaderConfig config) {
+ if (!(config instanceof TupleBatchCacheLoaderConfig)) {
+ throw new TeiidRuntimeException("Wrong Configuration"); //$NON-NLS-1$
+ }
+ this.config = config;
+ TupleBatchCacheLoaderConfig bmc = (TupleBatchCacheLoaderConfig)config;
+ this.bufferMgr = bmc.getBufferService().getBufferManager();
+ super.setConfig(config);
+ }
+
+}
Copied: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java (from rev 2524, branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java)
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java (rev 0)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/TupleBatchCacheLoaderConfig.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.teiid.dqp.service.BufferService;
+
+public class TupleBatchCacheLoaderConfig extends IndividualCacheLoaderConfig {
+ private static final long serialVersionUID = -5926642610388245871L;
+ private BufferService service;
+ private long timeout;
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public TupleBatchCacheLoaderConfig() {
+ setClassName(TupleBatchCacheLoader.class.getName());
+ }
+
+ public TupleBatchCacheLoaderConfig(IndividualCacheLoaderConfig config) {
+ setClassName(TupleBatchCacheLoader.class.getName());
+ populateFromBaseConfig(config);
+ }
+
+
+ public void setBufferService(BufferService service) {
+ this.service = service;
+ }
+
+ public BufferService getBufferService() {
+ return this.service;
+ }
+}
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -189,7 +189,16 @@
*/
void clearCache(String cacheType) throws AdminException;
+
/**
+ * Get the Cache Statistics for the given type
+ * @param cacheType Cache Type
+ * @return {@link CacheStatistics}
+ * @throws AdminException
+ */
+ CacheStatistics getCacheStats(String cacheType) throws AdminException;
+
+ /**
* Terminate the Session
*
* @param identifier Session Identifier {@link org.teiid.adminapi.Session}.
Modified: trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -27,11 +27,9 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Properties;
-import java.util.concurrent.ExecutionException;
import org.teiid.client.security.LogonException;
import org.teiid.client.util.ExceptionUtil;
-import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.net.CommunicationException;
@@ -51,42 +49,23 @@
private static final int DEFAULT_BOUNCE_WAIT = 2000;
- private final class ReconnectingProxy implements InvocationHandler {
+ private final class AdminProxy implements InvocationHandler {
private Admin target;
private ServerConnection registry;
private Properties p;
private boolean closed;
- public ReconnectingProxy(Properties p) throws ConnectionException, CommunicationException {
+ public AdminProxy(Properties p) throws ConnectionException, CommunicationException {
this.p = p;
this.registry = serverConnectionFactory.getConnection(p);
this.target = registry.getService(Admin.class);
}
- private synchronized Admin getTarget() throws AdminComponentException, CommunicationException {
+ private synchronized Admin getTarget() throws AdminComponentException {
if (closed) {
throw new AdminComponentException(NetPlugin.Util.getString("ERR.014.001.0001")); //$NON-NLS-1$
}
- if (target != null) {
- ResultsFuture<?> ping = registry.isOpen();
- if (ping != null) {
- try {
- ping.get();
- return target;
- } catch (InterruptedException e) {
- throw new CommunicationException(e);
- } catch (ExecutionException e) {
- //assume recoverable
- }
- }
- }
- try {
- registry = serverConnectionFactory.getConnection(p);
- } catch (ConnectionException e) {
- throw new AdminComponentException(e);
- }
- target = registry.getService(Admin.class);
return target;
}
@@ -97,7 +76,6 @@
close();
return null;
}
- Throwable t = null;
try {
return method.invoke(getTarget(), args);
} catch (InvocationTargetException e) {
@@ -109,10 +87,7 @@
}
}
throw e.getTargetException();
- } catch (CommunicationException e) {
- t = e;
}
- throw t;
}
public synchronized void close() {
@@ -231,7 +206,7 @@
p.setProperty(TeiidURL.CONNECTION.ADMIN, Boolean.TRUE.toString());
try {
- Admin serverAdmin = (Admin)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Admin.class }, new ReconnectingProxy(p));
+ Admin serverAdmin = (Admin)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Admin.class }, new AdminProxy(p));
return serverAdmin;
} catch (ConnectionException e) {
throw new AdminComponentException(e);
Copied: trunk/client/src/main/java/org/teiid/adminapi/CacheStatistics.java (from rev 2524, branches/7.1.x/client/src/main/java/org/teiid/adminapi/CacheStatistics.java)
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/CacheStatistics.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/adminapi/CacheStatistics.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+public interface CacheStatistics extends AdminObject {
+
+ double getHitRatio();
+
+ int getTotalEntries();
+
+ int getRequestCount();
+
+}
Modified: trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/DataPolicy.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -51,6 +51,7 @@
*/
List<String> getMappedRoleNames();
+ boolean isAnyAuthenticated();
interface DataPermission {
/**
Copied: trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java (from rev 2524, branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java)
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.teiid.adminapi.CacheStatistics;
+
+(a)MetaMapping(CacheStatisticsMetadataMapper.class)
+public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
+
+ private static final long serialVersionUID = -3514505497661004560L;
+
+ private double hitRatio;
+ private int totalEntries;
+ private int requestCount;
+
+ @Override
+ @ManagementProperty(description="Number of total requests made to the cache", readOnly=true)
+ public int getRequestCount() {
+ return requestCount;
+ }
+
+ public void setRequestCount(int count) {
+ this.requestCount = count;
+ }
+
+ @Override
+ @ManagementProperty(description="Cache hit ratio", readOnly=true)
+ public double getHitRatio() {
+ return this.hitRatio;
+ }
+
+ @Override
+ @ManagementProperty(description="Total number of cache entries", readOnly=true)
+ public int getTotalEntries() {
+ return this.totalEntries;
+ }
+
+ public void setHitRatio(double value) {
+ this.hitRatio = value;
+ }
+
+ public void setTotalEntries(int value) {
+ this.totalEntries = value;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("hitRatio=").append(hitRatio);//$NON-NLS-1$
+ sb.append("; totalEntries=").append(totalEntries); //$NON-NLS-1$
+ sb.append("; requestCount=").append(requestCount); //$NON-NLS-1$
+ return sb.toString();
+ }
+}
Copied: trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java (from rev 2524, branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java)
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+public class CacheStatisticsMetadataMapper extends MetaMapper<CacheStatisticsMetadata> {
+ private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
+ private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
+ private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
+ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+ private static final MutableCompositeMetaType metaType;
+
+ static {
+ metaType = new MutableCompositeMetaType(CacheStatisticsMetadata.class.getName(), "The Cache statistics"); //$NON-NLS-1$
+ metaType.addItem(TOTAL_ENTRIES, TOTAL_ENTRIES, SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.addItem(HITRATIO, HITRATIO, SimpleMetaType.DOUBLE_PRIMITIVE);
+ metaType.addItem(REQUEST_COUNT, REQUEST_COUNT, SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.freeze();
+ }
+
+ @Override
+ public Type mapToType() {
+ return CacheStatisticsMetadata.class;
+ }
+
+ @Override
+ public MetaType getMetaType() {
+ return metaType;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, CacheStatisticsMetadata object) {
+ if (object == null)
+ return null;
+ if (metaType instanceof CompositeMetaType) {
+ CompositeMetaType composite = (CompositeMetaType) metaType;
+ CompositeValueSupport cache = new CompositeValueSupport(composite);
+
+ cache.set(TOTAL_ENTRIES, SimpleValueSupport.wrap(object.getTotalEntries()));
+ cache.set(HITRATIO, SimpleValueSupport.wrap(object.getHitRatio()));
+ cache.set(REQUEST_COUNT, SimpleValueSupport.wrap(object.getRequestCount()));
+
+ return cache;
+ }
+ throw new IllegalArgumentException("Cannot convert cache statistics " + object); //$NON-NLS-1$
+ }
+
+ @Override
+ public CacheStatisticsMetadata unwrapMetaValue(MetaValue metaValue) {
+ if (metaValue == null)
+ return null;
+
+ if (metaValue instanceof CompositeValue) {
+ CompositeValue compositeValue = (CompositeValue) metaValue;
+
+ CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
+ cache.setTotalEntries((Integer) metaValueFactory.unwrap(compositeValue.get(TOTAL_ENTRIES)));
+ cache.setHitRatio((Double) metaValueFactory.unwrap(compositeValue.get(HITRATIO)));
+ cache.setRequestCount((Integer) metaValueFactory.unwrap(compositeValue.get(REQUEST_COUNT)));
+ return cache;
+ }
+ throw new IllegalStateException("Unable to unwrap cache statistics " + metaValue); //$NON-NLS-1$
+ }
+
+}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DQPManagement.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -42,4 +42,5 @@
void mergeVDBs(String sourceVDBName, int sourceVDBVersion, String targetVDBName, int targetVDBVersion) throws AdminException;
List<RequestMetadata> getLongRunningRequests();
List<RequestMetadata> getRequestsUsingVDB(String vdbName, int vdbVersion) throws AdminException;
+ CacheStatisticsMetadata getCacheStatistics(String cacheType);
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -52,6 +52,8 @@
protected String name;
@XmlElement(name = "description")
protected String description;
+ @XmlAttribute(name = "any-authenticated")
+ protected boolean anyAuthenticated;
@XmlElement(name = "permission")
protected PermissionMap permissions = new PermissionMap(new KeyBuilder<PermissionMetaData>() {
@@ -251,4 +253,15 @@
return sb.toString();
}
}
+
+
+ @Override
+ @ManagementProperty(description="Indicates if the role is mapped to any authenticated user.")
+ public boolean isAnyAuthenticated() {
+ return this.anyAuthenticated;
+ }
+
+ public void setAnyAuthenticated(boolean anyAuthenticated) {
+ this.anyAuthenticated = anyAuthenticated;
+ }
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -45,7 +45,6 @@
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.core.util.FileUtils;
import org.teiid.core.util.StringUtil;
@@ -182,11 +181,11 @@
if (path.endsWith("/")) { //$NON-NLS-1$
path = path.substring(0, path.length() - 1);
}
- String fileName = FileUtils.getBaseFileNameWithoutExtension(path);
- String prefix = getName() + VERSION_DELIM;
- if (StringUtil.startsWithIgnoreCase(fileName, prefix)) {
+ String fileName = StringUtil.getLastToken(path, "/"); //$NON-NLS-1$
+ String[] parts = fileName.split("\\."); //$NON-NLS-1$
+ if (parts[0].equalsIgnoreCase(getName()) && parts.length >= 3) {
try {
- int fileVersion = Integer.parseInt(fileName.substring(prefix.length()));
+ int fileVersion = Integer.parseInt(parts[parts.length - 2]);
this.setVersion(fileVersion);
} catch (NumberFormatException e) {
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -42,6 +42,7 @@
private static final long serialVersionUID = -3454161477587996138L;
private String type;
private Class executionClass;
+ private String description;
@Override
@ManagementProperty(description="Name of the Translator", mandatory = true)
@@ -85,5 +86,15 @@
public void setExecutionFactoryClass(Class clazz) {
this.executionClass = clazz;
addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
- }
+ }
+
+ @ManagementProperty(description="Translator Description")
+ public String getDescription() {
+ return this.description;
+ }
+
+ @XmlAttribute(name = "description", required = true)
+ public void setDescription(String desc) {
+ this.description = desc;
+ }
}
Modified: trunk/client/src/main/java/org/teiid/client/plan/Annotation.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/plan/Annotation.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/client/plan/Annotation.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,6 +33,7 @@
public class Annotation implements Externalizable {
public static final String MATERIALIZED_VIEW = "Materialized View"; //$NON-NLS-1$
+ public static final String CACHED_PROCEDURE = "Cached Procedure"; //$NON-NLS-1$
public static final String HINTS = "Hints"; //$NON-NLS-1$
public enum Priority {
Modified: trunk/client/src/main/java/org/teiid/client/security/ILogon.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/security/ILogon.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/client/security/ILogon.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -21,11 +21,13 @@
*/
package org.teiid.client.security;
+import java.util.Collection;
import java.util.Properties;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.net.CommunicationException;
/**
@@ -33,7 +35,7 @@
*/
public interface ILogon {
LogonResult logon(Properties connectionProperties)
- throws LogonException, TeiidComponentException;
+ throws LogonException, TeiidComponentException, CommunicationException;
/**
* Ping the server to see if the client-server connection is alive.
@@ -41,8 +43,10 @@
* @throws ComponentNotFoundException if can't find the Session service.
*/
ResultsFuture<?> ping()
- throws InvalidSessionException, TeiidComponentException;
+ throws InvalidSessionException, TeiidComponentException, CommunicationException;
+ ResultsFuture<?> ping(Collection<String> sessions)
+ throws TeiidComponentException, CommunicationException;
/**
* Log off the specified session.
@@ -51,5 +55,5 @@
*/
ResultsFuture<?> logoff() throws InvalidSessionException, TeiidComponentException;
- void assertIdentity(SessionToken sessionId) throws InvalidSessionException, TeiidComponentException;
+ void assertIdentity(SessionToken sessionId) throws InvalidSessionException, TeiidComponentException, CommunicationException;
}
Modified: trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -173,14 +173,14 @@
}
}
- private Throwable readFromByteArray(byte[] contents) throws IOException {
+ private Throwable readFromByteArray(byte[] contents) {
// only for top level we would have the contents as not null.
if (contents != null) {
ByteArrayInputStream bais = new ByteArrayInputStream(contents);
- ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais, ExceptionHolder.class.getClassLoader());
try {
+ ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais, ExceptionHolder.class.getClassLoader());
return (Throwable)ois.readObject();
- } catch (ClassNotFoundException e) {
+ } catch (Exception e) {
//
}
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/jdbc/ConnectionImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -45,9 +45,6 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -878,20 +875,7 @@
}
public boolean isValid(int timeout) throws SQLException {
- ResultsFuture<?> future = this.getServerConnection().isOpen();
- if (future == null) {
- return false;
- }
- try {
- future.get(timeout, TimeUnit.SECONDS);
- return true;
- } catch (InterruptedException e) {
- return false;
- } catch (ExecutionException e) {
- return false;
- } catch (TimeoutException e) {
- return false;
- }
+ return this.getServerConnection().isOpen(timeout * 1000);
}
public void recycleConnection() {
@@ -916,10 +900,7 @@
logger.log(Level.WARNING, JDBCPlugin.Util.getString("MMXAConnection.rolling_back_error"), e); //$NON-NLS-1$
}
- //perform load balancing
- if (this.serverConn instanceof SocketServerConnection) {
- ((SocketServerConnection)this.serverConn).selectNewServerInstance(this.getDQP());
- }
+ this.serverConn.cleanUp();
}
public boolean isSameProcess(ConnectionImpl conn) throws CommunicationException {
Modified: trunk/client/src/main/java/org/teiid/jdbc/ExecutionProperties.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ExecutionProperties.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/jdbc/ExecutionProperties.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -100,5 +100,7 @@
*/
public static final String NOEXEC = "NOEXEC"; //$NON-NLS-1$
+ public static final String NEWINSTANCE = "NEWINSTANCE"; //$NON-NLS-1$
+
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/jdbc/SocketProfile.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -61,7 +61,7 @@
// This host/port pattern allows just a . or a - to be in the host part.
static final String HOST_PORT_PATTERN = "[\\p{Alnum}\\.\\-\\_]+:\\d+"; //$NON-NLS-1$
- static final String URL_PATTERN = "jdbc:(metamatrix|teiid):([\\w-\\.]+)@mm[s]?://"+HOST_PORT_PATTERN+"(,"+HOST_PORT_PATTERN+")*(;.*)?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ static final String URL_PATTERN = "jdbc:teiid:([\\w-\\.]+)@mm[s]?://"+HOST_PORT_PATTERN+"(,"+HOST_PORT_PATTERN+")*(;.*)?"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
static Pattern urlPattern = Pattern.compile(URL_PATTERN);
/**
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -395,7 +395,11 @@
}
String key = match.group(1);
String value = match.group(2);
- JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getExecutionProperties());
+ if (ExecutionProperties.NEWINSTANCE.equalsIgnoreCase(key) && Boolean.valueOf(value)) {
+ this.getMMConnection().getServerConnection().cleanUp();
+ } else {
+ JDBCURL.addNormalizedProperty(key, value, this.driverConnection.getExecutionProperties());
+ }
this.updateCounts = new int[] {0};
return;
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -80,7 +80,7 @@
ex = ExceptionUtil.getExceptionOfType(e, CommunicationException.class);
if (ex instanceof SingleInstanceCommunicationException) {
ServerConnection sc = proxiedConnection.getServerConnection();
- if (sc.isOpen() != null) {
+ if (!sc.isOpen(ServerConnection.PING_INTERVAL)) {
ex = null;
}
}
Modified: trunk/client/src/main/java/org/teiid/net/HostInfo.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/HostInfo.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/HostInfo.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,6 +23,7 @@
package org.teiid.net;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import org.teiid.core.util.ArgCheck;
@@ -31,6 +32,10 @@
/**
* Defines the hostname/port or {@link InetAddress} to connect to a host.
+ *
+ * Similar to an {@link InetSocketAddress} except that it can be constructed
+ * fully resolved, with an {@link InetAddress} and a hostname.
+ *
* @since 4.2
*/
public class HostInfo {
@@ -38,14 +43,25 @@
private String hostName;
private int portNumber = 0;
private InetAddress inetAddress;
-
- public InetAddress getInetAddress() throws UnknownHostException {
- if (inetAddress != null) {
- return inetAddress;
- }
- return InetAddress.getByName(this.hostName);
+ private boolean ssl;
+
+ /**
+ * Construct a fully resolved {@link HostInfo}.
+ * @param hostName
+ * @param addr
+ */
+ public HostInfo(String hostName, InetSocketAddress addr) {
+ this.hostName = hostName;
+ this.portNumber = addr.getPort();
+ this.inetAddress = addr.getAddress();
}
+ /**
+ * Construct a {@link HostInfo} that can resolve each
+ * time an {@link InetAddress} is asked for.
+ * @param host
+ * @param port
+ */
public HostInfo (String host, int port) {
ArgCheck.isNotNull(host);
this.hostName = host.toLowerCase();
@@ -61,6 +77,13 @@
}
}
+ public InetAddress getInetAddress() throws UnknownHostException {
+ if (inetAddress != null) {
+ return inetAddress;
+ }
+ return InetAddress.getByName(this.hostName);
+ }
+
public String getHostName() {
return hostName;
}
@@ -87,7 +110,16 @@
return false;
}
HostInfo hostInfo = (HostInfo) obj;
- return hostName.equals(hostInfo.getHostName()) && portNumber == hostInfo.getPortNumber();
+ if (portNumber != hostInfo.getPortNumber()) {
+ return false;
+ }
+ if (inetAddress != null && hostInfo.inetAddress != null) {
+ return inetAddress.equals(hostInfo.inetAddress);
+ }
+ if (ssl != hostInfo.ssl) {
+ return false;
+ }
+ return hostName.equals(hostInfo.getHostName());
}
/**
@@ -98,5 +130,17 @@
int hc = HashCodeUtil.hashCode(0, hostName);
return HashCodeUtil.hashCode(hc, portNumber);
}
+
+ public boolean isResolved() {
+ return this.inetAddress != null;
+ }
+
+ public boolean isSsl() {
+ return ssl;
+ }
+
+ public void setSsl(boolean ssl) {
+ this.ssl = ssl;
+ }
}
Modified: trunk/client/src/main/java/org/teiid/net/ServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/ServerConnection.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/ServerConnection.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,7 +23,6 @@
package org.teiid.net;
import org.teiid.client.security.LogonResult;
-import org.teiid.client.util.ResultsFuture;
public interface ServerConnection {
@@ -33,10 +32,12 @@
void close();
- ResultsFuture<?> isOpen();
+ boolean isOpen(long msToTest);
LogonResult getLogonResult();
boolean isSameInstance(ServerConnection conn) throws CommunicationException;
+ void cleanUp();
+
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/AdminApiServerDiscovery.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -82,7 +82,7 @@
&& (info.lastDiscoveryTime < System.currentTimeMillis() - DISCOVERY_TIMEOUT || info.knownHosts.isEmpty())) {
Admin serverAdmin = instance.getService(Admin.class);
try {
- Collection<ProcessObject> processes = serverAdmin.getProcesses("*");
+ Collection<ProcessObject> processes = serverAdmin.getProcesses("*"); //$NON-NLS-1$
info.knownHosts.clear();
for (ProcessObject processObject : processes) {
if (!processObject.isEnabled() || !processObject.isRunning()) {
Modified: trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -50,8 +50,8 @@
/**
* @param version The version to set.
*/
- public void setVersion(String version) {
- this.version = version;
+ public void setVersion() {
+ this.version = ApplicationInfo.getInstance().getMajorReleaseNumber();
}
/**
Modified: trunk/client/src/main/java/org/teiid/net/socket/ServerDiscovery.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/ServerDiscovery.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/ServerDiscovery.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -44,7 +44,8 @@
void init(TeiidURL url, Properties p);
/**
- * Get the currently known hosts.
+ * Get the currently known hosts. Will be called prior to connecting and after
+ * authentication for each connection.
* @param result, the current {@link LogonResult} - may be null if unauthenticated
* @param instance, the currently connected instance - may be null if not connected
* @return
@@ -67,5 +68,14 @@
* Shutdown this {@link ServerDiscovery}
*/
void shutdown();
+
+ /**
+ * Select the next instance to try. The entry should be removed from the list
+ * when no more attempts are desired.
+ * and not return null.
+ * @param hosts
+ * @return a non-null HostInfo to try
+ */
+ HostInfo selectNextInstance(List<HostInfo> hosts);
}
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -26,22 +26,18 @@
package org.teiid.net.socket;
import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.net.SocketAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -52,6 +48,7 @@
import org.teiid.client.util.ExceptionUtil;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.HostInfo;
@@ -66,8 +63,7 @@
*/
public class SocketServerConnection implements ServerConnection {
- private static final int RETRY_COUNT = 3;
-
+ private static final int FAILOVER_PING_INTERVAL = 1000;
private SocketServerInstanceFactory connectionFactory;
private ServerDiscovery serverDiscovery;
private static Logger log = Logger.getLogger("org.teiid.client.sockets"); //$NON-NLS-1$
@@ -76,97 +72,87 @@
private Properties connProps;
private SocketServerInstance serverInstance;
- private volatile LogonResult logonResult;
+ private LogonResult logonResult;
+ private Map<HostInfo, LogonResult> logonResults = new ConcurrentHashMap<HostInfo, LogonResult>();
private ILogon logon;
- private Timer pingTimer;
private boolean closed;
private boolean failOver;
+ private long lastPing = System.currentTimeMillis();
+ private int pingFailOverInterval = FAILOVER_PING_INTERVAL;
public SocketServerConnection(
SocketServerInstanceFactory connectionFactory, boolean secure,
- ServerDiscovery serverDiscovery, Properties connProps,
- Timer pingTimer) throws CommunicationException, ConnectionException {
+ ServerDiscovery serverDiscovery, Properties connProps) throws CommunicationException, ConnectionException {
this.connectionFactory = connectionFactory;
this.serverDiscovery = serverDiscovery;
this.connProps = connProps;
this.secure = secure;
+ //ILogon that is allowed to failover
this.logon = this.getService(ILogon.class);
this.failOver = Boolean.valueOf(connProps.getProperty(TeiidURL.CONNECTION.AUTO_FAILOVER)).booleanValue();
-
- authenticate();
-
- this.pingTimer = pingTimer;
- schedulePing();
+ this.failOver |= Boolean.valueOf(connProps.getProperty(TeiidURL.CONNECTION.ADMIN)).booleanValue();
+ selectServerInstance();
}
-
- private void schedulePing() {
- if (this.pingTimer != null) {
- this.pingTimer.schedule(new TimerTask() {
-
- private ResultsFuture<?> ping;
-
- @Override
- public void run() {
- if (ping == null) {
- ping = isOpen();
- }
- if (ping != null) {
- try {
- ping.get(1, TimeUnit.SECONDS);
- ping = null;
- return;
- } catch (TimeoutException e) {
- return;
- } catch (Throwable e) {
- handlePingError(e);
- }
- }
- this.cancel();
- }
-
- }, PING_INTERVAL, PING_INTERVAL);
- }
- }
/**
* Implements a sticky random selection policy
* TODO: make this customizable
* TODO: put more information on hostinfo as to process response time, last successful connect, etc.
+ * @throws ConnectionException
*/
public synchronized SocketServerInstance selectServerInstance()
- throws CommunicationException {
+ throws CommunicationException, ConnectionException {
if (closed) {
throw new CommunicationException(NetPlugin.Util.getString("SocketServerConnection.closed")); //$NON-NLS-1$
}
if (this.serverInstance != null && (!failOver || this.serverInstance.isOpen())) {
return this.serverInstance;
}
- List<HostInfo> hostKeys = new ArrayList<HostInfo>(this.serverDiscovery.getKnownHosts(logonResult, this.serverInstance));
+ List<HostInfo> hostKeys = new ArrayList<HostInfo>(this.serverDiscovery.getKnownHosts(logonResult, null));
+ boolean discoverHosts = true;
closeServerInstance();
List<HostInfo> hostCopy = new ArrayList<HostInfo>(hostKeys);
int knownHosts = hostKeys.size();
while (hostKeys.size() > 0) {
- HostInfo hostInfo = hostKeys.remove((int) (Math.random() * hostKeys.size()));
+ HostInfo hostInfo = this.serverDiscovery.selectNextInstance(hostKeys);
Exception ex = null;
try {
- SocketServerInstance instance = connectionFactory.getServerInstance(hostInfo, secure);
- this.serverInstance = instance;
- if (this.logonResult != null) {
- ILogon newLogon = instance.getService(ILogon.class);
- newLogon.assertIdentity(logonResult.getSessionToken());
+ if (!hostInfo.isResolved()) {
+ hostInfo = new HostInfo(hostInfo.getHostName(), new InetSocketAddress(hostInfo.getInetAddress(), hostInfo.getPortNumber()));
}
- this.serverDiscovery.connectionSuccessful(hostInfo);
+ ILogon newLogon = connect(hostInfo);
+ if (this.logonResult == null) {
+ try {
+ this.logonResult = newLogon.logon(connProps);
+ this.logonResults.put(this.serverInstance.getHostInfo(), this.logonResult);
+ this.connectionFactory.connected(this.serverInstance, this.logonResult.getSessionToken());
+ this.serverDiscovery.connectionSuccessful(hostInfo);
+ if (discoverHosts) {
+ List<HostInfo> updatedHosts = this.serverDiscovery.getKnownHosts(logonResult, this.serverInstance);
+ if (updatedHosts.size() > 1 && new HashSet<HostInfo>(updatedHosts).size() > new HashSet<HostInfo>(hostCopy).size()) {
+ hostKeys = updatedHosts;
+ closeServerInstance();
+ discoverHosts = false;
+ continue;
+ }
+ }
+ } catch (LogonException e) {
+ // Propagate the original message as it contains the message we want
+ // to give to the user
+ throw new ConnectionException(e, e.getMessage());
+ } catch (TeiidComponentException e) {
+ if (e.getCause() instanceof CommunicationException) {
+ throw (CommunicationException)e.getCause();
+ }
+ throw new CommunicationException(e, NetPlugin.Util.getString("PlatformServerConnectionFactory.Unable_to_find_a_component_used_in_logging_on_to")); //$NON-NLS-1$
+ }
+ }
return this.serverInstance;
} catch (IOException e) {
ex = e;
- } catch (InvalidSessionException e) {
- shutdown(false);
- throw new CommunicationException(e,NetPlugin.Util.getString("SocketServerInstance.Connection_Error.Connect_Failed", hostInfo.getHostName(), String.valueOf(hostInfo.getPortNumber()), e.getMessage())); //$NON-NLS-1$
} catch (SingleInstanceCommunicationException e) {
ex = e;
- } catch (TeiidComponentException e) {
- ex = e;
}
this.serverDiscovery.markInstanceAsBad(hostInfo);
if (knownHosts == 1) { //just a single host, use the exception
@@ -179,133 +165,124 @@
}
throw new CommunicationException(NetPlugin.Util.getString("SocketServerInstancePool.No_valid_host_available", hostCopy.toString())); //$NON-NLS-1$
}
-
- public synchronized void authenticate() throws ConnectionException, CommunicationException {
- this.logonResult = null;
- // Log on to server
- try {
- this.logonResult = logon.logon(connProps);
- List<HostInfo> knownHosts = this.serverDiscovery.getKnownHosts(logonResult, this.serverInstance);
- if (knownHosts.size() > 1 && !new HashSet<HostInfo>(knownHosts).equals(new HashSet<HostInfo>(this.serverDiscovery.getKnownHosts(logonResult, null)))) {
- //if there are multiple instances, allow for load-balancing
- closeServerInstance();
- }
- return;
- } catch (LogonException e) {
- // Propagate the original message as it contains the message we want
- // to give to the user
- throw new ConnectionException(e, e.getMessage());
- } catch (TeiidComponentException e) {
- if (e.getCause() instanceof CommunicationException) {
- throw (CommunicationException)e.getCause();
- }
- throw new CommunicationException(e, NetPlugin.Util.getString("PlatformServerConnectionFactory.Unable_to_find_a_component_used_in_logging_on_to")); //$NON-NLS-1$
- }
+
+ private ILogon connect(HostInfo hostInfo) throws CommunicationException,
+ IOException {
+ hostInfo.setSsl(secure);
+ this.serverInstance = connectionFactory.getServerInstance(hostInfo);
+ this.logonResult = logonResults.get(hostInfo);
+ ILogon newLogon = this.serverInstance.getService(ILogon.class);
+ if (this.logonResult != null) {
+ try {
+ newLogon.assertIdentity(logonResult.getSessionToken());
+ } catch (TeiidException e) {
+ // session is no longer valid
+ disconnect();
+ }
+ }
+ return newLogon;
}
- class ServerConnectionInvocationHandler implements InvocationHandler {
-
- private Class<?> targetClass;
- private Object target;
-
- public ServerConnectionInvocationHandler(Class<?> targetClass) {
- this.targetClass = targetClass;
- }
-
- private synchronized Object getTarget() throws CommunicationException {
- if (this.target == null) {
- this.target = selectServerInstance().getService(targetClass);
+ public <T> T getService(Class<T> iface) {
+ return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface) {
+ @Override
+ protected SocketServerInstance getInstance() throws CommunicationException {
+ if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) {
+ try {
+ ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping();
+ future.get();
+ } catch (SingleInstanceCommunicationException e) {
+ closeServerInstance();
+ } catch (CommunicationException e) {
+ throw e;
+ } catch (InvalidSessionException e) {
+ disconnect();
+ closeServerInstance();
+ } catch (Exception e) {
+ closeServerInstance();
+ }
+ }
+ lastPing = System.currentTimeMillis();
+ try {
+ return selectServerInstance();
+ } catch (ConnectionException e) {
+ throw new CommunicationException(e);
+ }
}
- return this.target;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- Throwable exception = null;
- for (int i = 0; i < RETRY_COUNT; i++) {
- try {
- return method.invoke(getTarget(), args);
- } catch (InvocationTargetException t) {
- exception = t.getTargetException();
- } catch (Throwable t) {
- exception = t;
- }
- if (!failOver || ExceptionUtil.getExceptionOfType(exception, SingleInstanceCommunicationException.class) == null) {
- break;
- }
- invalidateTarget();
- //TODO: look for invalid session exception
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ try {
+ return super.invoke(proxy, method, args);
+ } catch (Exception e) {
+ if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) {
+ disconnect();
+ }
+ throw e;
+ }
}
- throw ExceptionUtil.convertException(method, exception);
- }
-
- private synchronized void invalidateTarget() {
- this.target = null;
- }
-
+
+ }));
}
-
- public <T> T getService(Class<T> iface) {
- return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new ServerConnectionInvocationHandler(iface)));
- }
+
public synchronized void close() {
- shutdown(true);
- }
- private synchronized void shutdown(boolean logoff) {
if (this.closed) {
return;
}
- if (logoff) {
+ if (this.serverInstance != null) {
+ logoff();
+ }
+
+ for (Map.Entry<HostInfo, LogonResult> logonEntry : logonResults.entrySet()) {
try {
- //make a best effort to send the logoff
- Future<?> writeFuture = this.logon.logoff();
- writeFuture.get(5000, TimeUnit.MILLISECONDS);
- } catch (InvalidSessionException e) {
- //ignore
- } catch (InterruptedException e) {
- //ignore
- } catch (ExecutionException e) {
- //ignore
- } catch (TimeoutException e) {
- //ignore
- } catch (TeiidComponentException e) {
- //ignore
+ connect(logonEntry.getKey());
+ logoff();
+ } catch (Exception e) {
+
}
}
- closeServerInstance();
-
this.closed = true;
this.serverDiscovery.shutdown();
}
+
+ private void logoff() {
+ disconnect();
+ try {
+ //make a best effort to send the logoff
+ Future<?> writeFuture = this.serverInstance.getService(ILogon.class).logoff();
+ writeFuture.get(5000, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ //ignore
+ }
+ closeServerInstance();
+ }
+
+ private void disconnect() {
+ this.logonResults.remove(this.serverInstance.getHostInfo());
+ if (this.logonResult != null) {
+ this.connectionFactory.disconnected(this.serverInstance, this.logonResult.getSessionToken());
+ }
+ }
- public synchronized ResultsFuture<?> isOpen() {
+ private synchronized ResultsFuture<?> isOpen() throws CommunicationException, InvalidSessionException, TeiidComponentException {
if (this.closed) {
- return null;
+ throw new CommunicationException();
}
+ return logon.ping();
+ }
+
+ public boolean isOpen(long msToTest) {
try {
- if (!selectServerInstance().isOpen()) {
- return null;
- }
- } catch (CommunicationException e) {
- return null;
- }
- try {
- return logon.ping();
+ ResultsFuture<?> future = isOpen();
+ future.get(msToTest, TimeUnit.MILLISECONDS);
+ return true;
} catch (Throwable th) {
- return null;
+ return false;
}
}
- private void handlePingError(Throwable th) {
- if (ExceptionUtil.getExceptionOfType(th, InvalidSessionException.class) != null) {
- shutdown(false);
- } else {
- close();
- }
- }
-
public LogonResult getLogonResult() {
return logonResult;
}
@@ -321,20 +298,22 @@
if (!(otherService instanceof SocketServerConnection)) {
return false;
}
- SocketAddress address = selectServerInstance().getRemoteAddress();
- if (address == null) {
- return false;
+ try {
+ return selectServerInstance().getHostInfo().equals(((SocketServerConnection)otherService).selectServerInstance().getHostInfo());
+ } catch (ConnectionException e) {
+ throw new CommunicationException(e);
}
- return address.equals(((SocketServerConnection)otherService).selectServerInstance().getRemoteAddress());
}
- public void selectNewServerInstance(Object service) {
+ public void cleanUp() {
closeServerInstance();
- ServerConnectionInvocationHandler handler = (ServerConnectionInvocationHandler)Proxy.getInvocationHandler(service);
- handler.invalidateTarget();
}
public void setFailOver(boolean failOver) {
this.failOver = failOver;
}
+
+ public void setFailOverPingInterval(int pingFailOverInterval) {
+ this.pingFailOverInterval = pingFailOverInterval;
+ }
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -30,11 +30,16 @@
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import java.util.Timer;
+import java.util.TimerTask;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -42,12 +47,15 @@
import java.util.logging.Logger;
import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.client.security.SessionToken;
import org.teiid.core.TeiidException;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.core.util.ReflectionHelper;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.HostInfo;
+import org.teiid.net.ServerConnection;
import org.teiid.net.ServerConnectionFactory;
import org.teiid.net.TeiidURL;
@@ -106,13 +114,11 @@
private static class CachedInstance {
HostInfo info;
Integer instance;
- boolean ssl;
SocketServerInstance actual;
SocketServerInstance proxy;
- public CachedInstance(HostInfo info, boolean ssl) {
+ public CachedInstance(HostInfo info) {
this.info = info;
- this.ssl = ssl;
}
@Override
@@ -129,7 +135,7 @@
return false;
}
CachedInstance other = (CachedInstance) obj;
- if (!info.equals(other.info) || ssl != other.ssl) {
+ if (!info.equals(other.info)) {
return false;
}
if (instance == null || other.instance == null) {
@@ -142,6 +148,8 @@
private ObjectChannelFactory channelFactory;
private Timer pingTimer;
+ private HashMap<HostInfo, Set<SessionToken>> sessions = new HashMap<HostInfo, Set<SessionToken>>();
+
//instance pooling
private AtomicInteger instanceCount = new AtomicInteger();
private Map<CachedInstance, CachedInstance> instancePool = new LinkedHashMap<CachedInstance, CachedInstance>();
@@ -180,15 +188,58 @@
public void initialize(Properties info) {
PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); //$NON-NLS-1$
this.pingTimer = new Timer("SocketPing", true); //$NON-NLS-1$
+ this.pingTimer.schedule(new TimerTask() {
+
+ @Override
+ public void run() {
+ Set<Map.Entry<HostInfo, Set<SessionToken>>> sessionEntries = null;
+ synchronized (sessions) {
+ sessionEntries = new HashSet<Map.Entry<HostInfo, Set<SessionToken>>>(sessions.entrySet());
+ }
+ for (Map.Entry<HostInfo, Set<SessionToken>> entry : sessionEntries) {
+ SocketServerInstance instance = null;
+ HashSet<SessionToken> entries = null;
+ synchronized (sessions) {
+ entries = new HashSet<SessionToken>(entry.getValue());
+ }
+ try {
+ instance = getServerInstance(entry.getKey());
+ ILogon logon = instance.getService(ILogon.class);
+ if ("7.1.1".compareTo(instance.getServerVersion()) > 0) { //$NON-NLS-1$
+ for (SessionToken session : entries) {
+ try {
+ logon.assertIdentity(session);
+ logon.ping();
+ } catch (InvalidSessionException e) {
+ }
+ }
+ } else {
+ ArrayList<String> sessionStrings = new ArrayList<String>(entry.getValue().size());
+ for (SessionToken session : entries) {
+ sessionStrings.add(session.getSessionID());
+ }
+ logon.ping(sessionStrings);
+ }
+ } catch (Exception e) {
+ log.log(Level.WARNING, "Error performing keep-alive ping", e); //$NON-NLS-1$
+ } finally {
+ if (instance != null) {
+ instance.shutdown();
+ }
+ }
+ }
+ }
+ }, ServerConnection.PING_INTERVAL, ServerConnection.PING_INTERVAL);
this.channelFactory = new OioOjbectChannelFactory(info);
}
-
- public SocketServerInstance getServerInstance(HostInfo info, boolean ssl) throws CommunicationException, IOException {
+
+ @Override
+ public SocketServerInstance getServerInstance(HostInfo info) throws CommunicationException, IOException {
CachedInstance key = null;
- CachedInstance instance = null;
boolean useCache = this.maxCachedInstances > 0;
if (useCache) {
- key = new CachedInstance(info, ssl);
+ CachedInstance instance = null;
+ key = new CachedInstance(info);
synchronized (instancePool) {
instance = instancePool.remove(key);
}
@@ -197,7 +248,7 @@
boolean valid = false;
try {
Future<?> success = logon.ping();
- success.get(this.channelFactory.getSoTimeout(), TimeUnit.MICROSECONDS);
+ success.get(this.channelFactory.getSoTimeout(), TimeUnit.MILLISECONDS);
valid = true;
} catch (Exception e) {
log.log(Level.FINE, "Error performing ping, will select another instance", e); //$NON-NLS-1$
@@ -219,7 +270,7 @@
}
}
}
- SocketServerInstanceImpl ssii = new SocketServerInstanceImpl(info, ssl, getSynchronousTtl());
+ SocketServerInstanceImpl ssii = new SocketServerInstanceImpl(info, getSynchronousTtl());
ssii.connect(this.channelFactory);
if (useCache) {
key.actual = ssii;
@@ -256,7 +307,7 @@
discovery.init(url, connectionProperties);
- return new SocketServerConnection(this, url.isUsingSSL(), discovery, connectionProperties, pingTimer);
+ return new SocketServerConnection(this, url.isUsingSSL(), discovery, connectionProperties);
}
static void updateConnectionProperties(Properties connectionProperties) {
@@ -284,5 +335,30 @@
public void setMaxCachedInstances(int maxCachedInstances) {
this.maxCachedInstances = maxCachedInstances;
}
+
+ @Override
+ public void connected(SocketServerInstance instance, SessionToken session) {
+ synchronized (sessions) {
+ Set<SessionToken> instanceSessions = sessions.get(instance.getHostInfo());
+ if (instanceSessions == null) {
+ instanceSessions = new HashSet<SessionToken>();
+ sessions.put(instance.getHostInfo(), instanceSessions);
+ }
+ instanceSessions.add(session);
+ }
+ }
+
+ @Override
+ public void disconnected(SocketServerInstance instance, SessionToken session) {
+ synchronized (sessions) {
+ Set<SessionToken> instanceSessions = sessions.get(instance.getHostInfo());
+ if (instanceSessions != null) {
+ instanceSessions.remove(session);
+ if (instanceSessions.isEmpty()) {
+ sessions.remove(instance.getHostInfo());
+ }
+ }
+ }
+ }
}
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,9 +22,14 @@
package org.teiid.net.socket;
-import java.net.SocketAddress;
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.client.util.ResultsReceiver;
import org.teiid.core.crypto.Cryptor;
+import org.teiid.net.CommunicationException;
import org.teiid.net.HostInfo;
@@ -33,8 +38,6 @@
<T> T getService(Class<T> iface);
void shutdown();
-
- SocketAddress getRemoteAddress();
HostInfo getHostInfo();
@@ -42,4 +45,12 @@
Cryptor getCryptor();
+ long getSynchTimeout();
+
+ void send(Message message, ResultsReceiver<Object> receiver, Serializable key) throws CommunicationException, InterruptedException;
+
+ void read(long timeout, TimeUnit unit, ResultsFuture<?> resultsFuture) throws TimeoutException, InterruptedException;
+
+ String getServerVersion();
+
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -24,12 +24,17 @@
import java.io.IOException;
+import org.teiid.client.security.SessionToken;
import org.teiid.net.CommunicationException;
import org.teiid.net.HostInfo;
public interface SocketServerInstanceFactory {
- SocketServerInstance getServerInstance(HostInfo info, boolean ssl) throws CommunicationException, IOException;
+ SocketServerInstance getServerInstance(HostInfo info) throws CommunicationException, IOException;
+
+ void connected(SocketServerInstance instance, SessionToken session);
+
+ void disconnected(SocketServerInstance instance, SessionToken session);
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -30,7 +30,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetSocketAddress;
-import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.util.Iterator;
import java.util.Map;
@@ -53,7 +52,6 @@
import org.teiid.core.crypto.Cryptor;
import org.teiid.core.crypto.DhKeyGenerator;
import org.teiid.core.crypto.NullCryptor;
-import org.teiid.core.util.ApplicationInfo;
import org.teiid.net.CommunicationException;
import org.teiid.net.HostInfo;
import org.teiid.net.NetPlugin;
@@ -69,31 +67,28 @@
static final int HANDSHAKE_RETRIES = 10;
private static Logger log = Logger.getLogger("org.teiid.client.sockets"); //$NON-NLS-1$
- private AtomicInteger MESSAGE_ID = new AtomicInteger();
+ private static AtomicInteger MESSAGE_ID = new AtomicInteger();
private Map<Serializable, ResultsReceiver<Object>> asynchronousListeners = new ConcurrentHashMap<Serializable, ResultsReceiver<Object>>();
- private HostInfo hostInfo;
- private boolean ssl;
private long synchTimeout;
+ private HostInfo info;
private ObjectChannel socketChannel;
private Cryptor cryptor;
+ private String serverVersion;
private boolean hasReader;
- public SocketServerInstanceImpl() {
-
- }
-
- public SocketServerInstanceImpl(final HostInfo host, boolean ssl, long synchTimeout) {
- this.hostInfo = host;
- this.ssl = ssl;
+ public SocketServerInstanceImpl(HostInfo info, long synchTimeout) {
+ if (!info.isResolved()) {
+ throw new AssertionError("Expected HostInfo to be resolved"); //$NON-NLS-1$
+ }
+ this.info = info;
this.synchTimeout = synchTimeout;
}
public synchronized void connect(ObjectChannelFactory channelFactory) throws CommunicationException, IOException {
- InetSocketAddress address = new InetSocketAddress(hostInfo.getInetAddress(), hostInfo.getPortNumber());
- this.socketChannel = channelFactory.createObjectChannel(address, ssl);
+ this.socketChannel = channelFactory.createObjectChannel(new InetSocketAddress(info.getInetAddress(), info.getPortNumber()), info.isSsl());
try {
doHandshake();
} catch (CommunicationException e) {
@@ -105,20 +100,11 @@
}
}
- @Override
+ @Override
public HostInfo getHostInfo() {
- return this.hostInfo;
+ return info;
}
- @Override
- public SocketAddress getRemoteAddress() {
- return this.socketChannel.getRemoteAddress();
- }
-
- static String getVersionInfo() {
- return ApplicationInfo.getInstance().getMajorReleaseNumber();
- }
-
private void doHandshake() throws IOException, CommunicationException {
Handshake handshake = null;
for (int i = 0; i < HANDSHAKE_RETRIES; i++) {
@@ -143,9 +129,9 @@
/*if (!getVersionInfo().equals(handshake.getVersion())) {
throw new CommunicationException(NetPlugin.Util.getString("SocketServerInstanceImpl.version_mismatch", getVersionInfo(), handshake.getVersion())); //$NON-NLS-1$
}*/
+ serverVersion = handshake.getVersion();
+ handshake.setVersion();
- handshake.setVersion(getVersionInfo());
-
byte[] serverPublicKey = handshake.getPublicKey();
if (serverPublicKey != null) {
@@ -162,12 +148,17 @@
throw new CommunicationException(err);
}
}
+
+ @Override
+ public String getServerVersion() {
+ return serverVersion;
+ }
public boolean isOpen() {
return socketChannel.isOpen();
}
- protected void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
+ public void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
throws CommunicationException, InterruptedException {
if (listener != null) {
asynchronousListeners.put(messageKey, listener);
@@ -227,6 +218,7 @@
listener.receiveResults(messagePacket.getContents());
}
} else {
+ //TODO: could ping back
log.log(Level.FINE, "packet ignored:" + packet); //$NON-NLS-1$
}
}
@@ -242,7 +234,7 @@
return this.cryptor;
}
- void read(long timeout, TimeUnit unit, ResultsFuture<?> future) throws TimeoutException, InterruptedException {
+ public void read(long timeout, TimeUnit unit, ResultsFuture<?> future) throws TimeoutException, InterruptedException {
long timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
long start = System.currentTimeMillis();
while (!future.isDone()) {
@@ -280,15 +272,24 @@
}
}
}
-
+
@SuppressWarnings("unchecked")
@Override
public <T> T getService(Class<T> iface) {
- return (T)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface));
+ return (T)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new RemoteInvocationHandler(iface) {
+ @Override
+ protected SocketServerInstanceImpl getInstance() {
+ return SocketServerInstanceImpl.this;
+ }
+ });
}
- public class RemoteInvocationHandler implements InvocationHandler {
+ public long getSynchTimeout() {
+ return synchTimeout;
+ }
+ public static abstract class RemoteInvocationHandler implements InvocationHandler {
+
private boolean secure;
private Class<?> targetClass;
@@ -302,17 +303,18 @@
throws Throwable {
Throwable t = null;
try {
+ final SocketServerInstance instance = getInstance();
Message message = new Message();
message.setContents(new ServiceInvocationStruct(args, method.getName(),
targetClass));
if (secure) {
- message.setContents(getCryptor().sealObject(message.getContents()));
+ message.setContents(instance.getCryptor().sealObject(message.getContents()));
}
ResultsFuture<Object> results = new ResultsFuture<Object>() {
@Override
protected Object convertResult() throws ExecutionException {
try {
- Object result = getCryptor().unsealObject((Serializable) super.convertResult());
+ Object result = instance.getCryptor().unsealObject(super.convertResult());
if (result instanceof ExceptionHolder) {
throw new ExecutionException(((ExceptionHolder)result).getException());
}
@@ -342,17 +344,17 @@
public Object get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
- read(timeout, unit, this);
+ instance.read(timeout, unit, this);
return super.get(timeout, unit);
}
};
final ResultsReceiver<Object> receiver = results.getResultsReceiver();
- send(message, receiver, Integer.valueOf(MESSAGE_ID.getAndIncrement()));
+ instance.send(message, receiver, Integer.valueOf(MESSAGE_ID.getAndIncrement()));
if (ResultsFuture.class.isAssignableFrom(method.getReturnType())) {
return results;
}
- return results.get(synchTimeout, TimeUnit.MILLISECONDS);
+ return results.get(instance.getSynchTimeout(), TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
t = e.getCause();
} catch (TimeoutException e) {
@@ -362,6 +364,8 @@
}
throw ExceptionUtil.convertException(method, t);
}
+
+ protected abstract SocketServerInstance getInstance() throws CommunicationException;
}
Modified: trunk/client/src/main/java/org/teiid/net/socket/UrlServerDiscovery.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/UrlServerDiscovery.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/java/org/teiid/net/socket/UrlServerDiscovery.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -31,7 +31,8 @@
/**
- * Simple URL discovery strategy
+ * Simple URL discovery strategy with a random load balancing policy
+ * TOOD: add black listing support
*/
public class UrlServerDiscovery implements ServerDiscovery {
@@ -70,4 +71,9 @@
}
+ @Override
+ public HostInfo selectNextInstance(List<HostInfo> hosts) {
+ return hosts.remove((int) (Math.random() * hosts.size()));
+ }
+
}
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-09-03 01:45:43 UTC (rev 2526)
@@ -98,6 +98,7 @@
<xs:element name="mapped-role-name" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="any-authenticated" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
Modified: trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,6 +29,8 @@
import java.io.StringReader;
import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -192,4 +194,11 @@
assertEquals("http://teiid.org/myvdb.vdb", vdb.getUrl());
}
+
+ @Test public void testSetUrlVersion() throws MalformedURLException {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("foo");
+ vdb.setUrl(new URL("file:///x/foo.2.vdb"));
+ assertEquals(2, vdb.getVersion());
+ }
}
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -38,7 +38,7 @@
/** Valid format of urls*/
@Test public void testAcceptsURL1() throws Exception {
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb@mm://localhost:1234")); //$NON-NLS-1$
- assertTrue(SocketProfile.acceptsURL("jdbc:metamatrix:jvdb@mm://localhost:1234")); //$NON-NLS-1$
+ assertTrue(SocketProfile.acceptsURL("jdbc:teiid:jvdb@mm://localhost:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
@@ -58,8 +58,8 @@
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://my-host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://123.123.123.123:53535,127.0.0.1:1234")); //$NON-NLS-1$
- assertTrue(!SocketProfile.acceptsURL("jdbc:metamatrix:jvdb@localhost:1234")); //$NON-NLS-1$
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb@localhost:1234")); //$NON-NLS-1$
+ assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb@localhost:1234")); //$NON-NLS-1$
//DQP type
assertTrue(!SocketProfile.acceptsURL("jdbc:teiid:jvdb@c:/dqp.properties;version=1")); //$NON-NLS-1$
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -56,42 +56,42 @@
/** Valid format of urls*/
@Test public void testAcceptsURL1() throws Exception {
- assertTrue(drv.acceptsURL("jdbc:metamatrix:jvdb@mm://localhost:1234")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:jvdb@mms://localhost:1234")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://my-host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://123.123.123.123:53535,127.0.0.1:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:jvdb@mm://localhost:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:jvdb@mms://localhost:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234;version=x")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mms://localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234;logLevel=2")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mms://127.0.0.1:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://127.0.0.1:1234,localhost.mydomain.com:63636;logLevel=2")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://my-host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://123.123.123.123:53535,127.0.0.1:1234")); //$NON-NLS-1$
//DQP type
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:jvdb@c:/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:jvdb@/foo/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:jvdb@../foo/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb@c:/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb@/foo/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb@../foo/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:jvdb@mm://localhost:port")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:vdb@localhost:port;version=x")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
- assertTrue(!drv.acceptsURL("jdbc:metamatrix:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:jvdb@mm://localhost:port")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:vdb@localhost:port;version=x")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234,localhost2:12342,localhost3:12343;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=1;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;logLevel=2;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log;autoCommitTxn=OFF;paritalResultsMode=true")); //$NON-NLS-1$
+ assertTrue(!drv.acceptsURL("jdbc:teiid:@localhost:1234;stickyConnections=false;socketsPerVM=4")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://my_host.mydomain.com:53535,127.0.0.1:1234")); //$NON-NLS-1$
}
/** Invalid format of urls*/
@@ -104,7 +104,7 @@
@Test public void testParseURL() throws Exception{
Properties p = new Properties();
- SocketProfile.parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234", p); //$NON-NLS-1$
+ SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(TeiidURL.CONNECTION.SERVER_URL).equals("mm://slwxp157:1234")); //$NON-NLS-1$
assertEquals(3, p.size());
@@ -112,7 +112,7 @@
@Test public void testParseURL2() throws Exception {
Properties p = new Properties();
- SocketProfile.parseURL("jdbc:metamatrix:BQT@mms://slwxp157:1234;version=3", p); //$NON-NLS-1$
+ SocketProfile.parseURL("jdbc:teiid:BQT@mms://slwxp157:1234;version=3", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
assertTrue(p.getProperty(TeiidURL.CONNECTION.SERVER_URL).equals("mms://slwxp157:1234")); //$NON-NLS-1$
@@ -123,7 +123,7 @@
@Test public void testParseURL3() throws Exception{
Properties p = new Properties();
- SocketProfile.parseURL("jdbc:metamatrix:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
+ SocketProfile.parseURL("jdbc:teiid:BQT@mm://slwxp157:1234,slntmm01:43401,sluxmm09:43302;version=4;autoCommitTxn=ON;partialResultsMode=YES;ApplicationName=Client", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
@@ -135,7 +135,7 @@
}
@Test public void testGetPropertyInfo1() throws Exception {
- DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:metamatrix:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
+ DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
assertEquals(19, info.length);
assertEquals(false, info[0].required);
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java
===================================================================
--- trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/net/socket/TestAdminApiServerDiscovery.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,7 +35,6 @@
import org.teiid.client.security.LogonResult;
import org.teiid.net.HostInfo;
import org.teiid.net.TeiidURL;
-import org.teiid.net.socket.SocketServerInstance;
public class TestAdminApiServerDiscovery extends TestCase {
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
===================================================================
--- trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,29 +25,30 @@
*/
package org.teiid.net.socket;
+import static org.junit.Assert.*;
+
import java.io.IOException;
-import java.net.InetSocketAddress;
+import java.io.Serializable;
+import java.util.Collection;
import java.util.Properties;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.teiid.client.security.ILogon;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
import org.teiid.client.security.SessionToken;
import org.teiid.client.util.ResultsFuture;
+import org.teiid.client.util.ResultsReceiver;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.crypto.NullCryptor;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.HostInfo;
import org.teiid.net.TeiidURL;
-import org.teiid.net.socket.SocketServerConnection;
-import org.teiid.net.socket.SocketServerConnectionFactory;
-import org.teiid.net.socket.SocketServerInstance;
-import org.teiid.net.socket.SocketServerInstanceFactory;
/**
@@ -55,12 +56,16 @@
* @see SocketServerConnection
* @since Westport
*/
-public class TestSocketServerConnection extends TestCase {
+public class TestSocketServerConnection {
private static final class FakeILogon implements ILogon {
Throwable t;
+ public FakeILogon(Throwable t) {
+ this.t = t;
+ }
+
@Override
public void assertIdentity(SessionToken sessionId)
throws InvalidSessionException, TeiidComponentException {
@@ -83,15 +88,25 @@
@Override
public ResultsFuture<?> ping()
- throws InvalidSessionException,
- TeiidComponentException {
+ throws TeiidComponentException, CommunicationException {
if (t != null) {
+ if (t instanceof CommunicationException) {
+ CommunicationException ce = (CommunicationException)t;
+ t = null;
+ throw ce;
+ }
TeiidComponentException e = new TeiidComponentException(t);
t = null;
throw e;
}
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
+
+ @Override
+ public ResultsFuture<?> ping(Collection<String> sessions)
+ throws TeiidComponentException, CommunicationException {
+ return ping();
+ }
}
/**
@@ -109,7 +124,7 @@
*
* @since Westport
*/
- public void testSocketServerConnection_PropertiesClientHost() throws Throwable {
+ @Test public void testSocketServerConnection_PropertiesClientHost() throws Throwable {
Properties p = new Properties();
SocketServerConnectionFactory.updateConnectionProperties(p);
@@ -118,25 +133,20 @@
assertTrue(p.containsKey(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS));
}
- public void testLogonFailsWithMultipleHosts() throws Exception {
+ @Test public void testLogonFailsWithMultipleHosts() throws Exception {
Properties p = new Properties();
- SocketServerInstanceFactory instanceFactory = new SocketServerInstanceFactory() {
- @Override
- public SocketServerInstance getServerInstance(HostInfo info,
- boolean ssl) throws CommunicationException, IOException {
- throw new SingleInstanceCommunicationException();
- }
- };
+ SocketServerInstanceFactory instanceFactory = Mockito.mock(SocketServerInstanceFactory.class);
+ Mockito.stub(instanceFactory.getServerInstance((HostInfo)Mockito.anyObject())).toThrow(new SingleInstanceCommunicationException());
ServerDiscovery discovery = new UrlServerDiscovery(new TeiidURL("mm://host1:1,host2:2")); //$NON-NLS-1$
try {
- new SocketServerConnection(instanceFactory, false, discovery, p, null);
+ new SocketServerConnection(instanceFactory, false, discovery, p);
fail("exception expected"); //$NON-NLS-1$
} catch (CommunicationException e) {
assertEquals("No valid host available. Attempted connections to: [host1:1, host2:2]", e.getMessage()); //$NON-NLS-1$
}
}
- public void testLogon() throws Exception {
+ @Test public void testLogon() throws Exception {
SocketServerConnection connection = createConnection(null);
assertEquals(String.valueOf(1), connection.getLogonResult().getSessionID());
}
@@ -144,63 +154,83 @@
/**
* Since the original instance is still open, this will be a transparent retry
*/
- public void testRetry() throws Exception {
+ @Test public void testRetry() throws Exception {
SocketServerConnection connection = createConnection(new SingleInstanceCommunicationException());
connection.setFailOver(true);
+ connection.setFailOverPingInterval(50);
ILogon logon = connection.getService(ILogon.class);
+ Thread.sleep(70);
logon.ping();
}
- public void testImmediateFail() throws Exception {
+ @Test(expected=CommunicationException.class) public void testImmediateFail() throws Exception {
SocketServerConnection connection = createConnection(new CommunicationException());
ILogon logon = connection.getService(ILogon.class);
- try {
- logon.ping();
- fail("expected exception"); //$NON-NLS-1$
- } catch (TeiidComponentException e) {
-
- }
+ logon.ping();
}
- public void testImmediateFail1() throws Exception {
+ @Test(expected=CommunicationException.class) public void testImmediateFail1() throws Exception {
SocketServerConnection connection = createConnection(new CommunicationException());
connection.setFailOver(true);
ILogon logon = connection.getService(ILogon.class);
- try {
- logon.ping();
- fail("expected exception"); //$NON-NLS-1$
- } catch (TeiidComponentException e) {
-
- }
+ logon.ping();
}
private SocketServerConnection createConnection(final Throwable throwException) throws CommunicationException, ConnectionException {
return createConnection(throwException, new HostInfo("0.0.0.2", 1)); //$NON-NLS-1$
}
- private SocketServerConnection createConnection(final Throwable t, HostInfo hostInfo)
+ private SocketServerConnection createConnection(final Throwable t, final HostInfo hostInfo)
throws CommunicationException, ConnectionException {
Properties p = new Properties();
ServerDiscovery discovery = new UrlServerDiscovery(new TeiidURL(hostInfo.getHostName(), hostInfo.getPortNumber(), false));
SocketServerInstanceFactory instanceFactory = new SocketServerInstanceFactory() {
+ FakeILogon logon = new FakeILogon(t);
+
@Override
- public SocketServerInstance getServerInstance(final HostInfo info,
- boolean ssl) throws CommunicationException, IOException {
+ public SocketServerInstance getServerInstance(HostInfo info)
+ throws CommunicationException, IOException {
SocketServerInstance instance = Mockito.mock(SocketServerInstance.class);
Mockito.stub(instance.getCryptor()).toReturn(new NullCryptor());
- Mockito.stub(instance.getRemoteAddress()).toReturn(new InetSocketAddress(info.getInetAddress(), info.getPortNumber()));
- FakeILogon logon = new FakeILogon();
- logon.t = t;
+ Mockito.stub(instance.getHostInfo()).toReturn(hostInfo);
Mockito.stub(instance.getService(ILogon.class)).toReturn(logon);
+ if (t != null) {
+ try {
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation)
+ throws Throwable {
+ if (logon.t == null) {
+ return null;
+ }
+ throw logon.t;
+ }
+ }).when(instance).send((Message)Mockito.anyObject(), (ResultsReceiver<Object>)Mockito.anyObject(), (Serializable)Mockito.anyObject());
+ } catch (Exception e) {
+
+ }
+ }
Mockito.stub(instance.isOpen()).toReturn(true);
return instance;
}
+
+ @Override
+ public void connected(SocketServerInstance instance,
+ SessionToken session) {
+
+ }
+
+ @Override
+ public void disconnected(SocketServerInstance instance,
+ SessionToken session) {
+
+ }
};
- SocketServerConnection connection = new SocketServerConnection(instanceFactory, false, discovery, p, null);
+ SocketServerConnection connection = new SocketServerConnection(instanceFactory, false, discovery, p);
return connection;
}
- public void testIsSameInstance() throws Exception {
+ @Test public void testIsSameInstance() throws Exception {
SocketServerConnection conn = createConnection(null, new HostInfo("0.0.0.0", 1)); //$NON-NLS-1$
SocketServerConnection conn1 = createConnection(null, new HostInfo("0.0.0.1", 1)); //$NON-NLS-1$
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerInstanceImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerInstanceImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -34,17 +34,14 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
-import org.junit.Ignore;
import org.junit.Test;
import org.teiid.client.security.ILogon;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidComponentException;
import org.teiid.net.CommunicationException;
import org.teiid.net.HostInfo;
-import org.teiid.net.socket.ObjectChannelFactory;
-import org.teiid.net.socket.SocketServerInstanceImpl;
-
+@SuppressWarnings("nls")
public class TestSocketServerInstanceImpl {
private static class FakeObjectChannel implements ObjectChannel, ObjectChannelFactory {
@@ -127,7 +124,8 @@
private SocketServerInstanceImpl createInstance(ObjectChannelFactory channelFactory)
throws CommunicationException, IOException {
- SocketServerInstanceImpl ssii = new SocketServerInstanceImpl(new HostInfo("0.0.0.0", 1), false, 1); //$NON-NLS-1$
+ HostInfo info = new HostInfo("0.0.0.0", 1);
+ SocketServerInstanceImpl ssii = new SocketServerInstanceImpl(info, 1);
ssii.connect(channelFactory);
return ssii;
}
@@ -147,17 +145,4 @@
}
}
- @Ignore
- @Test public void testVersionMismatch() throws Exception {
- Handshake h = new Handshake();
- h.setVersion("foo"); //$NON-NLS-1$
- final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(h));
- try {
- createInstance(channel);
- fail("exception expected"); //$NON-NLS-1$
- } catch (CommunicationException e) {
- assertTrue(e.getMessage().startsWith("Handshake failed due to version mismatch")); //$NON-NLS-1$
- }
- }
-
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -40,11 +40,8 @@
import java.util.Map;
import java.util.Set;
-import javax.xml.transform.Source;
-
import org.teiid.core.CorePlugin;
import org.teiid.core.ErrorMessageKeys;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.basic.AnyToObjectTransform;
import org.teiid.core.types.basic.AnyToStringTransform;
import org.teiid.core.types.basic.BooleanToNumberTransform;
@@ -733,21 +730,6 @@
return new XMLType(value);
}
});
- //Note: the default transform from non-InputStreamFactory source is a fully materialized string
- addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- try {
- return new XMLType(new SQLXMLImpl(sxt.getString()));
- } catch (Exception e) {
- throw new TeiidRuntimeException(e);
- }
- }
- });
addSourceTransform(Date.class, new SourceTransform<Date, Timestamp>() {
@Override
public Timestamp transform(Date value) {
Modified: trunk/common-core/src/main/java/org/teiid/core/util/Assertion.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/Assertion.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/common-core/src/main/java/org/teiid/core/util/Assertion.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,9 +22,6 @@
package org.teiid.core.util;
-import java.util.Collection;
-import java.util.Map;
-
import org.teiid.core.CorePlugin;
@@ -76,210 +73,6 @@
throw new AssertionError(msg);
}
- // ########################## boolean METHODS ###################################
-
- public static final void isEqual(boolean value1, boolean value2) {
- isEqual(value1,value2,null);
- }
-
- public static final void isEqual(boolean value1, boolean value2, String message) {
- if ( value1 != value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{new Boolean(value1),new Boolean(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNotEqual(boolean value1, boolean value2) {
- isNotEqual(value1,value2,null);
- }
-
- public static final void isNotEqual(boolean value1, boolean value2, String message) {
- if ( value1 == value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotEqual",new Object[]{new Boolean(value1),new Boolean(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- // ########################## int METHODS ###################################
-
- public static final void isEqual(int value1, int value2) {
- isEqual(value1,value2,null);
- }
-
- public static final void isEqual(int value1, int value2, String message) {
- if ( value1 != value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{new Integer(value1),new Integer(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNotEqual(int value1, int value2) {
- isNotEqual(value1,value2,null);
- }
-
- public static final void isNotEqual(int value1, int value2, String message) {
- if ( value1 == value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotEqual",new Object[]{new Integer(value1),new Integer(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNonNegative(int value) {
- isNonNegative(value,null);
- }
-
- public static final void isNonNegative(int value, String message) {
- if ( value < 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNonNegative",new Object[]{new Integer(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNonPositive(int value) {
- isNonPositive(value,null);
- }
-
- public static final void isNonPositive(int value, String message) {
- if ( value > 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNonPositive",new Object[]{new Integer(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNegative(int value) {
- isNegative(value,null);
- }
-
- public static final void isNegative(int value, String message) {
- if ( value >= 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNegative",new Object[]{new Integer(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isPositive(int value) {
- isPositive(value,null);
- }
-
- public static final void isPositive(int value, String message) {
- if ( value <= 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isPositive",new Object[]{new Integer(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- // ########################## long METHODS ###################################
-
- public static final void isEqual(long value1, long value2) {
- isEqual(value1,value2,null);
- }
-
- public static final void isEqual(long value1, long value2, String message) {
- if ( value1 != value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{new Long(value1),new Long(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNotEqual(long value1, long value2) {
- isNotEqual(value1,value2,null);
- }
-
- public static final void isNotEqual(long value1, long value2, String message) {
- if ( value1 == value2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotEqual",new Object[]{new Long(value1),new Long(value2)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNonNegative(long value) {
- isNonNegative(value,null);
- }
-
- public static final void isNonNegative(long value, String message) {
- if ( value < 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNonNegative",new Object[]{new Long(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNonPositive(long value) {
- isNonPositive(value,null);
- }
-
- public static final void isNonPositive(long value, String message) {
- if ( value > 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNonPositive",new Object[]{new Long(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNegative(long value) {
- isNegative(value,null);
- }
-
- public static final void isNegative(long value, String message) {
- if ( value >= 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNegative",new Object[]{new Long(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isPositive(long value) {
- isPositive(value,null);
- }
-
- public static final void isPositive(long value, String message) {
- if ( value <= 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isPositive",new Object[]{new Long(value)}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- // ########################## String METHODS ###################################
-
- public static final void isNotZeroLength(String value) {
- isNotZeroLength(value,null);
- }
-
- public static final void isNotZeroLength(String value, String message) {
- isNotNull(value);
- if ( value.length() == 0 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotZeroLength"); //$NON-NLS-1$
- failed(msg);
- }
- }
-
// ########################## OBJECT METHODS ###################################
public static final void isNull(Object value) {
@@ -308,61 +101,6 @@
}
}
- /**
- * Compares with object1 == object2.
- */
- public static final void isIdentical(Object object1, Object object2) {
- isIdentical(object1,object2,null);
- }
-
- /**
- * Compares with object1 == object2.
- */
- public static final void isIdentical(Object object1, Object object2, String message) {
- if ( object1 != object2 ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isIdentical",new Object[]{object1,object2}); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- /**
- * Compares with object1.equals(object2).
- */
- public static final void isEqual(Object object1, Object object2) {
- isEqual(object1,object2,null);
- }
-
- /**
- * Compares with object1.equals(object2).
- */
- public static final void isEqual(Object object1, Object object2, String message) {
- if(object1 == null) {
- if ( object2 != null ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{object1,object2}); //$NON-NLS-1$
- failed(msg);
- }
- // else both are null
- } else {
- if ( object2 == null ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{object1,object2}); //$NON-NLS-1$
- failed(msg);
- }
- // else both are not null
- if ( !object1.equals(object2) ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isEqual",new Object[]{object1,object2}); //$NON-NLS-1$
- failed(msg);
- }
- }
- }
-
/**
* Verifies that the specified value is an instance of the specified class.
* @param value The value to verify
@@ -371,74 +109,17 @@
* @throws ClassCastException If the value is not an instance of the specified class.
* @since 2.1
*/
- public static final Object isInstanceOf(final Object object, final Class expectedClass, final String name) {
+ public static final <T> T isInstanceOf(final Object object, final Class<T> expectedClass, final String name) {
if (object == null) {
return null;
}
- final Class objClass = object.getClass();
+ final Class<?> objClass = object.getClass();
if (!expectedClass.isAssignableFrom(objClass)) {
final Object[] params = new Object[]{name, expectedClass, objClass.getName()};
final String msg = CorePlugin.Util.getString("Assertion.invalidClassMessage",params); //$NON-NLS-1$
throw new ClassCastException(msg);
}
- return object;
+ return expectedClass.cast(object);
}
- // ########################## COLLECTION METHODS ###################################
-
- public static final void isNotEmpty(Collection collection) {
- isNotEmpty(collection,null);
- }
-
- public static final void isNotEmpty(Collection collection, String message) {
- isNotNull(collection);
- if ( collection.isEmpty() ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotEmpty_Collection"); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void isNotEmpty(Map map) {
- isNotEmpty(map,null);
- }
-
- public static final void isNotEmpty(Map map, String message) {
- isNotNull(map);
- if ( map.isEmpty() ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.isNotEmpty_Map"); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void contains(Collection collection, Object value) {
- contains(collection,value,null);
- }
-
- public static final void contains(Collection collection, Object value, String message) {
- isNotNull(collection);
- if ( !collection.contains(value) ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.contains_Collection"); //$NON-NLS-1$
- failed(msg);
- }
- }
-
- public static final void containsKey(Map map, Object key) {
- containsKey(map,key,null);
- }
-
- public static final void containsKey(Map map, Object key, String message) {
- isNotNull(map);
- if ( !map.containsKey(key) ) {
- final String msg = message != null ?
- message :
- CorePlugin.Util.getString("Assertion.contains_Map"); //$NON-NLS-1$
- failed(msg);
- }
- }
}
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestAssertion.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestAssertion.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestAssertion.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -93,619 +93,6 @@
}
/*
- * Test for void isEqual(boolean, boolean)
- */
- public void testIsEqualbooleanboolean() {
- Assertion.isEqual(true,true);
- Assertion.isEqual(false,false);
-
- try {
- Assertion.isEqual(false,true);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Boolean(false),new Boolean(true)};
- final String msg = CorePlugin.Util.getString("Assertion.isEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(boolean, boolean, String)
- */
- public void testIsEqualbooleanbooleanString() {
- Assertion.isEqual(true,true,TEST_MESSAGE);
- Assertion.isEqual(false,false,TEST_MESSAGE);
-
- try {
- Assertion.isEqual(false,true,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(boolean, boolean)
- */
- public void testIsNotEqualbooleanboolean() {
- Assertion.isNotEqual(false,true);
- Assertion.isNotEqual(true,false);
-
- try {
- Assertion.isNotEqual(false,false);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Boolean(false),new Boolean(false)};
- final String msg = CorePlugin.Util.getString("Assertion.isNotEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(boolean, boolean, String)
- */
- public void testIsNotEqualbooleanbooleanString() {
- Assertion.isNotEqual(false,true,TEST_MESSAGE);
- Assertion.isNotEqual(true,false,TEST_MESSAGE);
-
- try {
- Assertion.isNotEqual(false,false,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(int, int)
- */
- public void testIsEqualintint() {
- Assertion.isEqual(-1,-1);
- Assertion.isEqual(1,1);
- Assertion.isEqual(0,0);
- Assertion.isEqual(10000,10000);
-
- try {
- Assertion.isEqual(1,-1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(1),new Integer(-1)};
- final String msg = CorePlugin.Util.getString("Assertion.isEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(int, int, String)
- */
- public void testIsEqualintintString() {
- Assertion.isEqual(-1,-1,TEST_MESSAGE);
- Assertion.isEqual(1,1,TEST_MESSAGE);
- Assertion.isEqual(0,0,TEST_MESSAGE);
- Assertion.isEqual(10000,10000,TEST_MESSAGE);
-
- try {
- Assertion.isEqual(1,-1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(int, int)
- */
- public void testIsNotEqualintint() {
- Assertion.isNotEqual(-1,-12);
- Assertion.isNotEqual(1,-1);
- Assertion.isNotEqual(0,1);
- Assertion.isNotEqual(10000,-10000);
-
- try {
- Assertion.isNotEqual(1,1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(1),new Integer(1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNotEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(int, int, String)
- */
- public void testIsNotEqualintintString() {
- Assertion.isNotEqual(-1,-12,TEST_MESSAGE);
- Assertion.isNotEqual(1,-1,TEST_MESSAGE);
- Assertion.isNotEqual(0,1,TEST_MESSAGE);
- Assertion.isNotEqual(10000,-10000,TEST_MESSAGE);
-
- try {
- Assertion.isNotEqual(1,1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonNegative(int)
- */
- public void testIsNonNegativeint() {
- Assertion.isNonNegative(1);
- Assertion.isNonNegative(13);
- Assertion.isNonNegative(0);
-
- try {
- Assertion.isNonNegative(-1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(-1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNonNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonNegative(int, String)
- */
- public void testIsNonNegativeintString() {
- Assertion.isNonNegative(1,TEST_MESSAGE);
- Assertion.isNonNegative(13,TEST_MESSAGE);
- Assertion.isNonNegative(0,TEST_MESSAGE);
-
- try {
- Assertion.isNonNegative(-1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonPositive(int)
- */
- public void testIsNonPositiveint() {
- Assertion.isNonPositive(-1);
- Assertion.isNonPositive(0);
- Assertion.isNonPositive(-100);
-
- try {
- Assertion.isNonPositive(1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNonPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonPositive(int, String)
- */
- public void testIsNonPositiveintString() {
- Assertion.isNonPositive(-1,TEST_MESSAGE);
- Assertion.isNonPositive(0,TEST_MESSAGE);
- Assertion.isNonPositive(-100,TEST_MESSAGE);
-
- try {
- Assertion.isNonPositive(1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNegative(int)
- */
- public void testIsNegativeint() {
- Assertion.isNegative(-1);
- Assertion.isNegative(-100);
-
- try {
- Assertion.isNegative(1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- try {
- Assertion.isNegative(0);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(0)};
- final String msg = CorePlugin.Util.getString("Assertion.isNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNegative(int, String)
- */
- public void testIsNegativeintString() {
- Assertion.isNegative(-1,TEST_MESSAGE);
- Assertion.isNegative(-100,TEST_MESSAGE);
-
- try {
- Assertion.isNegative(1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- try {
- Assertion.isNegative(0,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isPositive(int)
- */
- public void testIsPositiveint() {
- Assertion.isPositive(1);
- Assertion.isPositive(100);
-
- try {
- Assertion.isPositive(-1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(-1)};
- final String msg = CorePlugin.Util.getString("Assertion.isPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- try {
- Assertion.isPositive(0);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Integer(0)};
- final String msg = CorePlugin.Util.getString("Assertion.isPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isPositive(int, String)
- */
- public void testIsPositiveintString() {
- Assertion.isPositive(1,TEST_MESSAGE);
- Assertion.isPositive(100,TEST_MESSAGE);
-
- try {
- Assertion.isPositive(-1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- try {
- Assertion.isPositive(0,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(long, long)
- */
- public void testIsEquallonglong() {
- Assertion.isEqual(-1l,-1l);
- Assertion.isEqual(1l,1l);
- Assertion.isEqual(0l,0l);
- Assertion.isEqual(10000l,10000l);
-
- try {
- Assertion.isEqual(1l,-1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(1),new Long(-1)};
- final String msg = CorePlugin.Util.getString("Assertion.isEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(long, long, String)
- */
- public void testIsEquallonglongString() {
- Assertion.isEqual(-1l,-1l,TEST_MESSAGE);
- Assertion.isEqual(1l,1l,TEST_MESSAGE);
- Assertion.isEqual(0l,0l,TEST_MESSAGE);
- Assertion.isEqual(10000l,10000l,TEST_MESSAGE);
-
- try {
- Assertion.isEqual(1l,-1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(long, long)
- */
- public void testIsNotEquallonglong() {
- Assertion.isNotEqual(-1l,-12l);
- Assertion.isNotEqual(1l,12l);
- Assertion.isNotEqual(0l,-20l);
- Assertion.isNotEqual(10000l,-10000l);
-
- try {
- Assertion.isNotEqual(1l,1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(1l),new Long(1l)};
- final String msg = CorePlugin.Util.getString("Assertion.isNotEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotEqual(long, long, String)
- */
- public void testIsNotEquallonglongString() {
- Assertion.isNotEqual(-1l,-12l,TEST_MESSAGE);
- Assertion.isNotEqual(1l,12l,TEST_MESSAGE);
- Assertion.isNotEqual(0l,-20l,TEST_MESSAGE);
- Assertion.isNotEqual(10000l,-10000l,TEST_MESSAGE);
-
- try {
- Assertion.isNotEqual(1l,1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonNegative(long)
- */
- public void testIsNonNegativelong() {
- Assertion.isNonNegative(1l);
- Assertion.isNonNegative(13l);
- Assertion.isNonNegative(0l);
-
- try {
- Assertion.isNonNegative(-1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(-1l)};
- final String msg = CorePlugin.Util.getString("Assertion.isNonNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonNegative(long, String)
- */
- public void testIsNonNegativelongString() {
- Assertion.isNonNegative(1l,TEST_MESSAGE);
- Assertion.isNonNegative(13l,TEST_MESSAGE);
- Assertion.isNonNegative(0l,TEST_MESSAGE);
-
- try {
- Assertion.isNonNegative(-1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonPositive(long)
- */
- public void testIsNonPositivelong() {
- Assertion.isNonPositive(-1l);
- Assertion.isNonPositive(0l);
- Assertion.isNonPositive(-100l);
-
- try {
- Assertion.isNonPositive(1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNonPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNonPositive(long, String)
- */
- public void testIsNonPositivelongString() {
- Assertion.isNonPositive(-1l,TEST_MESSAGE);
- Assertion.isNonPositive(0l,TEST_MESSAGE);
- Assertion.isNonPositive(-100l,TEST_MESSAGE);
-
- try {
- Assertion.isNonPositive(1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNegative(long)
- */
- public void testIsNegativelong() {
- Assertion.isNegative(-1l);
- Assertion.isNegative(-100l);
-
- try {
- Assertion.isNegative(1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(1)};
- final String msg = CorePlugin.Util.getString("Assertion.isNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- try {
- Assertion.isNegative(0l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(0)};
- final String msg = CorePlugin.Util.getString("Assertion.isNegative",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNegative(long, String)
- */
- public void testIsNegativelongString() {
- Assertion.isNegative(-1l,TEST_MESSAGE);
- Assertion.isNegative(-100l,TEST_MESSAGE);
-
- try {
- Assertion.isNegative(1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- try {
- Assertion.isNegative(0l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isPositive(long)
- */
- public void testIsPositivelong() {
- Assertion.isPositive(1l);
- Assertion.isPositive(100l);
-
- try {
- Assertion.isPositive(-1l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(-1)};
- final String msg = CorePlugin.Util.getString("Assertion.isPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- try {
- Assertion.isPositive(0l);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{new Long(0)};
- final String msg = CorePlugin.Util.getString("Assertion.isPositive",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isPositive(long, String)
- */
- public void testIsPositivelongString() {
- Assertion.isPositive(1l,TEST_MESSAGE);
- Assertion.isPositive(100l,TEST_MESSAGE);
-
- try {
- Assertion.isPositive(-1l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- try {
- Assertion.isPositive(0l,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotZeroLength(String)
- */
- public void testIsNotZeroLengthString() {
- Assertion.isNotZeroLength("This is a string"); //$NON-NLS-1$
- Assertion.isNotZeroLength(" "); //$NON-NLS-1$
-
- try {
- Assertion.isNotZeroLength(""); //$NON-NLS-1$
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final String msg = CorePlugin.Util.getString("Assertion.isNotZeroLength"); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- try {
- Assertion.isNotZeroLength(null);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final String msg = CorePlugin.Util.getString("Assertion.isNotNull"); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isNotZeroLength(String, String)
- */
- public void testIsNotZeroLengthStringString() {
- Assertion.isNotZeroLength("This is a string",TEST_MESSAGE); //$NON-NLS-1$
- Assertion.isNotZeroLength(" ",TEST_MESSAGE); //$NON-NLS-1$
-
- try {
- Assertion.isNotZeroLength("",TEST_MESSAGE); //$NON-NLS-1$
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- try {
- Assertion.isNotZeroLength(null,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final String msg = CorePlugin.Util.getString("Assertion.isNotNull"); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
* Test for void isNull(Object)
*/
public void testIsNullObject() {
@@ -767,86 +154,6 @@
}
}
- /*
- * Test for void isIdentical(Object, Object)
- */
- public void testIsIdenticalObjectObject() {
- final String obj1 = ""; //$NON-NLS-1$
- final Integer int1 = new Integer(33);
- Assertion.isIdentical(obj1,obj1);
- Assertion.isIdentical(int1,int1);
-
- try {
- Assertion.isIdentical(int1,obj1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{int1,obj1};
- final String msg = CorePlugin.Util.getString("Assertion.isIdentical",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isIdentical(Object, Object, String)
- */
- public void testIsIdenticalObjectObjectString() {
- final String obj1 = ""; //$NON-NLS-1$
- final Integer int1 = new Integer(33);
- Assertion.isIdentical(obj1,obj1,TEST_MESSAGE);
- Assertion.isIdentical(int1,int1,TEST_MESSAGE);
-
- try {
- Assertion.isIdentical(int1,obj1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(Object, Object)
- */
- public void testIsEqualObjectObject() {
- final String obj1 = ""; //$NON-NLS-1$
- final String obj2 = ""; //$NON-NLS-1$
- final Integer int1 = new Integer(33);
- final Integer int2 = new Integer(33);
- Assertion.isEqual(obj1,obj2);
- Assertion.isEqual(int1,int2);
-
- try {
- Assertion.isEqual(int1,obj1);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- final Object[] params = new Object[]{int1,obj1};
- final String msg = CorePlugin.Util.getString("Assertion.isEqual",params); //$NON-NLS-1$
- assertEquals(msg, e.getMessage());
- }
- }
-
- /*
- * Test for void isEqual(Object, Object, String)
- */
- public void testIsEqualObjectObjectString() {
- final String obj1 = ""; //$NON-NLS-1$
- final String obj2 = ""; //$NON-NLS-1$
- final Integer int1 = new Integer(33);
- final Integer int2 = new Integer(33);
- Assertion.isEqual(obj1,obj2,TEST_MESSAGE);
- Assertion.isEqual(int1,int2,TEST_MESSAGE);
-
- try {
- Assertion.isEqual(int1,obj1,TEST_MESSAGE);
- fail();
- } catch ( AssertionError e ) {
- // expected, but check the message
- assertEquals(TEST_MESSAGE, e.getMessage());
- }
- }
-
public void testIsInstanceOf() {
Assertion.isInstanceOf(new Integer(1),Integer.class,"name"); //$NON-NLS-1$
Assertion.isInstanceOf("asdfasdf",String.class,"name2"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/connectors/connector-ldap/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/connector-ldap/src/main/rar/META-INF/ra.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -38,7 +38,7 @@
<outbound-resourceadapter>
<connection-definition>
- <managedconnectionfactory-class>org.teiid.resource.cci.ldap.LDAPManagedConnectionFactory</managedconnectionfactory-class>
+ <managedconnectionfactory-class>org.teiid.resource.adapter.ldap.LDAPManagedConnectionFactory</managedconnectionfactory-class>
<config-property>
<description>{$display:"Ldap Admin User DN",$description:"User DN for the LDAP admin account.",$required:"true"}</description>
Modified: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/connector-ws/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,11 +29,29 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-core</artifactId>
- <version>3.1.1.GA</version>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>2.2.2</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
===================================================================
--- trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,21 +1,41 @@
package org.teiid.resource.adapter.ws;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
+import javax.activation.DataSource;
import javax.resource.ResourceException;
import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Response;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
-import org.jboss.ws.core.ConfigProvider;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.DispatchImpl;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.Base64;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.StringUtil;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -28,9 +48,128 @@
* TODO: set a handler chain
*/
public class WSConnectionImpl extends BasicConnection implements WSConnection {
- private static QName svcQname = new QName("http://teiid.org", "teiid"); //$NON-NLS-1$ //$NON-NLS-2$
- private static QName portQName = new QName("http://teiid.org", "teiid");//$NON-NLS-1$ //$NON-NLS-2$
+ private static final class HttpDataSource implements DataSource {
+ private final URL url;
+ private final HttpURLConnection httpConn;
+
+ private HttpDataSource(URL url, HttpURLConnection httpConn) {
+ this.url = url;
+ this.httpConn = httpConn;
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getName() {
+ return url.getPath();
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return httpConn.getInputStream();
+ }
+
+ @Override
+ public String getContentType() {
+ return httpConn.getContentType();
+ }
+ }
+
+ /**
+ * Workaround dispatch, since neither JBossNative nor CXF 2.2.2 implement
+ * this functionality.
+ */
+ private static final class BinaryDispatch implements Dispatch<DataSource> {
+
+ HashMap<String, Object> requestContext = new HashMap<String, Object>();
+
+ private String endpoint;
+
+ public BinaryDispatch(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public DataSource invoke(DataSource msg) {
+ try {
+ final URL url = new URL(endpoint);
+ final HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setRequestMethod((String) requestContext.get(MessageContext.HTTP_REQUEST_METHOD));
+ Map<String, List<String>> header = (Map<String, List<String>>)requestContext.get(MessageContext.HTTP_REQUEST_HEADERS);
+ for (Map.Entry<String, List<String>> entry : header.entrySet()) {
+ String value = StringUtil.join(entry.getValue(), ","); //$NON-NLS-1$
+ httpConn.setRequestProperty(entry.getKey(), value);
+ }
+ String username = (String) requestContext.get(Dispatch.USERNAME_PROPERTY);
+ String password = (String) requestContext.get(Dispatch.PASSWORD_PROPERTY);
+
+ if (username != null) {
+ httpConn.setRequestProperty("Authorization", "Basic " + Base64.encodeBytes((username + ':' + password).getBytes())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (msg != null) {
+ httpConn.setDoOutput(true);
+ OutputStream os = httpConn.getOutputStream();
+ InputStream is = msg.getInputStream();
+ ObjectConverterUtil.write(os, is, -1);
+ }
+
+ return new HttpDataSource(url, httpConn);
+ } catch (IOException e) {
+ throw new WebServiceException(e);
+ }
+ }
+
+ @Override
+ public Response<DataSource> invokeAsync(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future<?> invokeAsync(DataSource msg, AsyncHandler<DataSource> handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void invokeOneWay(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Binding getBinding() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public EndpointReference getEndpointReference() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends EndpointReference> T getEndpointReference(
+ Class<T> clazz) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Map<String, Object> getRequestContext() {
+ return requestContext;
+ }
+
+ @Override
+ public Map<String, Object> getResponseContext() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ static final String DEFAULT_NAMESPACE_URI = "http://teiid.org"; //$NON-NLS-1$
+ static final String DEFAULT_LOCAL_NAME = "teiid"; //$NON-NLS-1$
+
+ private static QName svcQname = new QName(DEFAULT_NAMESPACE_URI, DEFAULT_LOCAL_NAME);
private WSManagedConnectionFactory mcf;
public WSConnectionImpl(WSManagedConnectionFactory mcf) {
@@ -38,7 +177,7 @@
}
public <T> Dispatch<T> createDispatch(String binding, String endpoint, Class<T> type, Mode mode) {
- Service svc = Service.create(svcQname);
+ ArgCheck.isNotNull(binding);
if (endpoint != null) {
try {
new URL(endpoint);
@@ -74,15 +213,36 @@
} else {
endpoint = mcf.getEndPoint();
}
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); //$NON-NLS-1$
+ Dispatch<T> dispatch = null;
+ if (HTTPBinding.HTTP_BINDING.equals(binding) && type == DataSource.class) {
+ dispatch = (Dispatch<T>) new BinaryDispatch(endpoint);
+ } else {
+ //TODO: cache service/port/dispatch instances?
+ Bus bus = BusFactory.getThreadDefaultBus();
+ BusFactory.setThreadDefaultBus(mcf.getBus());
+ Service svc;
+ try {
+ svc = Service.create(svcQname);
+ } finally {
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); //$NON-NLS-1$
+ }
+ svc.addPort(mcf.getPortQName(), binding, endpoint);
+
+ dispatch = svc.createDispatch(mcf.getPortQName(), type, mode);
+
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity
+ && mcf.getOutInterceptors() != null) {
+ Client client = ((DispatchImpl)dispatch).getClient();
+ Endpoint ep = client.getEndpoint();
+ for (Interceptor i : mcf.getOutInterceptors()) {
+ ep.getOutInterceptors().add(i);
+ }
+ }
}
- svc.addPort(portQName, binding, endpoint);
-
- Dispatch<T> dispatch = svc.createDispatch(portQName, type, mode);
-
if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
@@ -96,10 +256,6 @@
httpHeaders.put("Content-Type", Collections.singletonList("text/xml; charset=utf-8"));//$NON-NLS-1$ //$NON-NLS-2$
httpHeaders.put("User-Agent", Collections.singletonList("Teiid Server"));//$NON-NLS-1$ //$NON-NLS-2$
dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
- } else if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
- // JBoss WS-Security
- ((ConfigProvider) dispatch).setSecurityConfig(mcf.getWsSecurityConfigURL());
- ((ConfigProvider) dispatch).setConfigName(mcf.getWsSecurityConfigName());
}
return dispatch;
}
Modified: trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -21,8 +21,16 @@
*/
package org.teiid.resource.adapter.ws;
+import java.util.List;
+
import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
import org.teiid.core.BundleUtil;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.resource.spi.BasicConnectionFactory;
@@ -38,13 +46,31 @@
private String endPoint;
private String securityType = SecurityType.None.name(); // None, HTTPBasic, WS-Security
- private String wsSecurityConfigURL; // path to the "jboss-wsse-client.xml" file
- private String wsSecurityConfigName; // ws-security config name in the above file
+ private String configFile; // path to the "jbossws-cxf.xml" file
+ private String configName; // config name in the above file
private String authPassword; // httpbasic - password
private String authUserName; // httpbasic - username
+ private Bus bus;
+ private QName portQName;
+ private List<Interceptor> outInterceptors;
+
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException {
+ String configName = getConfigName();
+ if (configName == null) {
+ configName = WSConnectionImpl.DEFAULT_LOCAL_NAME;
+ }
+ this.portQName = new QName(WSConnectionImpl.DEFAULT_NAMESPACE_URI, configName);
+ if (configFile != null) {
+ bus = new SpringBusFactory().createBus(configFile);
+ JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
+ Configurer configurer = bus.getExtension(Configurer.class);
+ if (null != configurer) {
+ configurer.configureBean(portQName.toString() + ".jaxws-client.proxyFactory", instance); //$NON-NLS-1$
+ }
+ outInterceptors = instance.getOutInterceptors();
+ }
return new BasicConnectionFactory() {
@Override
public BasicConnection getConnection() throws ResourceException {
@@ -85,20 +111,32 @@
this.securityType = securityType;
}
- public String getWsSecurityConfigURL() {
- return wsSecurityConfigURL;
+ public String getConfigFile() {
+ return configFile;
}
- public void setWsSecurityConfigURL(String wsSecurityConfigURL) {
- this.wsSecurityConfigURL = wsSecurityConfigURL;
+ public void setConfigFile(String config) {
+ this.configFile = config;
}
- public String getWsSecurityConfigName() {
- return wsSecurityConfigName;
+ public String getConfigName() {
+ return configName;
}
- public void setWsSecurityConfigName(String wsSecurityConfigName) {
- this.wsSecurityConfigName = wsSecurityConfigName;
+ public void setConfigName(String configName) {
+ this.configName = configName;
}
+ public Bus getBus() {
+ return bus;
+ }
+
+ public QName getPortQName() {
+ return portQName;
+ }
+
+ public List<Interceptor> getOutInterceptors() {
+ return outInterceptors;
+ }
+
}
Modified: trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -66,14 +66,14 @@
</config-property>
<config-property>
- <description>{$display:"URL to the WS-Security Configuration File(jboss-wsse-client.xml)",$description:"JBoss WS-Security client configuration File"}</description>
- <config-property-name>WsSecurityConfigURL</config-property-name>
+ <description>{$display:"CXF Configuration File",$description:"CXF client configuration File or URL"}</description>
+ <config-property-name>ConfigFile</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
<config-property>
- <description>{$display:"WS-Security Configuration Name in jboss-wsse-client.xml",$description:"JBoss WS-Security client configuration name to use"}</description>
- <config-property-name>WsSecurityConfigName</config-property-name>
+ <description>{$display:"Configuration Name",$description:"Local name of the QName of the port configuration to use with this connection. The port namespace URI should be http://teiid.org"}</description>
+ <config-property-name>ConfigName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -37,7 +37,7 @@
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
-@Translator(name="yahoo")
+@Translator(name="yahoo", description="A translator for testing to obtain stock quotes from Yahoo web site")
public class YahooExecutionFactory extends ExecutionFactory<Object, Object> {
public static final int YAHOO_MAX_SET_SIZE = 100;
Modified: trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
===================================================================
--- trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -61,7 +61,7 @@
import org.teiid.translator.TranslatorProperty;
import org.teiid.translator.TypeFacility;
-@Translator(name="file")
+@Translator(name="file", description="File Translator, reads contents of files or writes to them")
public class FileExecutionFactory extends ExecutionFactory<ConnectionFactory, FileConnection> {
private final class FileProcedureExecution implements ProcedureExecution {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -77,7 +77,7 @@
/**
* JDBC implementation of Connector interface.
*/
-@Translator(name="jdbc-ansi")
+@Translator(name="jdbc-ansi", description="JDBC ANSI translator, can used with any ANSI compatible JDBC Driver")
public class JDBCExecutionFactory extends ExecutionFactory<DataSource, Connection> {
public static final int DEFAULT_MAX_IN_CRITERIA = 1000;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,7 +33,7 @@
* This capabilities class may come in handy for testing and for
* sources that support JDBC but don't support extended JDBC capabilities.
*/
-@Translator(name="jdbc-simple")
+@Translator(name="jdbc-simple", description="An extended JDBC ANSI translator with some simple capabilities")
public class SimpleJDBCExecutionFactory extends JDBCExecutionFactory {
public SimpleJDBCExecutionFactory() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,7 +33,7 @@
import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.sybase.SybaseExecutionFactory;
-@Translator(name="access")
+@Translator(name="access", description="A translator for Microsoft Access Database")
public class AccessExecutionFactory extends SybaseExecutionFactory {
public AccessExecutionFactory() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -47,7 +47,7 @@
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.ModFunctionModifier;
-@Translator(name="db2")
+@Translator(name="db2", description="A translator for IBM DB2 Database")
public class DB2ExecutionFactory extends JDBCExecutionFactory {
private final class NullHandlingFormatModifier extends
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,7 +35,7 @@
/**
* @since 4.3
*/
-@Translator(name="derby")
+@Translator(name="derby", description="A translator for Apache Derby Database")
public class DerbyExecutionFactory extends DB2ExecutionFactory {
public static final String TEN_1 = "10.1"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -39,7 +39,7 @@
import org.teiid.translator.jdbc.hsql.AddDiffModifier;
import org.teiid.translator.jdbc.oracle.ConcatFunctionModifier;
-@Translator(name="h2")
+@Translator(name="h2", description="A translator for open source H2 Database")
public class H2ExecutionFactory extends JDBCExecutionFactory {
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,7 +35,7 @@
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-@Translator(name="hsql")
+@Translator(name="hsql", description="A translator for open source HSQL Database")
public class HsqlExecutionFactory extends JDBCExecutionFactory {
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -34,7 +34,7 @@
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-@Translator(name="informix")
+@Translator(name="informix", description="A translator for Informix Database")
public class InformixExecutionFactory extends JDBCExecutionFactory {
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -14,7 +14,7 @@
/**
* Capabilities compatible with MM 5.5.x
*/
-@Translator(name="metamatrix")
+@Translator(name="metamatrix", description="A translator for MetaMatrix Virtual Database")
public class MetaMatrixExecutionFactory extends JDBCExecutionFactory {
public List<String> getSupportedFunctions() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -47,7 +47,7 @@
/**
* Translator class for accessing the ModeShape JCR repository.
*/
-@Translator(name="modeshape")
+@Translator(name="modeshape", description="A translator for open source Modeshape JCA repository")
public class ModeShapeExecutionFactory extends JDBCExecutionFactory {
public ModeShapeExecutionFactory() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -32,7 +32,7 @@
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.FunctionModifier;
-@Translator(name="mysql5")
+@Translator(name="mysql5", description="A translator for open source MySQL5 Database")
public class MySQL5ExecutionFactory extends MySQLExecutionFactory {
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -43,7 +43,7 @@
/**
* @since 4.3
*/
-@Translator(name="mysql")
+@Translator(name="mysql", description="A translator for open source MySQL Database, used with any version lower than 5")
public class MySQLExecutionFactory extends JDBCExecutionFactory {
public MySQLExecutionFactory() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -62,7 +62,7 @@
import org.teiid.translator.jdbc.LocateFunctionModifier;
-@Translator(name="oracle")
+@Translator(name="oracle", description="A translator for Oracle Database")
public class OracleExecutionFactory extends JDBCExecutionFactory {
private static final String TIME_FORMAT = "HH24:MI:SS"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -57,7 +57,7 @@
* Translator class for PostgreSQL. Updated to expect a 8.0+ jdbc client
* @since 4.3
*/
-@Translator(name="postgresql")
+@Translator(name="postgresql", description="A translator for postgreSQL Database")
public class PostgreSQLExecutionFactory extends JDBCExecutionFactory {
public static final String EIGHT_0 = "8.0"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -41,7 +41,7 @@
/**
* Updated to assume the use of the DataDirect, 2005 driver, or later.
*/
-@Translator(name="sqlserver")
+@Translator(name="sqlserver", description="A translator for Microsoft SQL Server Database")
public class SQLServerExecutionFactory extends SybaseExecutionFactory {
public static final String V_2005 = "2005"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -51,7 +51,7 @@
import org.teiid.translator.jdbc.oracle.ConcatFunctionModifier;
-@Translator(name="sybase")
+@Translator(name="sybase", description="A translator for Sybase Database")
public class SybaseExecutionFactory extends JDBCExecutionFactory {
public static final String TWELVE_5 = "12.5"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,7 +35,7 @@
/**
* @since 4.3
*/
-@Translator(name="teiid")
+@Translator(name="teiid", description="A translator for Teiid Virtual Database")
public class TeiidExecutionFactory extends JDBCExecutionFactory {
public static final String SEVEN_0 = "7.0"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,7 +33,7 @@
/**
* for Teradata database Release V2R5.1
*/
-@Translator(name="teradata")
+@Translator(name="teradata", description="A translator for Teradata Database")
public class TeradataExecutionFactory extends JDBCExecutionFactory {
public TeradataExecutionFactory() {
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -41,7 +41,7 @@
* LDAP translator. This is responsible for initializing
* a connection factory, and obtaining connections to LDAP.
*/
-@Translator(name="ldap")
+@Translator(name="ldap", description="A translator for LDAP directory")
public class LDAPExecutionFactory extends ExecutionFactory<ConnectionFactory, LdapContext> {
public enum SearchDefaultScope {
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -37,7 +37,7 @@
/**
* Loopback translator.
*/
-@Translator(name="loopback")
+@Translator(name="loopback", description="A translator for testing, that returns mock data")
public class LoopbackExecutionFactory extends ExecutionFactory<Object, Object> {
private int waitTime = 0;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -48,7 +48,7 @@
import org.teiid.translator.salesforce.execution.QueryExecutionImpl;
import org.teiid.translator.salesforce.execution.UpdateExecutionImpl;
-@Translator(name="salesforce")
+@Translator(name="salesforce", description="A translator for Salesforce")
public class SalesForceExecutionFactory extends ExecutionFactory<ConnectionFactory, SalesforceConnection> {
private String connectorStateClass;
Copied: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java (from rev 2524, branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java)
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java (rev 0)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.ws;
+
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.sql.rowset.serial.SerialClob;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.WSConnection;
+
+/**
+ * http handler
+ */
+public class BinaryWSProcedureExecution implements ProcedureExecution {
+
+ RuntimeMetadata metadata;
+ ExecutionContext context;
+ private Call procedure;
+ private DataSource returnValue;
+ private WSConnection conn;
+ WSExecutionFactory executionFactory;
+
+ /**
+ * @param env
+ */
+ public BinaryWSProcedureExecution(Call procedure, RuntimeMetadata metadata, ExecutionContext context, WSExecutionFactory executionFactory, WSConnection conn) {
+ this.metadata = metadata;
+ this.context = context;
+ this.procedure = procedure;
+ this.conn = conn;
+ this.executionFactory = executionFactory;
+ }
+
+ public void execute() throws TranslatorException {
+ List<Argument> arguments = this.procedure.getArguments();
+
+ String method = (String)arguments.get(0).getArgumentValue().getValue();
+ Object payload = arguments.get(1).getArgumentValue().getValue();
+ String endpoint = (String)arguments.get(2).getArgumentValue().getValue();
+ try {
+ Dispatch<DataSource> dispatch = conn.createDispatch(HTTPBinding.HTTP_BINDING, endpoint, DataSource.class, Mode.MESSAGE);
+
+ if (method == null) {
+ method = "POST"; //$NON-NLS-1$
+ }
+
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, method);
+ if (payload != null && !"POST".equalsIgnoreCase(method)) { //$NON-NLS-1$
+ throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
+ }
+
+ DataSource ds = null;
+ if (payload instanceof String) {
+ ds = new InputStreamFactory.ClobInputStreamFactory(new SerialClob(((String)payload).toCharArray()));
+ } else if (payload instanceof SQLXML) {
+ ds = new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML)payload);
+ } else if (payload instanceof Clob) {
+ ds = new InputStreamFactory.ClobInputStreamFactory((Clob)payload);
+ } else if (payload instanceof Blob) {
+ ds = new InputStreamFactory.BlobInputStreamFactory((Blob)payload);
+ }
+
+ returnValue = dispatch.invoke(ds);
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ } catch (WebServiceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return Arrays.asList(returnValue, returnValue.getContentType());
+ }
+
+ public void close() {
+
+ }
+
+ public void cancel() throws TranslatorException {
+ // no-op
+ }
+}
Modified: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,12 +22,10 @@
package org.teiid.translator.ws;
-import java.sql.SQLXML;
import java.util.Collections;
import java.util.List;
import javax.resource.cci.ConnectionFactory;
-import javax.xml.transform.Source;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.SOAPBinding;
@@ -49,9 +47,11 @@
import org.teiid.translator.TypeFacility;
import org.teiid.translator.WSConnection;
-@Translator(name="ws")
+@Translator(name="ws", description="A translator for making Web Service calls")
public class WSExecutionFactory extends ExecutionFactory<ConnectionFactory, WSConnection> {
+ private static final String INVOKE_HTTP = "invokeHttp"; //$NON-NLS-1$
+
public enum Binding {
HTTP(HTTPBinding.HTTP_BINDING),
SOAP11(SOAPBinding.SOAP11HTTP_BINDING),
@@ -104,13 +104,12 @@
@Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, WSConnection connection)
throws TranslatorException {
+ if (command.getProcedureName().equalsIgnoreCase(INVOKE_HTTP)) {
+ return new BinaryWSProcedureExecution(command, metadata, executionContext, this, connection);
+ }
return new WSProcedureExecution(command, metadata, executionContext, this, connection);
}
- public SQLXML convertToXMLType(Source value) {
- return (SQLXML)getTypeFacility().convertToRuntimeType(value);
- }
-
@Override
public final List getSupportedFunctions() {
return Collections.EMPTY_LIST;
@@ -132,7 +131,7 @@
//can be one of string, xml, clob
param = metadataFactory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.XML, Type.In, p); //$NON-NLS-1$
- param.setAnnotation("The XML document or root element that represents the request. If the ExecutionFactory is configured in with a DefaultServiceMode or MESSAGE then SOAP request must contain the entire SOAP message."); //$NON-NLS-1$
+ param.setAnnotation("The XML document or root element that represents the request. If the ExecutionFactory is configured in with a DefaultServiceMode of MESSAGE, then the SOAP request must contain the entire SOAP message."); //$NON-NLS-1$
param.setNullType(NullType.Nullable);
param = metadataFactory.addProcedureParameter("endpoint", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
@@ -140,11 +139,11 @@
param.setNullType(NullType.Nullable);
metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
- /*
+
p = metadataFactory.addProcedure(INVOKE_HTTP);
p.setAnnotation("Invokes a webservice that returns an binary result"); //$NON-NLS-1$
- param = metadataFactory.addProcedureParameter("method", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param = metadataFactory.addProcedureParameter("action", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
param.setAnnotation("Sets the HTTP Method (GET, POST - default, etc.)."); //$NON-NLS-1$
param.setNullType(NullType.Nullable);
@@ -159,7 +158,6 @@
metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.BLOB, Type.ReturnValue, p); //$NON-NLS-1$
metadataFactory.addProcedureParameter("contentType", TypeFacility.RUNTIME_NAMES.STRING, Type.Out, p); //$NON-NLS-1$
- */
}
}
Modified: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -42,9 +42,6 @@
import org.teiid.core.types.XMLType;
import org.teiid.language.Argument;
import org.teiid.language.Call;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
@@ -62,7 +59,7 @@
RuntimeMetadata metadata;
ExecutionContext context;
private Call procedure;
- private SQLXML returnValue;
+ private Source returnValue;
private WSConnection conn;
private WSExecutionFactory executionFactory;
@@ -83,7 +80,7 @@
String style = (String)arguments.get(0).getArgumentValue().getValue();
String action = (String)arguments.get(1).getArgumentValue().getValue();
XMLType docObject = (XMLType)arguments.get(2).getArgumentValue().getValue();
- Source source = null;
+ StreamSource source = null;
try {
source = convertToSource(docObject);
String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
@@ -99,7 +96,7 @@
}
}
- Dispatch<Source> dispatch = conn.createDispatch(style, endpoint, Source.class, executionFactory.getDefaultServiceMode());
+ Dispatch<StreamSource> dispatch = conn.createDispatch(style, endpoint, StreamSource.class, executionFactory.getDefaultServiceMode());
if (Binding.HTTP.getBindingId().equals(style)) {
if (action == null) {
@@ -132,14 +129,7 @@
// JBoss Native DispatchImpl throws exception when the source is null
source = new StreamSource(new StringReader("<none/>")); //$NON-NLS-1$
}
- Source result = dispatch.invoke(source);
- this.returnValue = this.executionFactory.convertToXMLType(result);
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- try {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "WebService Response: " + this.returnValue.getString()); //$NON-NLS-1$
- } catch (SQLException e) {
- }
- }
+ this.returnValue = dispatch.invoke(source);
} catch (SQLException e) {
throw new TranslatorException(e);
} catch (WebServiceException e) {
@@ -153,9 +143,6 @@
if (xml == null) {
return null;
}
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " + xml.getString()); //$NON-NLS-1$
- }
return xml.getSource(StreamSource.class);
}
Modified: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,9 +22,9 @@
package org.teiid.rhq.admin;
import java.lang.reflect.Method;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -40,10 +40,14 @@
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
+import org.teiid.adminapi.Admin;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.Transaction;
@@ -51,6 +55,7 @@
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.RequestMetadataMapper;
import org.teiid.rhq.plugin.objects.ExecutedResult;
+import org.teiid.rhq.plugin.util.DeploymentUtils;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
@@ -59,29 +64,24 @@
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() {
-
}
/*
* 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;
@@ -92,36 +92,36 @@
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)) {
- 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)) {
- try {
- 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 .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)) {
+ try {
+ 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$
+ return getCacheProperty(connection, metric);
}
-
return resultObject;
}
+
+ 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();
+ }
private Object getVdbMetric(ProfileServiceConnection connection,
String componentType, String identifier, String metric,
@@ -129,31 +129,21 @@
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;
}
@@ -161,19 +151,13 @@
* 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);
}
-
}
private void executePlatformOperation(ProfileServiceConnection connection,
@@ -245,6 +229,30 @@
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);
+ 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));
+ }
+ 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;
+ }
+
+ try {
+ URL url = new URL(vdbUrl);
+ 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);
+ throw new RuntimeException(e);
+ }
}
}
@@ -552,6 +560,16 @@
}
return count;
}
+
+ protected MetaValue getCacheStats(ProfileServiceConnection connection, String type) {
+ try {
+ 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$
+ }
+ return null;
+ }
protected MetaValue getLongRunningQueries(
ProfileServiceConnection connection) {
@@ -586,20 +604,16 @@
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 = (RequestMetadata) rmm
- .unwrapMetaValue(value);
+ 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$
}
}
}
@@ -609,15 +623,12 @@
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$
}
}
}
@@ -627,15 +638,12 @@
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$
}
}
}
@@ -645,17 +653,14 @@
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$
}
}
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -43,11 +43,8 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.jbossas5.ApplicationServerComponent;
-import org.rhq.plugins.jbossas5.ProfileServiceComponent;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -59,22 +56,14 @@
*
*/
public class PlatformComponent extends Facet {
- private final Log LOG = LogFactory
- .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer",
- "BufferService", "SessionService", "JdbcSocketConfiguration" };
+ String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer", //$NON-NLS-1$
+ "BufferService", "SessionService", "JdbcSocketConfiguration" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- /*
- * (non-Javadoc)
- *
- * @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
- * ResourceContext)
- */
@Override
public void start(ResourceContext context) {
- this.setComponentName(context.getPluginConfiguration().getSimpleValue(
- "name", null));
+ this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name", null)); //$NON-NLS-1$
this.resourceConfiguration = context.getPluginConfiguration();
super.start(context);
}
@@ -93,22 +82,15 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getRuntimeEngineDeployer(getConnection())
- .getRunState();
+ runState = ProfileServiceUtil.getRuntimeEngineDeployer(getConnection()).getRunState();
} catch (NamingException e) {
- LOG
- .error("Naming exception getting: "
- + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ LOG .debug("Naming exception getting: " + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE); //$NON-NLS-1$
return AvailabilityType.DOWN;
} catch (Exception e) {
- LOG
- .error("Exception getting: "
- + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ LOG .debug("Exception getting: " + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE); //$NON-NLS-1$
return AvailabilityType.DOWN;
}
- return (runState == RunState.RUNNING) ? AvailabilityType.UP
- : AvailabilityType.DOWN;
-
+ return (runState == RunState.RUNNING) ? AvailabilityType.UP: AvailabilityType.DOWN;
}
@Override
@@ -116,23 +98,21 @@
Configuration configuration, Map<String, Object> valueMap) {
// Parameter logic for System Operations
if (name.equals(Platform.Operations.KILL_REQUEST)) {
- valueMap.put(Operation.Value.REQUEST_ID, configuration.getSimple(
- Operation.Value.REQUEST_ID).getLongValue());
- valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
- Operation.Value.SESSION_ID).getLongValue());
+ valueMap.put(Operation.Value.REQUEST_ID, configuration.getSimple(Operation.Value.REQUEST_ID).getLongValue());
+ valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(Operation.Value.SESSION_ID).getLongValue());
} else if (name.equals(Platform.Operations.KILL_REQUEST)) {
- valueMap.put(Operation.Value.TRANSACTION_ID, configuration
- .getSimple(Operation.Value.TRANSACTION_ID).getLongValue());
+ valueMap.put(Operation.Value.TRANSACTION_ID, configuration.getSimple(Operation.Value.TRANSACTION_ID).getLongValue());
} else if (name.equals(Platform.Operations.KILL_SESSION)) {
- valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(
- Operation.Value.SESSION_ID).getLongValue());
+ valueMap.put(Operation.Value.SESSION_ID, configuration.getSimple(Operation.Value.SESSION_ID).getLongValue());
+ } else if (name.equals(Platform.Operations.DEPLOY_VDB_BY_URL)) {
+ valueMap.put(Operation.Value.VDB_URL, configuration.getSimple(Operation.Value.VDB_URL).getStringValue());
+ valueMap.put(Operation.Value.VDB_DEPLOY_NAME, configuration.getSimple(Operation.Value.VDB_DEPLOY_NAME).getStringValue());
+ valueMap.put(Operation.Value.VDB_VERSION, configuration.getSimple(Operation.Value.VDB_VERSION).getIntegerValue());
}
-
}
@Override
- public void getValues(MeasurementReport report,
- Set<MeasurementScheduleRequest> requests) throws Exception {
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) throws Exception {
DQPManagementView view = new DQPManagementView();
@@ -146,56 +126,27 @@
// Initialize any parameters to be used in the retrieval of
// metric values
- Object metricReturnObject = view.getMetric(getConnection(),
+ Object metric = view.getMetric(getConnection(),
getComponentType(), this.getComponentIdentifier(),
name, valueMap);
- try {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- report.addData(new MeasurementDataNumeric(
- request, (Double) metricReturnObject));
- } else {
- if (request
- .getName()
- .equals(
- PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
- report.addData(new MeasurementDataNumeric(
- request,
- (Double) metricReturnObject));
- }
- }
- }
- }
-
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- throw (e);
+ if (metric instanceof Double) {
+ report.addData(new MeasurementDataNumeric(request, (Double) metric));
}
+ else if (metric instanceof Integer ){
+ report.addData(new MeasurementDataNumeric(request, new Double(((Integer)metric).doubleValue())));
+ }
+ else if (metric instanceof Long){
+ report.addData(new MeasurementDataNumeric(request, new Double(((Long)metric).longValue())));
+ }
+ else {
+ LOG.error("Metric value must be a numeric value"); //$NON-NLS-1$
+ }
}
} catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
+ LOG.error("Failed to obtain measurement [" + name + "]. Cause: " + e); //$NON-NLS-1$ //$NON-NLS-2$
throw (e);
}
-
}
@Override
@@ -204,13 +155,6 @@
super.stop();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.teiid.rhq.plugin.Facet#updateResourceConfiguration(org.rhq.core.pluginapi
- * .configuration.ConfigurationUpdateReport)
- */
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -231,27 +175,23 @@
for (String serviceName : PLATFORM_SERVICES_NAMES) {
- managedComponent = managementView.getComponent(serviceName,
- componentType);
- Map<String, ManagedProperty> managedProperties = managedComponent
- .getProperties();
+ managedComponent = managementView.getComponent(serviceName, componentType);
+ Map<String, ManagedProperty> managedProperties = managedComponent.getProperties();
- ProfileServiceUtil.convertConfigurationToManagedProperties(
- managedProperties, resourceConfig, resourceContext
- .getResourceType());
+ ProfileServiceUtil.convertConfigurationToManagedProperties(managedProperties, resourceConfig, resourceContext.getResourceType());
try {
managementView.updateComponent(managedComponent);
} catch (Exception e) {
- LOG.error("Unable to update component ["
- + managedComponent.getName() + "] of type "
- + componentType + ".", e);
+ LOG.error("Unable to update component [" //$NON-NLS-1$
+ + managedComponent.getName() + "] of type " //$NON-NLS-1$
+ + componentType + ".", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
}
} catch (Exception e) {
- LOG.error("Unable to process update request", e);
+ LOG.error("Unable to process update request", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
@@ -285,20 +225,14 @@
// Get all ManagedComponents of type Teiid and subtype dqp
Set<ManagedComponent> mcSet = null;
try {
- mcSet = ProfileServiceUtil
- .getManagedComponents(
- getConnection(),
- new org.jboss.managed.api.ComponentType(
+ mcSet = ProfileServiceUtil.getManagedComponents(getConnection(),
+ new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
- LOG
- .error("NamingException getting components in Platform loadConfiguration(): "
- + e.getMessage());
+ LOG.error("NamingException getting components in Platform loadConfiguration(): " + e.getMessage()); //$NON-NLS-1$
} catch (Exception e) {
- LOG
- .error("Exception getting components in Platform loadConfiguration(): "
- + e.getMessage());
+ LOG.error("Exception getting components in Platform loadConfiguration(): " + e.getMessage()); //$NON-NLS-1$
}
for (ManagedComponent mc : mcSet) {
@@ -319,22 +253,18 @@
PropertySimple prop = new PropertySimple(mProp.getName(), value);
configuration.put(prop);
} catch (Exception e) {
- LOG
- .error("Exception setting properties in Platform loadConfiguration(): "
- + e.getMessage());
+ LOG.error("Exception setting properties in Platform loadConfiguration(): " + e.getMessage()); //$NON-NLS-1$
}
}
}
@Override
public ProfileServiceConnection getConnection() {
- return ((ApplicationServerComponent) this.resourceContext
- .getParentResourceComponent()).getConnection();
+ return ((ApplicationServerComponent) this.resourceContext.getParentResourceComponent()).getConnection();
}
@Override
public EmsConnection getEmsConnection() {
- // TODO Auto-generated method stub
return null;
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -96,7 +96,7 @@
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
+ log.debug("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
return discoveredResources;
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -63,16 +63,9 @@
String RESOURCE_NAME = "resourceName";
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
- * ResourceContext)
- */
@Override
public void start(ResourceContext context) {
- this.setComponentName(context.getPluginConfiguration().getSimpleValue(
- "name", null));
+ this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name", null));
this.resourceConfiguration=context.getPluginConfiguration();
super.start(context);
}
@@ -94,8 +87,7 @@
*
* @see MeasurementFacet#getValues(MeasurementReport, Set)
*/
- public void getValues(MeasurementReport report,
- Set<MeasurementScheduleRequest> requests) {
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
for (MeasurementScheduleRequest request : requests) {
String name = request.getName();
@@ -107,11 +99,9 @@
Number value = new Integer(1); // dummy measurement value -
// this should come from the
// managed resource
- report.addData(new MeasurementDataNumeric(request, value
- .doubleValue()));
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
} catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
+ LOG.error("Failed to obtain measurement [" + name + "]. Cause: " + e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -121,12 +111,8 @@
protected void setOperationArguments(String name,
Configuration configuration, Map argumentMap) {
//No operations for translators
-
}
- /* (non-Javadoc)
- * @see org.teiid.rhq.plugin.Facet#loadResourceConfiguration()
- */
@Override
public Configuration loadResourceConfiguration() {
@@ -144,8 +130,8 @@
LOG.error(msg, e);
}
- String translatorName = ProfileServiceUtil.getSimpleValue(
- translator, "name", String.class);
+ String translatorName = ProfileServiceUtil.getSimpleValue( translator, "name", String.class);
+ String description = ProfileServiceUtil.getSimpleValue( translator, "description", String.class);
Configuration c = resourceConfiguration;
PropertyList list = new PropertyList("translatorList");
@@ -153,12 +139,12 @@
c.put(list);
// First get translator specific properties
- ManagedProperty translatorProps = translator
- .getProperty("property");
+ ManagedProperty translatorProps = translator.getProperty("property");
getTranslatorValues(translatorProps.getValue(), propMap, list);
// Now get common properties
c.put(new PropertySimple("name", translatorName));
+ c.put(new PropertySimple("description", description));
return c;
@@ -169,8 +155,7 @@
MetaType metaType = pValue.getMetaType();
Map<String, T> unwrappedvalue = null;
if (metaType.isComposite()) {
- unwrappedvalue = (Map<String, T>) MetaValueFactory
- .getInstance().unwrap(pValue);
+ unwrappedvalue = (Map<String, T>) MetaValueFactory .getInstance().unwrap(pValue);
for (String key : unwrappedvalue.keySet()) {
map = new PropertyMap("property");
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -41,8 +41,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.plugins.jbossas5.ApplicationServerComponent;
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
+import org.teiid.core.util.ApplicationInfo;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -69,8 +69,9 @@
for (ManagedComponent translator : translators) {
String translatorKey = translator.getName();
- String translatorName = ProfileServiceUtil.getSimpleValue(
- translator, "name", String.class);
+ String translatorName = ProfileServiceUtil.getSimpleValue(translator, "name", String.class); //$NON-NLS-1$
+ String description = ProfileServiceUtil.getSimpleValue(translator, "description", String.class); //$NON-NLS-1$
+
/**
*
* A discovered resource must have a unique key, that must stay the
@@ -80,8 +81,8 @@
discoveryContext.getResourceType(), // ResourceType
translatorKey, // Resource Key
translatorName, // Resource Name
- null, // Version
- PluginConstants.ComponentType.Translator.DESCRIPTION, // Description
+ ApplicationInfo.getInstance().getReleaseNumber(), // Version
+ description, // Description
discoveryContext.getDefaultPluginConfiguration(), // Plugin config
null // Process info from a process scan
);
@@ -89,19 +90,19 @@
// Get plugin config map for models
Configuration configuration = detail.getPluginConfiguration();
- configuration.put(new PropertySimple("name", translatorName));
+ configuration.put(new PropertySimple("name", translatorName));//$NON-NLS-1$
detail.setPluginConfiguration(configuration);
// Add to return values
// First get translator specific properties
- ManagedProperty translatorProps = translator.getProperty("property");
- PropertyList list = new PropertyList("translatorList");
+ ManagedProperty translatorProps = translator.getProperty("property");//$NON-NLS-1$
+ PropertyList list = new PropertyList("translatorList");//$NON-NLS-1$
PropertyMap propMap = null;
getTranslatorValues(translatorProps.getValue(), propMap, list);
// Now get common properties
- configuration.put(new PropertySimple("name", translatorName));
- configuration.put(new PropertySimple("type",ProfileServiceUtil.getSimpleValue(translator,"type", String.class)));
+ configuration.put(new PropertySimple("name", translatorName));//$NON-NLS-1$
+ configuration.put(new PropertySimple("type",ProfileServiceUtil.getSimpleValue(translator,"type", String.class)));//$NON-NLS-1$ //$NON-NLS-2$
detail.setPluginConfiguration(configuration);
// Add to return values
@@ -121,9 +122,9 @@
unwrappedvalue = (Map<String, T>) MetaValueFactory.getInstance().unwrap(pValue);
for (String key : unwrappedvalue.keySet()) {
- map = new PropertyMap("properties");
- map.put(new PropertySimple("name", key));
- map.put(new PropertySimple("value", unwrappedvalue.get(key)));
+ map = new PropertyMap("properties");//$NON-NLS-1$
+ map.put(new PropertySimple("name", key));//$NON-NLS-1$
+ map.put(new PropertySimple("value", unwrappedvalue.get(key)));//$NON-NLS-1$
//map.put(new PropertySimple("description", "Custom property"));
list.add(map);
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -200,8 +200,13 @@
.getName()
.equals(
PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
- report.addData(new MeasurementDataTrait(
- request, (String) metricReturnObject));
+ if (((String) metricReturnObject).equals("ACTIVE")) {
+ report.addData(new MeasurementDataTrait(
+ request, "UP"));
+ }else{
+ report.addData(new MeasurementDataTrait(
+ request, "DOWN"));
+ }
} else {
if (request
.getName()
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -42,8 +42,8 @@
private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
public static boolean hasCorrectExtension(String archiveFileName, ResourceType resourceType) {
- String expectedExtension = "vdb";
- int lastPeriod = archiveFileName.lastIndexOf(".");
+ String expectedExtension = "vdb"; //$NON-NLS-1$
+ int lastPeriod = archiveFileName.lastIndexOf("."); //$NON-NLS-1$
String extension = (lastPeriod != -1) ? archiveFileName.substring(lastPeriod + 1) : null;
// Use File.equals() to compare the extensions so case-sensitivity is correct for this platform.
return (extension != null && new File(extension).equals(new File(expectedExtension)));
@@ -63,16 +63,47 @@
public static void deployArchive(DeploymentManager deploymentManager, File archiveFile, boolean deployExploded)
throws Exception {
String archiveFileName = archiveFile.getName();
- LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")...");
+ LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
URL contentURL;
try {
contentURL = archiveFile.toURI().toURL();
}
catch (MalformedURLException e) {
- throw new IllegalArgumentException("Failed to convert archive file path '" + archiveFile + "' to URL.", e);
+ throw new IllegalArgumentException("Failed to convert archive file path '" + archiveFile + "' to URL.", e); //$NON-NLS-1$ //$NON-NLS-2$
}
- DeploymentProgress progress = null;
+ deployAndStart(deploymentManager, contentURL, archiveFileName);
+ }
+
+ /**
+ * Deploys (i.e. distributes then starts) the specified archive file.
+ *
+ * @param fileName
+ * @param deploymentManager
+ * @param archiveUrl
+ * @param deployExploded
+ *
+ * @return
+ *
+ * @throws Exception if the deployment fails for any reason
+ */
+ public static void deployArchive(String fileName, DeploymentManager deploymentManager, URL contentURL, boolean deployExploded)
+ throws Exception {
+ String archiveFileName = fileName;
+ LOG.debug("Deploying '" + archiveFileName + "' (deployExploded=" + deployExploded + ")..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ deployAndStart(deploymentManager, contentURL, archiveFileName);
+ }
+
+ /**
+ * @param deploymentManager
+ * @param contentURL
+ * @param archiveFileName
+ * @throws Exception
+ */
+ private static void deployAndStart(DeploymentManager deploymentManager,
+ URL contentURL, String archiveFileName) throws Exception {
+ DeploymentProgress progress = null;
DeploymentStatus distributeStatus;
Exception distributeFailure = null;
try {
@@ -80,14 +111,14 @@
distributeStatus = run(progress);
if (distributeStatus.isFailed()) {
distributeFailure = (distributeStatus.getFailure() != null) ? distributeStatus.getFailure() :
- new Exception("Distribute failed for unknown reason.");
+ new Exception("Distribute failed for unknown reason."); //$NON-NLS-1$
}
}
catch (Exception e) {
distributeFailure = e;
}
if (distributeFailure != null) {
- throw new Exception("Failed to distribute '" + contentURL + "' to '" + archiveFileName + "' - cause: "
+ throw new Exception("Failed to distribute '" + contentURL + "' to '" + archiveFileName + "' - cause: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ThrowableUtil.getAllMessages(distributeFailure));
}
@@ -100,15 +131,15 @@
startStatus = run(progress);
if (startStatus.isFailed()) {
startFailure = (startStatus.getFailure() != null) ? startStatus.getFailure() :
- new Exception("Start failed for unknown reason.");
+ new Exception("Start failed for unknown reason."); //$NON-NLS-1$
}
}
catch (Exception e) {
startFailure = e;
}
if (startFailure != null) {
- LOG.error("Failed to start deployment " + Arrays.asList(deploymentNames)
- + " during deployment of '" + archiveFileName + "'. Backing out the deployment...", startFailure);
+ LOG.error("Failed to start deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+ + " during deployment of '" + archiveFileName + "'. Backing out the deployment...", startFailure); //$NON-NLS-1$ //$NON-NLS-2$
// If start failed, the app is invalid, so back out the deployment.
DeploymentStatus removeStatus;
Exception removeFailure = null;
@@ -117,24 +148,24 @@
removeStatus = run(progress);
if (removeStatus.isFailed()) {
removeFailure = (removeStatus.getFailure() != null) ? removeStatus.getFailure() :
- new Exception("Remove failed for unknown reason.");
+ new Exception("Remove failed for unknown reason."); //$NON-NLS-1$
}
}
catch (Exception e) {
removeFailure = e;
}
if (removeFailure != null) {
- LOG.error("Failed to remove deployment " + Arrays.asList(deploymentNames)
- + " after start failure.", removeFailure);
+ LOG.error("Failed to remove deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+ + " after start failure.", removeFailure); //$NON-NLS-1$
}
- throw new Exception("Failed to start deployment " + Arrays.asList(deploymentNames)
- + " during deployment of '" + archiveFileName + "' - cause: " +
+ throw new Exception("Failed to start deployment " + Arrays.asList(deploymentNames) //$NON-NLS-1$
+ + " during deployment of '" + archiveFileName + "' - cause: " + //$NON-NLS-1$ //$NON-NLS-2$
ThrowableUtil.getAllMessages(startFailure));
}
// If we made it this far, the deployment (distribution+start) was successful.
return;
- }
-
+ }
+
public static DeploymentStatus run(DeploymentProgress progress) {
progress.run();
return progress.getDeploymentStatus();
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -75,16 +75,15 @@
public final static String GET_TRANSACTIONS = "getTransactions"; //$NON-NLS-1$
public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
public final static String GET_BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
-
+ public final static String GET_CACHE_STATS = "getCacheStatistics"; //$NON-NLS-1$
+ public final static String DEPLOY_VDB_BY_URL = "deployVdbByUrl"; //$NON-NLS-1$
}
public static interface Metrics {
-
public final static String QUERY_COUNT = "queryCount"; //$NON-NLS-1$
public final static String SESSION_COUNT = "sessionCount"; //$NON-NLS-1$
public final static String LONG_RUNNING_QUERIES = "longRunningQueries"; //$NON-NLS-1$
- public final static String BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
-
+ public final static String BUFFER_USAGE = "userBufferSpace"; //$NON-NLS-1$
}
}
@@ -125,7 +124,6 @@
public final static String TYPE = "teiid"; //$NON-NLS-1$
public final static String SUBTYPE = "translator"; //$NON-NLS-1$
public final static String NAME = "Translator"; //$NON-NLS-1$
- public final static String DESCRIPTION = "Teiid Translator"; //$NON-NLS-1$
public static interface Operations {
@@ -227,7 +225,9 @@
public final static String TRANSACTION_ID = "transactionID"; //$NON-NLS-1$
public final static String REQUEST_ID = "requestID"; //$NON-NLS-1$
public final static String SESSION_ID = "sessionID"; //$NON-NLS-1$
-
+ public final static String VDB_URL = "vdbUrl"; //$NON-NLS-1$
+ public final static String VDB_DEPLOY_NAME = "vdbDeployName"; //$NON-NLS-1$
+ 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$
Modified: trunk/console/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/console/src/main/resources/META-INF/rhq-plugin.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -154,6 +154,19 @@
</c:list-property>
</results>
</operation>
+
+ <operation name="deployVdbByUrl" displayName="Deploy a VDB via URL"
+ description="Deploy a VDB using a URL">
+ <parameters>
+ <c:simple-property displayName="VDB URL" name="vdbUrl"
+ type="file" required="true" description="The URL of the VDB to deploy" />
+ <c:simple-property displayName="VDB Deploy File Name" name="vdbDeployName"
+ type="string" required="true" description="The deployment file name to use. Must match the VDB Name you are deploying." />
+ <c:simple-property displayName="VDB Version" name="vdbVersion"
+ type="integer" required="false" description="The version to use for the deployed VDB (leave blank for overwrite of version one)" />
+ </parameters>
+ </operation>
+
<operation name="terminateSession" displayName="Terminate Session"
description="Terminate a specified session">
@@ -256,6 +269,30 @@
displayType="detail" category="throughput" property="userBufferSpace"
description="The currently used file buffer space in MB." />
+ <metric displayName="Prepared Plan Cache Hit Ratio %" defaultOn="true"
+ displayType="detail" category="performance" property="PREPARED_PLAN_CACHE.hitRatio"
+ description="Percentage of positive cache hits" />
+
+ <metric displayName="Prepared Plan Cache Size" defaultOn="true"
+ displayType="detail" category="performance" property="PREPARED_PLAN_CACHE.totalEntries"
+ description="Current number of entries in cache" />
+
+ <metric displayName="Prepared Plan Cache # of Requests" defaultOn="true"
+ displayType="detail" category="performance" property="PREPARED_PLAN_CACHE.requestCount"
+ description="Total number of requests made against cache" />
+
+ <metric displayName="ResultSet Cache Hit Ratio %" defaultOn="true"
+ displayType="detail" category="performance" property="QUERY_SERVICE_RESULT_SET_CACHE.hitRatio"
+ description="Percentage of positive cache hits" />
+
+ <metric displayName="ResultSet Cache Size" defaultOn="true"
+ displayType="detail" category="performance" property="QUERY_SERVICE_RESULT_SET_CACHE.totalEntries"
+ description="Current number of entries in cache" />
+
+ <metric displayName="ResultSet Cache # of Requests" defaultOn="true"
+ displayType="detail" category="performance" property="QUERY_SERVICE_RESULT_SET_CACHE.requestCount"
+ description="Total number of requests made against cache" />
+
<resource-configuration>
<c:group name="teiidProperties" displayName="Runtime Engine Properties"
hiddenByDefault="false">
@@ -461,8 +498,9 @@
<c:option value="INACTIVE" name="DOWN" default="true" />
</c:property-options>
</c:simple-property>
- <c:simple-property name="connectionType" type="string"
- description="Connections to allow to this Virtual Database"
+ <c:simple-property name="connectionType" type="string"
+ description="Allowable Connections: 1) NONE - disallow new connections 2) BY VERSION - allow connections only if the version is specified or if this is the earliest 'BY VERSION' vdb and there are no vdbs marked as 'ANY'
+3) ANY - allow connections with or without a version specified. If multiple versions of same VDB are deployed, connect to one specified with ANY, or if there are multiple VDBs with ANY then connect to the latest version with ANY "
required="false">
<c:property-options>
<c:option value="NONE" name="NONE" />
@@ -567,8 +605,9 @@
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="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">
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -49,6 +49,7 @@
<xi:include href="content/vdb-deployment.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/logging.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/clustering.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/admin-console.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/adminshell.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/appendix-a.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -6,6 +6,12 @@
Teiid's Admin Console is built using the <ulink url="http://www.jboss.org/embjopr">Embedded JOPR</ulink> library and adds a additional plugin into the Embeeded JOPR program already available in the
<ulink url="http://www.jboss.org/jbossas">JBoss AS</ulink>.</para>
+ <mediaobject>
+ <imageobject>
+ <imagedata scalefit="1" fileref="../images/admin_console.png"/>
+ </imageobject>
+ </mediaobject>
+
<section>
<title>What can be monitored and/or configured?</title>
<para>Here are the steps to follow to install Teiid</para>
@@ -31,12 +37,6 @@
<para>The creation/modification of the datasource is managed by the JBossAS plugin.</para>
</note>
- <mediaobject>
- <imageobject>
- <imagedata fileref="../images/admin_console.png"/>
- </imageobject>
- </mediaobject>
-
<section>
<title>Configuration</title>
<orderedlist>
Copied: trunk/documentation/admin-guide/src/main/docbook/en-US/content/clustering.xml (from rev 2524, branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/clustering.xml)
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/clustering.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/clustering.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="clustering">
+ <title>Clustering in Teiid</title>
+ <para>Since Teiid is installed in JBoss AS, there is no separate configuration needed on the part of the user to cluster the Teiid instances.
+ To cluster JBoss AS instances use these <ulink url="http://www.jboss.org/jbossas/docs/5-x.html">instructions</ulink> then Teiid instances
+ are clustered as well. Just make sure that you installed Teiid in every JBoss AS node before starting the cluster.
+ There is one specific configuration that needs to be done for enabling the replicated (distributed) cache in Teiid.
+ To enable distributed cache rename "<jboss-as>/server/<profile>/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml" file
+ to "<jboss-as>/server/<profile>/deploy/teiid/teiid-cache-manager-jboss-beans.xml".
+ </para>
+
+ <para>
+ Typically users create clusters to improve the performance of the system through
+ <orderedlist>
+ <listitem> <para>Load Balancing: Take look at the Client developers guide on how to use load balancing between multiple nodes.</para> </listitem>
+ <listitem> <para>Fail Over: Take look at the Client developers guide on how to use fail over between multiple nodes.</para> </listitem>
+ <listitem> <para>Distributed Caching: This is automatically done for you once you configure it as specified above. </para> </listitem>
+ </orderedlist>
+ </para>
+
+ <para>If would like a clustered deployment of the VDB and data-source artifacts, i.e. deploy artifacts to a central
+ location and let the system propagate deployments every where, then look into
+ <ulink url="http://community.jboss.org/wiki/JBossFarmDeployment">JBoss Farm Deployment</ulink>. Note that this only supports hot deployments.
+ Take look at some commonly asked questions <ulink url="http://community.jboss.org/wiki/JoinTheClusterBeforeUpdatingTheFarmDirectory">here</ulink>.
+ If you need more fine grained control, you can use script based deployment, where you control the deployment of artifacts into each node, or
+ JBoss AS "deploy" folder can be configured as a <emphasis>shared</emphasis> folder among all the clustered JBoss AS nodes to achieve farming.</para>
+
+</chapter>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -47,6 +47,35 @@
</orderedlist>
</section>
<section>
+ <title>CXF Installation</title>
+ <para>The usage of CXF is expected for utilizing Salesforce and Web Services connectivity through Teiid. If you do not plan on integrating either of these features, then you may leave JBoss AS with the default "native" web services stack.</para>
+ <orderedlist>
+ <listitem>
+ <para>Download <ulink url="http://www.jboss.org/jbossws/downloads/">JBossWS-CXF 3.1.2</ulink> and unzip to a temporary location.</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, save the ant.properties.example file as ant.properties and change the values for jboss510.home, jbossws.integration.target, jboss.server.instance, jboss.bind.address accordingly:
+ <programlisting>
+...
+jboss510.home=<jboss-install>
+
+# The JBoss server under test. This can be [jboss500|jboss501|jboss510|jboss600]
+jbossws.integration.target=jboss510
+
+# The JBoss settings
+jboss.server.instance=<profile>
+jboss.bind.address=<bind address>
+</programlisting> The jboss-install location should be the root directory of your AS installation, profile (typically default) should indicate the profile selected for your Teiid installation, and the bind address should be the bind address used when launching JBoss AS (use the value localhost if you do not set the bind address when launching JBoss AS).</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, install JBossWS-CXF by running the ANT build script: <programlisting>$ant deploy-jboss510</programlisting></para>
+ </listitem>
+ <listitem>
+ <para>Optionally run tests to verify that there are no errors with the installation: <programlisting>$ant tests</programlisting></para>
+ </listitem>
+ </orderedlist>
+ </section>
+ <section>
<title>Directory Structure Explained</title>
<example>
<title>Directory Structure</title>
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -10,7 +10,8 @@
<para>Typically a user name is required, however user names may be considered optional if the
identity of the user can be discerned by the password credential alone. In
any case it is up to the configured security domain to determine whether a user can be
- authenticated.</para>
+ authenticated. If you need authentication, the administrator must configure a LoginModule to be used with Teiid.
+ See below for more information on how configure the Login module in JBoss AS.</para>
<note><para>By default, access to Teiid is NOT secure. The default login modules are only
backed by file based authentication, which has a well known user
@@ -18,6 +19,18 @@
The same is true for making connections to the Admin Console application.
We DO NOT recommend leaving the default security profile as defined when you
are exposing sensitive data.</para></note>
+ <section>
+ <title>Pass-through Authentication</title>
+ <para>If your client application (web application or Web service) resides in the same JBoss AS instance as Teiid and
+ client application uses a security-domain to handle the security concerns, then you can configure Teiid to use the
+ same security-domain and not force the user to re-authenticate for using Teiid. In this case Teiid looks for a authenticated
+ subject in the calling thread context and uses for its session and authorization purposes. To configure Teiid for this
+ pass-through authentication mechanism, you need change the Teiid's security-domain name to same name as your
+ application's security domain name in the "teiid-jboss-beans.xml" file in the SessionService section.
+ Please note that for this to work, the security-domain
+ must be a JAAS based Login Module and your client application MUST obtain Teiid connection
+ using <emphasis>Local</emphasis> Connection.</para>
+ </section>
</section>
<section>
<title>Authorization</title>
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -53,21 +53,32 @@
<section>
<title>Deploying VDB Dependencies</title>
<para>Apart from deploying the VDB, the user is also responsible for providing all the necessary
- dependent libraries, configuration for creating the data sources that are needed by the Schemas (models)
- defined in "META-INF/vdb.xml" file inside your VDB. This section shows you a sample VDB configuration needed.</para>
+ dependent libraries, configuration for creating the data sources that are needed by the models (schemas)
+ defined in "META-INF/vdb.xml" file inside your VDB. For example, if you are trying to integrate Oracle and File sources in your VDB, then you are responsible for
+ providing the JDBC driver for the Oracle source and any necessary documents and configuration that are needed by the File Translator.</para>
- <para>For example, if you are trying to integrate Oracle and File sources in your VDB, then you are responsible for
- providing the JDBC driver for the Oracle source, and any necessary documents and configuration that are needed by the File Translator.</para>
+ <para>Data source instances may be used by only one VDB, or may be shared with as many VDBs or other applications as makes since for your deployments.
+ Consider sharing connections to sources that have heavy-weight and resource constrained connections.</para>
- <para>Once the VDB and its dependencies are deployed, then client applications can connect using the JDBC API. If there are any errors in the deployment, a connection attempt will not be successful and a message will be logged. You can use the
- <link linkend="admin-console">admin-console</link> tool or check the log files for errors and correct them before proceeding.</para>
+ <para>With the exception of JDBC, each of the data sources supported by has a corresponding .rar (zip format) file in <jboss-install>/server/<profile>/deploy/teiid/connectors.
+ If not using JOPR or other tooling to create your -ds.xml files, you can consult the .rar files META-INF/ra.xml for a full description of how the source can be configured.
+ </para>
+ <para>Some -ds.xml files may contain passwords or other sensitive information.
+ See the WIKI article <ulink url="http://community.jboss.org/wiki/EncryptingDataSourcePasswords">EncryptingDataSourcePasswords</ulink> to not store passwords in plain text.</para>
+
+ <para>Once the VDB and its dependencies are deployed, then client applications can connect using the JDBC API. If there are any errors in the deployment, a connection attempt will not be successful and a message will be logged.
+ You can use the <link linkend="admin-console">admin-console</link> tool or check the log files for errors and correct them before proceeding.</para>
+
<section>
- <title>Creating An Oracle Data Source</title>
+ <title>JDBC Data Sources</title>
+ <para>The following is an example highlighting configuring an Oracle data source. The process is nearly identical regardless of the vendor.
+ Typically only the client jar and the setting in the -ds.xml file change.</para>
+ <para>There are templates for all the data sources in the "<jboss-install>/docs/examples/jca" directory.</para>
<orderedlist>
<listitem> <para>Copy the Oracle JDBC JAR file into "<jboss-install>/server/<profile>/lib" directory </para> </listitem>
<listitem> <para>Create a "data source" to the Oracle instance in the JBoss container. This typically
- done by creating "xxx-ds.xml" file and copying this file to the "<jboss-install>/server/%lt;profile>/deploy"
+ done by creating "xxx-ds.xml" file and copying this file to the "<jboss-install>/server/<profile>/deploy"
directory. The following shows a "-ds.xml" file template for Oracle. You can also use admin-console to create this data source. </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<datasources>
@@ -99,26 +110,206 @@
</datasources>]]></programlisting>
</listitem>
</orderedlist>
- <para>There are templates for all the data sources in the "<jboss-install>/docs/examples/jca" directory.</para>
</section>
<section>
- <title>Creating A File Data Source</title>
- <para>File data source uses Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
- "<jboss-install>/server/%lt;profile>/deploy" directory.</para>
+ <title>File Data Sources</title>
+ <para>File data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
<example>
<title>Template for creating a File based data source</title>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<no-tx-connection-factory>
<jndi-name>text-source</jndi-name>
- <rar-name>connector-file-{version}.rar</rar-name>
+ <rar-name>teiid-connector-file.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
- <config-property name="ParentDirectory" type="java.lang.String">path-to-the-directory-of-data-file</config-property>
- <max-pool-size>1</max-pool-size>
- </no-tx-connection-factory>
+ <config-property name="ParentDirectory">path-to-the-directory-of-data-file</config-property>
+ </no-tx-connection-factory>
</connection-factories>]]></programlisting></example>
</section>
+
+ <section>
+ <title>Web Service Data Sources</title>
+ <para>Web service data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating a web service based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ <section>
+ <title>CXF Configuration</title>
+ <para>Each web service data source may choose a particular CXF config file and port configuration.
+ The <code>ConfigFile</code> config property specifies the Spring XML configuration
+ file for the CXF Bus and port configuration to be used by connections.
+ If no config file is specified then the system default configuration will be used.</para>
+
+ <para>Only 1 port configuration can be used by this data source. You may explicitly set the local name of the port QName to use via the
+ <code>ConfigName</code> property. The namespace URI for the QName in your config file should be http://teiid.org.
+ See the sections on WS-Security, Logging, etc. for examples of using the CXF configuration file.</para>
+
+ <para>See the <ulink url="http://cxf.apache.org/docs/">CXF documentation</ulink> for all possible configuration options.</para>
+ <note><para>The CXF configuration is currently only applicable to non-binary web service calls.</para></note>
+ </section>
+ <section>
+ <title>WS-Security</title>
+ <para>To enable the use of WS-Security, the <code>SecurityType</code> should be set to WSSecurity.
+ At this time Teiid does not expect a WSDL to describe the service being used.
+ Thus a Spring XML configuration file is not only required, it must instead contain all of the relevant policy configuration.
+ And just as with the general configuration, each data source is limited to specifing only a single port configration to use.</para>
+ <example>
+ <title>Example WS-Security enabled data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ <config-property name="ConfigFile">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="ConfigName">port_x</config-property>
+ <config-property name="SecurityType">WSSecurity</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting>
+<para>Corresponding xxx-jbossws-cxf.xml file that adds a timestamp to the SOAP header</para>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="{http://teiid.org}port_x"
+ createdFromAPI="true">
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="Timestamp_Request"/>
+ </jaxws:outInterceptors>
+ </jaxws:client>
+
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="Timestamp_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp"/>
+ <map>
+ </constructor-arg>
+ </bean>
+
+</beans>]]></programlisting>
+ <para>Note that the client port configuration is matched to the data source instance by the QName {http://teiid.org}port_x.
+ The configuration may contain other port confiruations with different local names.</para>
+</example>
+ <para>For more information on configuring CXF interceptors,
+ please consult the <ulink url="https://cwiki.apache.org/CXF20DOC/ws-security.html">CXF documentation</ulink> or
+ the <ulink url="http://community.jboss.org/wiki/JBossWS-StackCXFUserGuide#WSSecurity">JBossWS-CXF documentation</ulink>.</para>
+ </section>
+ <section>
+ <title>Logging</title>
+ <para>The CXF config property may also be used to control the logging of requests and responses for specific or all ports. Logging, when enabled, will be performed at an INFO level to the org.apache.cxf.interceptor context.</para>
+ <example>
+ <title>Example logging data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ <config-property name="ConfigFile">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="ConfigName">port_y</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting>
+<para>Corresponding xxx-jbossws-cxf.xml</para>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="{http://teiid.org}port_y"
+ createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ </jaxws:client>
+
+</beans>]]></programlisting>
+</example>
+ </section>
+ <section>
+ <title>Transport Settings</title>
+ <para>The CXF config property may also be used to control low level aspects of the HTTP transport. See the <ulink url="http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html">CXF documentation</ulink> for all possible options.</para>
+ <example>
+ <title>Example Disabling Hostname Verification</title>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <http-conf:conduit name="{http://teiid.org}port_z.http-conduit">
+ <!-- WARNING ! disableCNcheck=true should NOT be used in production -->
+ <http-conf:tlsClientParameters disableCNcheck="true" />
+
+ </http-conf:conduit>
+</beans>
+]]></programlisting>
+</example>
+ </section>
+ </section>
+
+ <section>
+ <title>Salesforce Data Sources</title>
+ <para>Salesforce data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating a Salesforce based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>sf-source</jndi-name>
+ <rar-name>teiid-connector-salesforce.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="URL">https://test.salesforce.com/services/Soap/u/10.0</config-property>
+ <config-property name="username">username</config-property>
+ <config-property name="password">password</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
+ <section>
+ <title>LDAP Data Sources</title>
+ <para>LDAP data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating an LDAP based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>ldap-source</jndi-name>
+ <rar-name>teiid-connector-ldap.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="LdapAdminUserDN">cn=x,ou=y,dc=z</config-property>
+ <config-property name="LdapAdminUserPassword">password</config-property>
+ <config-property name="LdapUrl">ldap://ldapServer:389</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
</section>
<section id="vdb-versioning">
Deleted: trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/cachehint.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,88 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="cache-hint">
- <title>Cache Hint</title>
- <para>A cache hint can be used to:</para>
- <itemizedlist>
- <listitem><para>Indicate that a user query is eligible for result set caching.
- </para></listitem>
- <listitem><para>Set the result set query cache entry memory preference or time to live.
- </para></listitem>
- <listitem><para>Set the materialized view memory preference, time to live, or updatablity.
- </para></listitem>
- </itemizedlist>
- <para><synopsis>/*+ cache[([pref_mem] [ttl:n] [updatable])] */</synopsis>
- <itemizedlist>
- <listitem><para><emphasis>pref_mem</emphasis> - if present indicates that the cached results should prefer to remain in memory. They are not however required to be memory only.
- </para></listitem>
- <listitem><para><emphasis>ttl:n</emphasis> - if present n indicates the time to live value in milliseconds.
- </para></listitem>
- <listitem><para><emphasis>updatable</emphasis> - if present indicates that the cached results can be updated.
- </para></listitem>
- </itemizedlist>
- </para>
- <section>
- <title>ResultSet Cache Query</title>
- <para>The most basic form of the cache hint, <code>/*+ cache */</code>, is sufficient to inform the engine that the results of the non-update command should be cached.</para>
- <example>
- <title>PreparedStatement ResultSet Caching</title>
- <programlisting>...
-PreparedStatement ps = connection.prepareStatement("/*+ cache */ select col from t where col2 = ?");
-ps.setInt(1, 5);
-ps.execute();
-...</programlisting>
- <para>While no options are specified with the cache hint, it still informs the engine to use ResultSet caching.</para>
- </example>
- <para>The pref_mem and ttl options may also be used for ResultSet cache queries, however updatable only has an effect on materialized view tables.</para>
- <example>
- <title>Advanced ResultSet Caching</title>
- <programlisting>/*+ cache(pref_mem ttl:60000 */ select col from t</programlisting>
- <para>In this example the memory preference has been enabled and the time to live is set to 60000 milliseconds or 1 minute.
- The ttl for an entry is actually treated as it's maximum age and the entry may be purged sooner if the maximum number of cache entries has been reached.</para>
- </example>
- <para>See the <link linkend="resultset">ResultSet Caching Chapter</link> for more.</para>
- </section>
- <section>
- <title>Materialized Views</title>
- <para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materializated table.
- The hint is not used for materialization targeted at an external source. See the <link linkend="resultset">Materialized View Chapter</link> for more on materialized views.</para>
- <para>The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
- <section>
- <title>TTL Snapshot Refresh</title>
- <para>When the ttl is specified in the cache hint, a full refresh of the materialized view will be triggered automatically after the specified time interval.
- The refresh is equivalent to <code>CALL SYS.refreshMatView('view name', false)</code>, but performed asynchronously so that user queries do not block on the load.
- </para>
- <section>
- <title>Limitations</title>
- <itemizedlist>
- <listitem><para>The automatic ttl refresh is not intended for complex loading scenarios, as nested materialized views will be used by the refresh query.
- </para></listitem>
- <listitem><para>The automatic ttl refresh is performed lazily, that is it is only trigger by using the table after the ttl has expired.
- For infrequently used tables with long load times, this means that data may be used well past the intended ttl.
- </para></listitem>
- </itemizedlist>
- </section>
- </section>
- <section>
- <title>Updatable</title>
- <para>When the updatable option is specified, the materialized view may be targeted by the system function <code>refreshMatViewRow</code>.
- The refreshMatViewRow function updates a single row of an internal materialized with the supplied key value.
- The refresh query does use nested caches, so this refresh method should be used with caution.
- </para>
- <para>When the updatable option is not specified, accessing the materialized view table is more efficient because modifications do not need to be considered.
- Therefore, only specify the updatable option if row based incremental updates are needed. Even when performing row updates, full snapshot refreshes may be needed to ensure consistency.</para>
- </section>
- </section>
- <section>
- <title>Limitations</title>
- <itemizedlist>
- <listitem><para>The form of the query hint must be matched exactly for the hint to have affect.
- For a user query if the hint is not specified correctly, e.g. /*+ cach(pref_mem) */, it will not be used by the engine nor will
- there be an informational log. As a workaround, the query plan may be checked though (see the Client Developers Guide) to see if the user command
- in the plan has retained the proper hint.
- </para></listitem>
- </itemizedlist>
- </section>
-</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -60,7 +60,7 @@
<para>More control of the cache hint.</para>
</listitem>
<listitem>
- <para>The ability to use option nocache.</para>
+ <para>The ability to use <link linkend="nocache">OPTION NOCACHE</link>.</para>
</listitem>
<listitem>
<para>Usage of a materialized view lookup as an uncorrelated subquery is no different than the use of the lookup function.</para>
Copied: trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml (from rev 2524, branches/7.1.x/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml)
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml (rev 0)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/hint-option.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,60 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="cache-hint-options">
+ <title>Hints and Options</title>
+ <section id="cache-hint">
+ <title>Cache Hint</title>
+ <para>A query cache hint can be used to:</para>
+ <itemizedlist>
+ <listitem><para>Indicate that a user query is eligible for result set caching and set the cache entry memory preference or time to live.
+ </para></listitem>
+ <listitem><para>Set the materialized view memory preference, time to live, or updatablity.
+ </para></listitem>
+ <listitem><para>Indicate that a virtual procedure should be cachable and set the cache entry memory preference or time to live.
+ </para></listitem>
+ </itemizedlist>
+ <para><synopsis>/*+ cache[([pref_mem] [ttl:n] [updatable])] */ sql ...</synopsis>
+ <itemizedlist>
+ <listitem><para>The cache hint should appear at the beginning of the SQL. It will not have any affect on INSERT/UPDATE/DELETE statements or virtual update procedure definitions.</para></listitem>
+ <listitem><para><emphasis>pref_mem</emphasis> - if present indicates that the cached results should prefer to remain in memory. They are not however required to be memory only.
+ </para></listitem>
+ <listitem><para><emphasis>ttl:n</emphasis> - if present n indicates the time to live value in milliseconds.
+ </para></listitem>
+ <listitem><para><emphasis>updatable</emphasis> - if present indicates that the cached results can be updated. This is currently only applicable to materialized views.
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ <section>
+ <title>Limitations</title>
+ <itemizedlist>
+ <listitem><para>The form of the query hint must be matched exactly for the hint to have affect.
+ For a user query if the hint is not specified correctly, e.g. <code>/*+ cach(pref_mem) */</code>, it will not be used by the engine nor will
+ there be an informational log. As a workaround, the query plan may be checked though (see the Client Developers Guide) to see if the user command
+ in the plan has retained the proper hint.
+ </para></listitem>
+ </itemizedlist>
+ </section>
+ </section>
+ <section id="nocache">
+ <title>OPTION NOCACHE</title>
+ <para>Individual queries may override the use of cached results by
+ specifying <code>OPTION NOCACHE</code> on the query. 0 or more fully qualified view or procedure names may be specified to exclude using their cached results.
+ If no names are specified, cached results will not be used transitively.
+ </para>
+ <example>
+ <title>Full NOCACHE</title>
+ <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</programlisting>
+ <para>No cached results will be used at all.</para>
+ </example>
+ <example>
+ <title>Specific NOCACHE</title>
+ <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3</programlisting>
+ <para>Only the vg1 and vg3 caches will be skipped, vg2 or any cached results nested under vg1 and vg3 will be used.</para>
+ </example>
+ <para><code>OPTION NOCACHE</code> may be specified in procedure or view definitions. In that way, transformations can
+ specify to always use real-time data obtained directly from sources.
+ </para>
+ </section>
+</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -27,35 +27,14 @@
</listitem>
<listitem>
<para>User ability to override use of materialized view cache for
- specific queries through OPTION NO CACHE</para>
+ specific queries through <code>OPTION NOCACHE</code></para>
</listitem>
</itemizedlist>
</section>
<section>
<title>User Interaction</title>
- <para>When client applications issue queries against a Relational
- table or view that has been defined as a materialized view, the
- Teiid query engine automatically routes that query to obtain the
- results from the cache database.</para>
- <para>Individual queries may override the use of materialized views by
- specifying OPTION NOCACHE on the query. This parameter may specify
- one or more virtual groups to override (separated by commas, spaces
- optional). If no virtual groups are specified, materialized views tables will not be used transitively.
- </para>
- <example>
- <title>Full NOCACHE</title>
- <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</programlisting>
- </example>
- <example>
- <title>Specific NOCACHE</title>
- <programlisting>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3</programlisting>
- <para>Only the vg1 and vg3 caches will be skipped vg2 or any materialized views nested under vg1 and vg3 will be used.</para>
- </example>
- <para>Option NOCACHE may be specified in virtual
- group transformation queries. In that way, transformations can
- specify to always use real-time data obtained directly from a source.
- The use of caching and non-caching can be mixed in transformation
- definitions, just as with user queries.</para>
+ <para>Similar to cached procedures, materialized view tables are used automatically when a query accesses the corresponding view.
+ Usage of the cached results may be bypassed with an <code>OPTION NOCACHE</code> clause. See the <link linkend="nocache">OPTION NOCACHE</link> section for more on its usage.</para>
</section>
<section>
<title>Materialized View Definition</title>
@@ -67,16 +46,27 @@
<note><para>It is important to ensure that all key/index information is present as these will be used by the materialization process to enhance the performance of the materialized table.</para></note>
<para>The target materialized table may also be set in the properties. If the value is left blank, the default, then internal materialization will be used.
Otherwise for external materialization, the value should reference the fully qualified name of a table (or possibly view) with the same columns as the materialized view.
- For most basic scenarios the simplicity of internal materialization makes it the more appealing option. Other considerations for chosing between internal and external materialization are:
+ For most basic scenarios the simplicity of internal materialization makes it the more appealing option.
<itemizedlist>
- <listitem><para>Does the cached data need to be fully durable? If yes, then external materialization should be used.
+ <title>Reasons to use external materialization</title>
+ <listitem><para>The cached data needs to be fully durable.
Internal materialization should not survive a cluster restart.</para>
</listitem>
- <listitem><para>Is full control needed of loading and refresh? If yes, then external materialzation should be used.
+ <listitem><para>Full control is needed of loading and refresh.
Internal materialization does offer several system supported methods for refreshing, but does not give full access to the materialized table.</para>
</listitem>
+ <listitem><para>Control is needed over the materialized table definition.
+ Internal materialization does support <link linkend="internal-index">secondary indexes</link>, but they cannot be directly controlled.
+ Constraints or other database features cannot be added to internal materialization tables.</para>
+ </listitem>
+ <listitem><para>The data volume is large. Internal materialization (and temp tables in general) have memory overhead for each page.
+ A rough guideline is that no more than 100 million rows should in all materializated tables across all VDBs for every 1 gigabyte of heap.</para>
+ </listitem>
</itemizedlist>
</para>
+ <note><para>Materialized view tables are always scoped to the VDB. If a materialized view definition directly or transitively contains a non-deterministic
+ function call, such as random or hasRole, the resulting table will contain only the initially evaluated values. In most instances you should consider
+ nesting a materialized view without the deterministic results that is joined with relevant non-deterministic values in a parent view.</para></note>
</section>
<section>
<title>External Materialization</title>
@@ -101,7 +91,7 @@
<listitem>
<para>Determine a load and refresh strategy. With the schema created the most simplistic approach is to just load the data.
The load can even be done through Teiid with <code>insert into target_table select * from matview option nocache</code>.
- That however may be too simplistic because you index creation may be more performant if deferred until after the table has been created.
+ That however may be too simplistic because your index creation may be more performant if deferred until after the table has been created.
Also full snapshot refreshes are best done to a staging table then swapping it for the existing physical table to ensure that the refresh
does not impact user queries and to ensure that the table is valid prior to use.</para>
</listitem>
@@ -112,6 +102,8 @@
<para>Internal materialization creates Teiid temporary tables to hold the materialized table. While these tables are not fully durable, they perform
well in most circumstances and the data is present at each Teiid instance which removes the single point of failure and network overhead of an external database.
Internal materialization also provides more built-in facilities for refreshing and monitoring.</para>
+ <para>The cache hint, when used in the context of an internal materialized view transformation query, provides the ability to fine tune the materializated table.
+ The pref_mem option also applies to internal materialized views. Internal table index pages already have a memory preference, so the perf_mem option indicates that the data pages should prefer memory as well.</para>
<section>
<title>Loading And Refreshing</title>
<para>An internal materialized view table is initially in an invalid state (there is no data). The first user query will trigger an implicit loading of the data.
@@ -128,33 +120,63 @@
subsequent refreshes performed with <code>refreshMatView</code> will use dependent materialized view tables if they exist. Only one load may occur at a time. If a load is already in progress when
the <code>SYS.refreshMatView</code> procedure is called, it will return -1 immediately rather than preempting the current load.
</para>
- <para>The <link linkend="cache-hint">cache hint</link> may be used to automatically trigger a full snapshot refresh after a specified time to live.
- <example>
- <title>Auto-refresh Transformation Query</title>
- <programlisting>/*+ cache(ttl:3600000) */ select t.col, t1.col from t, t1 where t.id = t1.id</programlisting>
- </example>
- </para>
- <para>In advanced use-cases the <link linkend="cache-hint">cache hint</link> may also be used to mark an internal materialized view as updatable.
- An updatable internal materialized view may use the <code>SYS.refreshMatViewRow</code> procedure to update a single row in the materialized table.
- To be updatable the materialized view must have a single column primary key. Composite keys are not yet supported by <code>SYS.refreshMatViewRow</code>.
- <example>
- <title>Updatable Scenario</title>
- <para>Transofrmation Query: <programlisting>/*+ cache(updatable) */ select t.col, t1.col from t, t1 where t.id = t1.id</programlisting></para>
- <para>Update: <programlisting>CALL SYS.updateMatViewRow(viewname=>'schema.matview', key=>5)</programlisting></para>
- <para>Given that the schema.matview defines interger column col as it's primary key, the update will check the live source(s) for the row values.
- If it exists, the materialized view table row will be updated. If it does not exist the correpsonding row will be deleted.</para>
- </example>
- The update query will not use dependent materialized view tables, so care should be taken to ensure that getting a single
- row from this transformation query performs well. This may require the use of depedent join hints.
- When the updatable option is not specified, accessing the materialized view table is more efficient because modifications do not need to be considered.
- Therefore, only specify the updatable option if row based incremental updates are needed. Even when performing row updates, full snapshot refreshes may be needed to ensure consistency.
- </para>
+ <section>
+ <title>TTL Snapshot Refresh</title>
+ <para>The <link linkend="cache-hint">cache hint</link> may be used to automatically trigger a full snapshot refresh after a specified time to live.
+ The refresh is equivalent to <code>CALL SYS.refreshMatView('view name', false)</code>, but performed asynchronously so that user queries do not block on the load.</para>
+ <example>
+ <title>Auto-refresh Transformation Query</title>
+ <programlisting>/*+ cache(ttl:3600000) */ select t.col, t1.col from t, t1 where t.id = t1.id</programlisting>
+ <para>The resulting materialized view will be reloaded every hour (3600000 milliseconds).</para>
+ </example>
+ <section>
+ <title>Limitations</title>
+ <itemizedlist>
+ <listitem><para>The automatic ttl refresh is not intended for complex loading scenarios, as nested materialized views will be used by the refresh query.
+ </para></listitem>
+ <listitem><para>The automatic ttl refresh is performed lazily, that is it is only trigger by using the table after the ttl has expired.
+ For infrequently used tables with long load times, this means that data may be used well past the intended ttl.
+ </para></listitem>
+ </itemizedlist>
+ </section>
+ </section>
+ <section>
+ <title>Updatable</title>
+ <para>In advanced use-cases the <link linkend="cache-hint">cache hint</link> may also be used to mark an internal materialized view as updatable.
+ An updatable internal materialized view may use the <code>SYS.refreshMatViewRow</code> procedure to update a single row in the materialized table.
+ If the source row exists, the materialized view table row will be updated. If the source row does not exist, the correpsonding materialized row will be deleted.
+ To be updatable the materialized view must have a single column primary key. Composite keys are not yet supported by <code>SYS.refreshMatViewRow</code>.
+ <example>
+ <title>Updatable Transformation Query</title>
+ <para>Transofrmation Query: <programlisting>/*+ cache(updatable) */ select t.col, t1.col from t, t1 where t.id = t1.id</programlisting></para>
+ <para>Update SQL: <programlisting>CALL SYS.updateMatViewRow(viewname=>'schema.matview', key=>5)</programlisting></para>
+ <para>Given that the schema.matview defines an interger column col as it's primary key, the update will check the live source(s) for the row values.</para>
+ </example>
+ The update query will not use dependent materialized view tables, so care should be taken to ensure that getting a single
+ row from this transformation query performs well. See the Reference Guide for information on controlling dependent joins, which may be applicable to increasing the performance of retrieving a single row.
+ The refresh query does use nested caches, so this refresh method should be used with caution.
+ </para>
+ <para>
+ When the updatable option is not specified, accessing the materialized view table is more efficient because modifications do not need to be considered.
+ Therefore, only specify the updatable option if row based incremental updates are needed. Even when performing row updates, full snapshot refreshes may be needed to ensure consistency.
+ </para>
+ </section>
</section>
- <section>
- <title>Limitations</title>
+ <section id="internal-index">
+ <title>Secondary Indexes</title>
+ <para>Internal materialized view tables will automatically create non-unique indexes for each unique constraint and index defined on the materialized view.
+ These indexes are created as non-unique even for unique constraints since the materialized table is not intended as an enforcement point for data integrity
+ and when updatable the table may not be consistent with underlying values and thus unable to satisfy constraints. The primary key (if it exists) of the view will automatically be part of the covered columns for the index.</para>
+ <para>The secondary indexes are always created as trees - bitmap or hash indexes are not supported. Teiid's metadata for indexes is currently limited.
+ We are not currently able to capture additional information, such as specifying the evluated expressions, sort direction, additional columns to cover, etc. You may workaround some of these limitations though.
<itemizedlist>
- <listitem><para>Secondary index information is currently not used. An index is only created for the primary key.</para></listitem>
+ <listitem><para>If a function based index is needed, consider adding another column to the view that projects the funciton expression, then place an index on that new column.
+ Queries to the view will need to be modified as appropiate though to make use of the new column/index.</para></listitem>
+ <listitem><para>If additional covered columns are needed, they may simply be added to the index columns. This however is only applicable to comparable types.
+ Adding additional columns will increase the amount of space used by the index, but may allow
+ its usage to result in higher performance when only the covered columns are used and the main table is not consulted.</para></listitem>
</itemizedlist>
+ </para>
</section>
</section>
-</chapter>
\ No newline at end of file
+</chapter>
Copied: trunk/documentation/caching-guide/src/main/docbook/en-US/content/results.xml (from rev 2524, branches/7.1.x/documentation/caching-guide/src/main/docbook/en-US/content/results.xml)
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/results.xml (rev 0)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/results.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,138 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="results">
+ <title>Results Caching</title>
+ <para>Teiid provides the capability to cache the results of
+ specific user queries and virtual procedure calls. This caching technique
+ can yield significant performance gains if users of the system submit
+ the same queries or execute the same procedures often.</para>
+ <section>
+ <title>Support Summary</title>
+ <itemizedlist>
+ <listitem>
+ <para>Caching of user query results including XML document model results.</para>
+ </listitem>
+ <listitem>
+ <para>Caching of virtual procedure results.</para>
+ </listitem>
+ <listitem>
+ <para>Scoping of results is automatically determined to be VDB/user (replicated) or session level.</para>
+ </listitem>
+ <listitem>
+ <para>Configurable number of cache entries and time to live.</para>
+ </listitem>
+ <listitem>
+ <para>Administrative clearing.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section>
+ <title>User Interaction</title>
+ <section>
+ <title>User Query Cache</title>
+ <para>User query result set caching will cache result sets based on an exact match
+ of the incoming SQL string and PreparedStatement parameter values if present. Caching only applies to SELECT, set query, and stored procedure execution
+ statements; it does not apply to SELECT INTO statements, or INSERT,
+ UPDATE, or DELETE statements.</para>
+ <para>End users or client applications explicitly state whether to use
+ result set caching. This can be done by setting the
+ JDBC ResultSetCacheMode execution property to true (default false) or by adding a <link linkend="cache-hint">cache hint</link> to the query.
+ Note that if either of these mechanisms are used, Teiid must also have result set caching enabled (the default is enabled).</para>
+ <para>The most basic form of the cache hint, <code>/*+ cache */</code>, is sufficient to inform the engine that the results of the non-update command should be cached.</para>
+ <example>
+ <title>PreparedStatement ResultSet Caching</title>
+ <programlisting>...
+PreparedStatement ps = connection.prepareStatement("/*+ cache */ select col from t where col2 = ?");
+ps.setInt(1, 5);
+ps.execute();
+...</programlisting>
+ <para>The results will be cached with the default ttl and use the SQL string and the parameter value as part of the cache key.</para>
+ </example>
+ <para>The pref_mem and ttl options of the cache hint may also be used for result set cache queries.
+ If a cache hint is not specified, then the default time to live of the result set caching configuration will be used.
+ </para>
+ <example>
+ <title>Advanced ResultSet Caching</title>
+ <programlisting>/*+ cache(pref_mem ttl:60000 */ select col from t</programlisting>
+ <para>In this example the memory preference has been enabled and the time to live is set to 60000 milliseconds or 1 minute.
+ The ttl for an entry is actually treated as it's maximum age and the entry may be purged sooner if the maximum number of cache entries has been reached.</para>
+ </example>
+ <note><para>Each query is re-checked for authorization using the current user’s permissions,
+ regardless of whether or not the results have been cached.</para></note>
+ </section>
+ <section>
+ <title>Procedure Result Cache</title>
+ <para>Similar to materialized views, cached virtual procedure results are used automatically when a matching set of parameter values is detected for the same procedure execution.
+ Usage of the cached results may be bypassed with an <code>OPTION NOCACHE</code> clause. See the <link linkend="nocache">OPTION NOCACHE</link> section for more on its usage.</para>
+ </section>
+ </section>
+ <section>
+ <title>Cached Virtual Procedure Definition</title>
+ <para>To indicate that a virtual procedure (only definable by Teiid Designer) should be cached, it's definition should include a <link linkend="cache-hint">cache hint</link>.
+ <example>
+ <title>Procedure Caching</title>
+ <programlisting>/*+ cache */ CREATE VIRTUAL PROCEDURE
+BEGIN
+ ...
+END</programlisting>
+ <para>Results will be cached with the default ttl.</para>
+ </example>
+ The pref_mem and ttl options of the cache hint may also be used for procedure caching.
+ </para>
+ <para>Procedure results cache keys include the input parameter values.
+ To prevent one procedure from filling the cache, at most 256 cache keys may be created per procedure per VDB.</para>
+ <para>A cached procedure will always produce all of its results prior to allowing those results to be consumed and placed in the cache.
+ This differs from normal procedure execution which in some situations allows the returned results to be consumed in a streaming manner.</para>
+ </section>
+ <section>
+ <title>Cache Configuration</title>
+ <para>By default result set caching is enabled with 1024 maximum entries with a maximum entry age of 2 hours.
+ There are actually 2 caches configured with these settings. One cache holds results that are specific to sessions and is local to each Teiid instance.
+ The other cache holds VDB scoped results and can be replicated.
+ See the &jboss-beans; config file or the Console's "Runtime Engine Properties" for tuning the configuration.
+ The user may also override the default maximum entry age via the <link linkend="cache-hint">cache hint</link>.
+ </para>
+ <para>Result set caching is not limited to memory. There is no explicit limit on the size of the results that can be cached.
+ Cached results are primarily stored in the BufferManager and are subject to it's configuration - including the restriction of maximum buffer space.
+ </para>
+ <note><para>While the result data is not held in memory, cache keys - including parameter values - may be held in memory.
+ Thus the cache should not be given an unlimited maximum size.</para></note>
+ </section>
+ <section>
+ <title>Cache Administration</title>
+ <para>The result set cache can be cleared through the AdminAPI using the <code>clearCache</code> method.
+ The expected cache key is "QUERY_SERVICE_RESULT_SET_CACHE".</para>
+ <example>
+ <title>Clearing the ResultSet Cache in AdminShell</title>
+ <programlisting>connectAsAdmin()
+clearCache("QUERY_SERVICE_RESULT_SET_CACHE")
+...</programlisting>
+ </example>
+ <para>See the Admin Guide for more on using the AdminAPI and AdminShell.</para>
+ </section>
+ <section>
+ <title>Limitations</title>
+ <itemizedlist>
+ <listitem>
+ <para>Non-XML document model results, BLOBs, CLOBs, and OBJECT typed values cannot be cached.</para>
+ </listitem>
+ <listitem>
+ <para>XML, BLOB, CLOB, and OBJECT type cannot be used as part of the cache key for prepared statement of procedure cache keys.</para>
+ </listitem>
+ <listitem>
+ <para>The exact SQL string, including the cache hint if present, must match the cached entry for the results to be reused.
+ This allows cache usage to skip parsing and resolving for faster responses.</para>
+ </listitem>
+ <listitem>
+ <para>Result set caching is not transactional. Transactions depend on (and
+ enforce) consistency of data, and cached data is not guaranteed
+ to be consistent with the data store’s data.</para>
+ </listitem>
+ <listitem>
+ <para>Clearing the results cache clears all cache entries for all VDBs.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,93 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="resultset">
- <title>Result Set Caching</title>
- <para>Teiid provides the capability to cache the results of
- specific user queries. When the
- exact same user query is submitted to Teiid, the
- cached results will be returned. This caching technique
- can yield significant performance gains if users of the system submit
- the same queries often.</para>
- <para>Result set caching will cache result sets based on an exact match
- of the incoming SQL string and PreparedStatement parameter values if present. Caching only applies to SELECT, set query, and stored procedure execution
- statements; it does not apply to SELECT INTO statements, or INSERT,
- UPDATE, or DELETE statements.</para>
- <section>
- <title>Support Summary</title>
- <itemizedlist>
- <listitem>
- <para>Caching of user query results.</para>
- </listitem>
- <listitem>
- <para>Scoping of results is automatically determined to be either VDB (replicated) or session level.</para>
- </listitem>
- <listitem>
- <para>Caching of XML document model results.</para>
- </listitem>
- <listitem>
- <para>Configurable number of cache entries and time to live.</para>
- </listitem>
- <listitem>
- <para>Administrative clearing.</para>
- </listitem>
- </itemizedlist>
- </section>
- <section>
- <title>User Interaction</title>
- <para>End users or client applications explicitly state whether to use
- result set caching. This can be done by setting the
- JDBC ResultSetCacheMode execution property to true (default false) or by adding a <link linkend="cache-hint">cache hint</link> to the query.
- Note that if either of these mechanisms are used, Teiid must also have result set caching enabled (the default is enabled).</para>
- <para>
- To control the preference of individual results to remain in memory or the time to live see the <link linkend="cache-hint">cache hint</link>.
- If a cache hint is not specified, then the default time to live of the result set caching configuration will be used.
- </para>
- <note><para>Each query is re-checked for authorization using the current user’s permissions,
- regardless of whether or not the results have been cached.</para></note>
- </section>
- <section>
- <title>Cache Configuration</title>
- <para>By default result set caching is enabled with 1024 maximum entries with a maximum entry age of 2 hours.
- There are actually 2 caches configured with these settings. One cache holds results that are specific to sessions and is local to each Teiid instance.
- The other cache holds VDB scoped results and can be replicated.
- See the &jboss-beans; config file or the Console's "Runtime Engine Properties" for tuning the configuration.
- The user may also override the default maximum entry age via the <link linkend="cache-hint">cache hint</link>.</para>
- <para>Result set caching is not limited to memory. There is no explicit limit on the size of the results that can be cached.
- Cached results are primarily stored in the BufferManager and are subject to it's configuration - including the restriction of maximum buffer space.
- </para>
- </section>
- <section>
- <title>Cache Administration</title>
- <para>The result set cache can be cleared through the AdminAPI using the <code>clearCache</code> method.
- The expected cache key is "QUERY_SERVICE_RESULT_SET_CACHE".</para>
- <example>
- <title>Clearing the ResultSet Cache in AdminShell</title>
- <programlisting>connectAsAdmin()
-clearCache("QUERY_SERVICE_RESULT_SET_CACHE")
-...</programlisting>
- </example>
- <para>See the Admin Guide for more on using the AdminAPI and AdminShell.</para>
- </section>
- <section>
- <title>Limitations</title>
- <itemizedlist>
- <listitem>
- <para>Non-XML document model results, BLOBs, and CLOBs cannot be cached.</para>
- </listitem>
- <listitem>
- <para>The exact SQL string, including the cache hint if present, must match the cached entry for the results to be reused.
- This allows cache usage to skip parsing and resolving for faster responses.</para>
- </listitem>
- <listitem>
- <para>Result set caching is not transactional. Transactions depend on (and
- enforce) consistency of data, and cached data is not guaranteed
- to be consistent with the data store’s data.</para>
- </listitem>
- <listitem>
- <para>Clearing the result set cache clears all cache entries for all VDBs.</para>
- </listitem>
- </itemizedlist>
- </section>
-</chapter>
\ No newline at end of file
Modified: trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/caching-guide/src/main/docbook/en-US/main.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -47,8 +47,8 @@
</bookinfo>
<toc />
<xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/results.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/cachehint.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/hint-option.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
\ No newline at end of file
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -278,15 +278,15 @@
</entry>
<entry>Server where the Teiid runtime installed</entry>
</row>
- <!-- <row>
+ <row>
<entry>
<code>AlternateServers</code>
</entry>
<entry>
<code>String</code>
</entry>
- <entry>Optional , delimited list of host:port entries. See the <link linkend="multiple_hosts">multiple hosts</link> section for more information.</entry>
- </row> -->
+ <entry>Optional delimited list of host:port entries. See the <link linkend="multiple_hosts">multiple hosts</link> section for more information.</entry>
+ </row>
<row>
<entry>
<code>AdditionalProperties</code>
@@ -407,7 +407,7 @@
directory. Based on the type of deployment (XA, driver, or local), the contents of the file will be different. See the following sections for more.</para></listitem>
</orderedlist>
- <para>Tje data source will then be accessable through the JNDI name specified in the -ds.xml file.</para>
+ <para>The data source will then be accessable through the JNDI name specified in the -ds.xml file.</para>
<section id="as_xa_connection">
<title>DataSource Connection</title>
@@ -444,7 +444,7 @@
<programlisting><![CDATA[<datasources>
<local-tx-datasource>
<jndi-name>TEIID-DS</jndi-name>
- <connection-url>jdbc:metamatrix:myVDB@mm://localhost:31000</connection-url>
+ <connection-url>jdbc:teiid:myVDB@mm://localhost:31000</connection-url>
<driver-class>org.teiid.jdbc.TeiidDriver</driver-class>
<user-name>admin</user-name>
<password>teiid</password>
@@ -488,27 +488,63 @@
<section id="multiple_hosts">
<title>Using Multiple Hosts</title>
- <para>A group of Teiid Servers in the same AS cluster may be connected using connection time failover and load-balancing.
- To enable this feature the client needs to specify multiple host name and port number combinations on the URL connection string.
- The client will randomly pick any one the Teiid server from the list and will have session established with that server.
- If that server cannot be contacted, then a connection will be attempted to each of the remaining servers in random order.</para>
-
- <!-- If the "autoFailover" connection property is set to "true", a failure with the connected server will cause the client to automatically failover
- to other available servers. Even if autoFailover is not set, when using a managed DataSource based connection, the connection will randomly select a new server instance when it is returned to the pool.</para>
- -->
- <example><title>Example URL connection string</title><programlisting><![CDATA[jdbc:teiid:<vdb-name>@mm://host1:31000, host1:31001, host2:31000;version=2]]></programlisting></example>
-
- <!-- <para>Currently when the fail over happens, the user is re-authenticated with the new server. The clustering
- feature coming up in the Teiid 7.1 release will define how the transparent session fail over will occur with out the
- re-authentication.</para>
-
- <para>You can also use this feature to distribute the query load among various avaialble Teiid Servers available.
- Load balancing happens automatically, when you are using a data source along with connection pooling. Each time a connection is
- grabbed from the pool, it will randomly select a Teiid Server to distribute the load. Note, that load balacing feature
- is not avaialble if you are using Teiid Driver to make your connection.</para>-->
-
- <para>If you are using DataSource to connect to Teiid Server, use "AlternateServers" property/method to define the failover servers.
- Check out the Javadoc on the format of the string.</para>
+ <para>A group of Teiid Servers in the same JBoss AS cluster may be connected using failover and load-balancing features.
+ To enable theses features in their simplest form, the client needs to specify multiple host name and port number combinations on the URL connection string.
+ <example><title>Example URL connection string</title><programlisting><![CDATA[jdbc:teiid:<vdb-name>@mm://host1:31000,host1:31001,host2:31000;version=2]]></programlisting></example>
+ </para>
+ <para>If you are using a DataSource to connect to Teiid Server, use the "AlternateServers" property/method to define the failover servers. The format is also a comma separated list of host:port combinations.</para>
+ <para>The client will randomly pick one the Teiid server from the list and establish a session with that server.
+ If that server cannot be contacted, then a connection will be attempted to each of the remaining servers in random order.
+ This allows for both connection time fail-over and random server selection load balancing.
+ </para>
+ <section id="failover">
+ <title>Fail Over</title>
+ <para>Post connection fail over will be sued if you're using an admin connection (such as what is used by AdminShell) or if the autoFailover connection property is set to true.
+ Post connection failover works by sending a ping, at most every second, to test the connection prior to use. If the ping fails, a new instance will be selected prior to the operation being attempted.
+ This is not true "transparent application failover" as the client will not restart the transaction/query/recreate session scoped temp tables, etc. So this feature should be used with caution by non-admin connections.</para>
+ </section>
+ <section id="loadbalancing">
+ <title>Load Balancing</title>
+ <para>Post connection load balancing can be utilized in one of two ways. First if you are using <code>TeiidDataSource</code> and the Connections returned by
+ Teiid <code>PooledConnections</code> have their <code>close</code> method called, then a new server instance will be selected automatically.
+ However when using driver based connections or even when using <code>TeiidDataSource</code> in a connection pool (such as JBoss AS), the automatic load balancing will not happen.
+ Second you can explicitly trigger load balancing through the use of the set statement: <programlisting>SET NEWINSTANCE TRUE</programlisting>
+ Typically you will not need want to issue this statement manually, but instead use it as the connection test query on your DataSource configuration.
+ <example>
+ <title>JBoss AS DataSource With Post Connection Load Balancing</title>
+ <programlisting><![CDATA[<datasources>
+ <local-tx-datasource>
+ <jndi-name>TEIID-DS</jndi-name>
+ <connection-url>jdbc:teiid:myVDB@mm://localhost:31000,mm://localhost:32000</connection-url>
+ <driver-class>org.teiid.jdbc.TeiidDriver</driver-class>
+ <user-name>admin</user-name>
+ <password>teiid</password>
+
+ <!-- pool and other JBoss datasource properties -->
+ <check-valid-connection-sql>SET NEWINSTANCE TRUE</check-valid-connection-sql>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>10</max-pool-size>
+ </local-tx-datasource>
+</datasources>]]></programlisting>
+</example>
+ </para>
+ <para>Teiid by default maintians a pool of extra socket connections that are reused. For load balancing, this reduces the potential cost of switching a connection to another server instance.
+ The default setting is to maintain 16 connections (see <code>org.teiid.sockets.maxCachedInstances</code> in the client jar's teiid-client-settings.properties file.
+ If you're client is connecting to large numbers of Teiid instances and you're using post connection time load balancing, then consider increasing the number of cached instances.
+ You may either set an analogous system property or create another version of teiid-client-settings.properties file and place it into the classpath ahead of the client jar.</para>
+ <note><para>Session level temporary tables, currently running transactions, session level cache entries, and PreparedPlans for a given session will not be available on other cluster members.
+ Therefore, it is recommended that post connection time load balancing is only used when the logical connection could have been closed, but the actual connection is reused (the typical connection pool pattern).</para></note>
+ </section>
+ <section id="advancedconfig">
+ <title>Advanced Configuration</title>
+ <para>Server discovery, load balancing, fail over, retry, retry delay, etc. may be customize if the default policy is not sufficient.
+ See the <code>org.teiid.net.socket.ServerDiscovery</code> interface and default implementaion <code>org.teiid.net.socket.UrlServerDiscovery</code> for how to start with your customization.
+ The <code>UrlServerDiscovery</code> implemenation provides the following: discovery of servers from the URL hosts (DataSource server/alternativeServers), random selection for load balancing and failover, 1 connection attempt per host, no biasing, black listing, or other advanced features.
+ Typically you'll want to extend the <code>UrlServerDiscovery</code> so that it can be used as the fallback strategy and to only implement the necessary changed methods.
+ It's important to consider that 1 <code>ServerDiscovery</code> instance will be created for each connection. Any sharing of information between instances should be done through static state or some other shared lookup.
+ </para>
+ <para>Your customized server discovery class will then need to be referenced by the discoveryStategy connection/DataSource property by its full class name.</para>
+ </section>
</section>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/odbc.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -206,7 +206,7 @@
ReadOnly = no
ServerType = Postgres
ConnSettings =
- UseServerSidePrepare=1
+ UseServerSidePrepare=0
ByteaAsLongVarBinary=1
Optimizer=0
Ksqo=0
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/using-hibernate.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -43,7 +43,7 @@
(replacing terms in angle brackets with the appropriate values):
<programlisting><![CDATA[<property name="connection.url">
- jdbc:metamatrix:<vdb-name>@mm://<host>:<port>;user=<user-name>;password=<password>
+ jdbc:teiid:<vdb-name>@mm://<host>:<port>;user=<user-name>;password=<password>
</property>]]></programlisting></para>
</listitem>
<listitem>
Modified: trunk/documentation/reference/src/main/docbook/en-US/Reference.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/Reference.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/Reference.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -53,7 +53,7 @@
<xi:include href="content/scalar_functions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/procedures.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/transaction_support.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/entitlements.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/dataroles.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/system_schema.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/translators.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/federated_planning.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
Copied: trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml (from rev 2524, branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/dataroles.xml)
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml (rev 0)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/dataroles.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="dataroles">
+ <title>Data Roles</title>
+ <para>Data roles, also called entitlements, are sets of permissions defined
+ per VDB that dictate data access (create, read, update, delete). Data roles use a fine-grained permission system that Teiid will enforce
+ at runtime and provide audit log entries for access violations (see that Admin and Developers Guide for more on Audit Logging).</para>
+
+ <para>Prior to applying data roles, you should consider restricting source system access through the fundamental design of your VDB.
+ Foremost, Teiid can only access source entries that are represented in imported metadata. You should narrow imported metadata to only what
+ is necessary for use by your VDB. When using Teiid Designer, you may then go further and modify the imported metadata at a granular
+ level to remove specific columns, mark tables as non-updatable, etc.</para>
+
+ <para>If data roles is enabled and data roles are defined in a VDB, then access permissions will be enforced by the Teiid Server.
+ The use of data roles may be disabled system wide via the
+ &jboss-beans; file, by setting the property <code>useDataRoles</code> to false in the configuration section of the <code>RuntimeEngineDeployer</code>.</para>
+
+ <warning><para>Unlike previous versions of Teiid data roles will only be checked if present in a VDB.
+ A VDB deployed without data roles is open for use by any authenticated user.</para></warning>
+
+ <section>
+ <title>Permissions</title>
+
+ <para>CREATE, READ, UPDATE, DELETE (CRUD) permissions can be set for any resource path in a VDB.
+ A resource path can be as specific as the fully qualified name of a column or as general a top level model (schema) name.
+ Permissions granted to a particular path apply to it and any resource paths that share the same partial name.
+ For example, granting read to "model" will also grant read to "model.table", "model.table.column", etc.
+ Allowing or denying a particular action is determined by searching for permissions from the most to least specific resource paths.
+ The first permission found with a specific allow or deny will be used.
+ Thus it is possible to set very general permissions at high-level resource path names and to override only as necessary at more specific resource paths.
+ </para>
+
+ <para>Permission grants are only needed for resources that a role needs access to.
+ Permissions are also only applied to the columns/tables/procedures in the user query - not to every resource
+ accessed transitively through view and procedure definitions.
+ It is important therefore to ensure that permission grants are applied
+ consistently across models that access the same resources.
+ </para>
+
+ <warning><para>Unlike previous versions of Teiid, non-visible models are accessible by user queries.
+ To restrict user access at a model level, at least one data role should be created to enable data role checking.
+ In turn that role can be mapped to any authenticated user and should not grant permissions to models that should be inaccessable.</para></warning>
+
+ <orderedlist>
+ <para>To process a <emphasis>SELECT</emphasis> statement or a stored procedure execution, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>READ</emphasis> - on the Table(s) being accessed or the procedure being called.</para></listitem>
+ <listitem> <para><emphasis>READ</emphasis> - on every column referenced.</para></listitem>
+ </orderedlist>
+
+ <orderedlist>
+ <para>To process an <emphasis>INSERT</emphasis> statement, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>CREATE</emphasis> - on the Table being inserted into.</para></listitem>
+ <listitem> <para><emphasis>CREATE</emphasis> - on every column being inserted on that Table.</para></listitem>
+ </orderedlist>
+
+ <orderedlist>
+ <para>To process an <emphasis>UPDATE</emphasis> statement, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>UPDATE</emphasis> - on the Table being updated.</para></listitem>
+ <listitem> <para><emphasis>UPDATE</emphasis> - on every column being updated on that Table.</para></listitem>
+ <listitem> <para><emphasis>READ</emphasis> - on every column referenced in the criteria.</para></listitem>
+ </orderedlist>
+
+ <orderedlist>
+ <para>To process a <emphasis>DELETE</emphasis> statement, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>DELETE</emphasis> - on the Table being deleted.</para></listitem>
+ <listitem> <para><emphasis>READ</emphasis> - on every column referenced in the criteria.</para></listitem>
+ </orderedlist>
+
+ <orderedlist>
+ <para>To process a <emphasis>EXEC</emphasis> statement, the user account requires the following access rights:</para>
+ <listitem> <para><emphasis>READ</emphasis> - on the Procedure being executed.</para></listitem>
+ </orderedlist>
+
+ </section>
+
+ <section>
+ <title>Role Mapping</title>
+ <para>Each Teiid data role can be mapped to any number of container roles or any authenticated user.
+ You may control role membership through whatever system the Teiid security domain login modules are associated with.
+ The kit includes example files for use with the UsersRolesLoginModule - see teiid-security-roles.properties.</para>
+ <para>It is possible for a user to have any number of container roles, which in turn imply a subset of Teiid data roles.
+ Each applicable Teiid data role contributes cumulatively to the permissions of the user.
+ No one role supercedes or negates the permissions of the other data roles.</para>
+ </section>
+
+ <section>
+ <title>XML Definition</title>
+ <para>Data roles are defined inside the <code>vdb.xml</code> file (inside the .vdb Zip archive under META-INF/vdb.xml) if you used Designer.
+ The "vdb.xml" file is checked against the schema file <code>vdb-deployer.xsd</code>, which can be found in the kit under teiid-docs/schema.
+ This example will show a sample "vdb.xml" file with few simple data roles.</para>
+
+ <para>For example, if a VDB defines a table "TableA" in schema "modelName" with columns (column1, column2) - note that the column types do not matter. And we wish to define three roles "RoleA", "RoleB", "RoleC" with following permissions:
+ <orderedlist>
+ <listitem><para>RoleA has permissions to read, write access to TableA, but can not delete.</para></listitem>
+ <listitem><para>RoleB has no permissions that allow access to TableA</para></listitem>
+ <listitem><para>RoleC has permissions that only allow read access to TableA.column1</para></listitem>
+ </orderedlist>
+ </para>
+ <example><title>vdb.xml defining RoleA, RoleB, and RoleC</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<vdb name="sample" version="1">
+
+ <model name="modelName">
+ <source name="source-name" translator-name="oracle" connection-jndi-name="java:myDS" />
+ </model>
+
+ <data-role name="RoleA">
+ <description>Allow all, except Delete</description>
+
+ <permission>
+ <resource-name>modelName.TableA</resource-name>
+ <allow-create>true</allow-create>
+ <allow-read>true</allow-read>
+ <allow-update>true</allow-update>
+ </permission>
+
+ <mapped-role-name>role1</mapped-role-name>
+
+ </data-role>
+
+ <data-role name="RoleC">
+ <description>Allow read only</description>
+
+ <permission>
+ <resource-name>modelName.TableA</resource-name>
+ <allow-read>true</allow-read>
+ </permission>
+
+ <permission>
+ <resource-name>modelName.TableA.colum2</resource-name>
+ <allow-read>false</allow-read>
+ </permission>
+
+ <mapped-role-name>role2</mapped-role-name>
+ </data-role>
+</vdb>]]></programlisting>
+</example>
+ <para>The above XML defined two data roles, "RoleA" which allows everything except delete on the table, "RoleC" that
+ allows only read operation on the table. Since Teiid uses deny by default, there is no explicit data-role entry needed for "RoleB". Note that explicit column permissions are
+ not needed for RoleA, since the parent resource path, modelName.TableA, permissions still apply. RoleC however must explicitly disallow read to column2.</para>
+
+ <para>The "mapped-role-name" defines the container JAAS roles that are assigned the data role. For assigning roles to your users in the JBoss AS,
+ check out the instructions for the selected Login Module. Check the "Admin Guide" for configuring Login Modules. You may also choose to allow any
+ authenticated user to have a data role by setting the any-authenticated attribute value to true on data-role element.</para>
+
+ </section>
+ <section>
+ <title>System Functions</title>
+ <para>The <code>hasRole</code> system function will return true if the current user has the given data role.
+ The <code>hasRole</code> function can be used in procedure or view definitions to allow for a more dynamic application of security - which allows for things such as value masking or row level security.</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: trunk/documentation/reference/src/main/docbook/en-US/content/entitlements.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/entitlements.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/entitlements.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,147 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="entitlements">
- <title>Data Roles</title>
- <para>Data roles, also called entitlements, are sets of permissions that are defined
- per VDB that dictate data access (create, read, update, delete). The use of data roles is controlled system wide with the property in
- <code><jboss-install>/server/<profile>/deploy/teiid/teiid-jboss-beans.xml</code> file
- in bean configuration section of <code>RuntimeEngineDeployer</code> with property <code>useDataRoles</code>.</para>
-
- <para>Once data roles are enabled, the access permissions defined in a VDB will be enforced by the Teiid Server.
- </para>
-
- <warning><para>Teiid uses a deny by default permission system, so all VDBs deployed to the server will need roles granting access with this feature enabled.</para></warning>
-
- <section>
- <title>Permissions</title>
-
- <para>CREATE, READ, UPDATE, DELETE (CRUD) permissions can be set for any resource path in a VDB.
- A resource path can be as specific as the fully qualified name of a column or as general a top level model (schema) name.
- Permissions granted to a particular path apply to it and any resource paths that share the same partial name.
- For example, granting read to "model" will also grant read to "model.table", "model.table.column", etc.
- Allowing or denying a particular action is determined by searching for permissions from the most to least specific resource paths.
- The first permission found with a specific allow or deny will be used.
- Thus it is possible to set very general permissions at high-level resource path names and to override only as necessary at more specific resource paths.
- </para>
-
- <para>Permission grants are only needed for resources that are visible.
- All non-visible, typically physical, models in a VDB are automatically
- inaccessible by user level requests. Permissions are also only applied
- to the columns and tables in the user query - not to every resource
- accessed transitively through views and procedures.
- It is important therefore to ensure that permission grants are applied
- consistently across visible models that access the same resources.
- </para>
-
- <orderedlist>
- <para>To process a <emphasis>SELECT</emphasis> statement or a stored procedure execution, the user account requires the following access rights:</para>
- <listitem> <para><emphasis>READ</emphasis> - on the Table(s) being accessed or the procedure being called.</para></listitem>
- <listitem> <para><emphasis>READ</emphasis> - on every column referenced.</para></listitem>
- </orderedlist>
-
- <orderedlist>
- <para>To process an <emphasis>INSERT</emphasis> statement, the user account requires the following access rights:</para>
- <listitem> <para><emphasis>CREATE</emphasis> - on the Table being inserted into.</para></listitem>
- <listitem> <para><emphasis>CREATE</emphasis> - on every column being inserted on that Table.</para></listitem>
- </orderedlist>
-
- <orderedlist>
- <para>To process an <emphasis>UPDATE</emphasis> statement, the user account requires the following access rights:</para>
- <listitem> <para><emphasis>UPDATE</emphasis> - on the Table being updated.</para></listitem>
- <listitem> <para><emphasis>UPDATE</emphasis> - on every column being updated on that Table.</para></listitem>
- <listitem> <para><emphasis>READ</emphasis> - on every column referenced in the criteria.</para></listitem>
- </orderedlist>
-
- <orderedlist>
- <para>To process a <emphasis>DELETE</emphasis> statement, the user account requires the following access rights:</para>
- <listitem> <para><emphasis>DELETE</emphasis> - on the Table being deleted.</para></listitem>
- <listitem> <para><emphasis>READ</emphasis> - on every column referenced in the criteria.</para></listitem>
- </orderedlist>
-
- <orderedlist>
- <para>To process a <emphasis>EXEC</emphasis> statement, the user account requires the following access rights:</para>
- <listitem> <para><emphasis>READ</emphasis> - on the Procedure being executed.</para></listitem>
- </orderedlist>
-
- </section>
-
- <section>
- <title>XML Definition</title>
- <para>Data roles are defined inside the <code>vdb.xml</code> file (inside the .vdb Zip archive under META-INF/vdb.xml) if you used Designer.
- This example will show a sample "vdb.xml" file with few simple data rules.</para>
-
- <para>For example, if a VDB defines a table "TableA" in schema "modelName" with columns (column1, column2) - note that the column types do not matter. And we wish to define three roles "RoleA", "RoleB", "RoleC" with following permissions:
- <orderedlist>
- <listitem><para>RoleA has privileges to read, write access to TableA, but can not delete.</para></listitem>
- <listitem><para>RoleB has no privileges that allow access to TableA</para></listitem>
- <listitem><para>RoleC has privileges that only allow read access to TableA.column1</para></listitem>
- </orderedlist>
- </para>
- <example><title>vdb.xml defining RoleA, RoleB, and RoleC</title>
- <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<vdb name="sample" version="1">
-
- <model name="modelName">
- <source name="source-name" translator-name="oracle" connection-jndi-name="java:myDS" />
- </model>
-
- <data-role name="RoleA">
- <description>Allow all, except Delete</description>
-
- <permission>
- <resource-name>modelName.TableA</resource-name>
- <allow-create>true</allow-create>
- <allow-read>true</allow-read>
- <allow-update>true</allow-update>
- </permission>
-
- <permission>
- <resource-name>modelName.TableA.colum1</resource-name>
- <allow-create>true</allow-create>
- <allow-read>true</allow-read>
- <allow-update>true</allow-update>
- </permission>
-
- <permission>
- <resource-name>modelName.TableA.column2</resource-name>
- <allow-create>true</allow-create>
- <allow-read>true</allow-read>
- <allow-update>true</allow-update>
- </permission>
-
- <mapped-role-name>role1</mapped-role-name>
-
- </data-role>
-
- <data-role name="RoleC">
- <description>Allow read only</description>
-
- <permission>
- <resource-name>modelName.TableA</resource-name>
- <allow-read>true</allow-read>
- </permission>
-
- <permission>
- <resource-name>modelName.TableA.colum1</resource-name>
- <allow-read>true</allow-read>
- </permission>
-
- <mapped-role-name>role2</mapped-role-name>
- </data-role>
-</vdb>]]></programlisting>
-</example>
- <para>The above XML defined two data roles, "RoleA" which allows everything except delete on the table, "RoleC" that
- allows only read operation on the table. Since Teiid uses deny by default, there is no explicit data-role entry needed for "RoleB". The "mapped-role-name" defines the JAAS "role" to whom these policies are applicable.</para>
-
- <para>For assigning roles to your users in the JBoss AS,
- check out the instructions for the selected Login Module. Check the "Admin Guide" for configuring Login Modules.</para>
-
- <para>The "vdb.xml" file is checked against the schema file <code>vdb-deployer.xsd</code>, check the documents sections of the Teiid kit
- to find a copy of the schema file.</para>
-
- </section>
-
-</chapter>
\ No newline at end of file
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -697,7 +697,7 @@
<para>LIMIT (limit result set to a certain range of results)</para>
</listitem>
</orderedlist>
- <para>These clause translate into the following types of planning
+ <para>These clauses translate into the following types of planning
nodes:</para>
<itemizedlist>
<listitem>
@@ -710,7 +710,7 @@
<para>GROUP BY: Group node</para>
</listitem>
<listitem>
- <para>GROUP BY: Group node</para>
+ <para>HAVING: Select node</para>
</listitem>
<listitem>
<para>SELECT: Project node and DupRemoval node (for SELECT DISTINCT)</para>
@@ -719,7 +719,7 @@
<para>INTO: Project node with a SOURCE Node</para>
</listitem>
<listitem>
- <para>INTO: Project node with a SOURCE Node</para>
+ <para>ORDER BY: Sort node</para>
</listitem>
<listitem>
<para>LIMIT: Limit node</para>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1036,7 +1036,7 @@
</entry>
</row><row>
<entry>
- <para>TO_BYTES(x, encoding)</para>
+ <para id="to_bytes">TO_BYTES(x, encoding)</para>
</entry>
<entry>
<para>Return a blob from the clob with the given encoding.
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1126,9 +1126,10 @@
<para>OPTION NOCACHE</para>
</listitem>
</itemizedlist>
- <para>Previous versions of Teiid accepted the PLANONLY, DEBUG, and SHOWPLAN option arguments. These are no longer accepted in the OPTION clause.
+ <para>All tables specified in the OPTION clause should be fully qualified.</para>
+ <note><para>Previous versions of Teiid accepted the PLANONLY, DEBUG, and SHOWPLAN option arguments. These are no longer accepted in the OPTION clause.
Please see the Client Developers Guide for replacements to those options.
- </para>
+ </para></note>
</section>
</section>
<section id="set_operations">
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -693,21 +693,31 @@
</tgroup>
</table>
<para>There are ws importer settings, but it does provide metadata for dynamic vdbs.</para>
-<note>
-<para>Setting the org.teiid.CONNECTOR.WS logging context to detail will show the request/response documents as part of the log.</para>
-</note>
<section><title>Usage</title>
-<para>The main procedure, invoke, allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
+<para>The WS translator exposes low level procedures for accessing web services. See also the ws-weather example in the kit.</para>
+<section>
+<title>Invoke Procedure</title>
+<para>invoke allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
<programlisting>Procedure invoke(binding in STRING, action in STRING, request in XML, endpoint in STRING) returns XML</programlisting>
</para>
<para>The binding may be one of null (to use the default) HTTP, SOAP11, or SOAP12. Action with a SOAP binding indicates the SOAPAction value. Action with a HTTP binding indicates the HTTP method (GET, POST, etc.), which defaults to POST.</para>
<para>A null value for the binding or endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.</para>
-<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invoke(binding='HTTP', action='GET')</programlisting></para>
+<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invoke(binding=>'HTTP', action=>'GET')</programlisting></para>
<para>The request XML should be a valid XML document or root element.</para>
-<para>See the ws-weather example in the kit and database metadata for a full description of invoke.</para>
</section>
+<section>
+<title>InvokeHTTP Procedure</title>
+<para>invokeHttp can return the byte contents of an HTTP(S) call.
+<programlisting>Procedure invokeHttp(action in STRING, request in OBJECT, endpoint in STRING, contentType out STRING) returns BLOB</programlisting>
+</para>
+<para>Action indicates the HTTP method (GET, POST, etc.), which defaults to POST.</para>
+<para>A null value for endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.</para>
+<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invokeHttp(action=>'GET')</programlisting></para>
+<para>The request can be one of SQLXML, STRING, BLOB, or CLOB. The request will be sent as the POST payload in byte form. For STRING/CLOB values this will default to the UTF-8 encoding. To control the byte encoding, see the <link linkend="to_bytes">to_bytes</link> function.</para>
</section>
</section>
+</section>
+</section>
<section id="dynamic_vdbs">
<title>Dynamic VDBs</title>
<para>
Modified: trunk/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,6 +29,7 @@
public enum Type {SESSION("Session"), //$NON-NLS-1$
RESULTSET("ResultSet"), //$NON-NLS-1$
+ RESULTSET_BATCHES(RESULTSET, "batches"), //$NON-NLS-1$
PREPAREDPLAN("PreparaedPlan"); //$NON-NLS-1$
private String location;
@@ -37,6 +38,10 @@
this.location = location;
}
+ Type(Type base, String location){
+ this.location = base.location+"/"+location; //$NON-NLS-1$
+ }
+
public String location() {
return this.location;
}
Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -139,7 +139,11 @@
if (ttl < 0) {
return Long.MAX_VALUE;
}
- return System.currentTimeMillis() + ttl;
+ long result = System.currentTimeMillis() + ttl;
+ if (result < ttl) {
+ result = Long.MAX_VALUE;
+ }
+ return result;
}
public V put(K key, V value, Long timeToLive) {
Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -34,8 +34,12 @@
private volatile boolean destroyed = false;
public DefaultCacheFactory() {
- this.cacheRoot = new DefaultCache("Teiid"); //$NON-NLS-1$
+ this(CacheConfiguration.DEFAULT);
}
+
+ public DefaultCacheFactory(CacheConfiguration config) {
+ this.cacheRoot = new DefaultCache("Teiid", config.getMaxEntries(), config.getMaxAgeInSeconds()*1000); //$NON-NLS-1$
+ }
@Override
public void destroy() {
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -116,4 +116,7 @@
STree createSTree(final List elements, String groupName, int keyLength);
+ void addTupleBuffer(TupleBuffer tb);
+
+ TupleBuffer getTupleBuffer(String id);
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/STree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/STree.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -392,4 +392,8 @@
this.preferMemory = preferMemory;
}
+ public boolean isPreferMemory() {
+ return preferMemory;
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -176,6 +176,7 @@
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ rowOffset = in.readInt();
terminationFlag = in.readBoolean();
preservedTypes = (String[])in.readObject();
if (types == null) {
@@ -187,6 +188,7 @@
}
}
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(this.rowOffset);
out.writeBoolean(terminationFlag);
out.writeObject(this.preservedTypes);
BatchSerializer.writeBatch(out, types, getAllTuples());
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBrowser.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,6 +22,7 @@
package org.teiid.common.buffer;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -32,12 +33,14 @@
/**
* Implements intelligent browsing over a {@link STree}
+ *
+ * TODO: this is not as efficient as it should be over partial matches
*/
public class TupleBrowser implements TupleSource {
private final STree tree;
- private List<List<Object>> valueSet;
+ private TupleSource valueSet;
private SPage page;
private int index;
@@ -48,14 +51,17 @@
private TupleBatch values;
private boolean updated;
private boolean direction;
+
+ private boolean inPartial;
/**
- * Construct a value based browser
+ * Construct a value based browser. The {@link TupleSource} should already be in the
+ * proper direction.
* @param sTree
* @param valueSet
* @param direction
*/
- public TupleBrowser(STree sTree, List<List<Object>> valueSet, boolean direction) {
+ public TupleBrowser(STree sTree, TupleSource valueSet, boolean direction) {
this.tree = sTree;
this.direction = direction;
this.valueSet = valueSet;
@@ -73,10 +79,17 @@
this.tree = sTree;
this.direction = direction;
+ init(lowerBound, upperBound);
+ }
+
+ private void init(List<Object> lowerBound,
+ List<?> upperBound)
+ throws TeiidComponentException {
if (lowerBound != null) {
+ lowerBound.addAll(Collections.nCopies(tree.getKeyLength() - lowerBound.size(), null));
setPage(lowerBound);
} else {
- page = sTree.header[0];
+ page = tree.header[0];
}
boolean valid = true;
@@ -91,7 +104,9 @@
bound = upper.page;
boundIndex = upper.index;
if (boundIndex < 0) {
- boundIndex = Math.min(upper.values.getTuples().size() - 1, -boundIndex -1);
+ //we are guaranteed by find to not get back the -1 index, unless
+ //there are now tuples, in which case a bound of -1 is fine
+ boundIndex = Math.min(upper.values.getTuples().size(), -boundIndex -1) - 1;
}
if (!direction) {
values = upper.values;
@@ -143,12 +158,17 @@
TeiidProcessingException {
for (;;) {
//first check for value iteration
- if (valueSet != null) {
- if (valueSet.isEmpty()) {
+ if (!inPartial && valueSet != null) {
+ List<?> newValue = valueSet.nextTuple();
+ if (newValue == null) {
resetState();
return null;
}
- List<?> newValue = direction?valueSet.remove(0):valueSet.remove(valueSet.size() -1);
+ if (newValue.size() < tree.getKeyLength()) {
+ init(new ArrayList<Object>(newValue), newValue);
+ inPartial = true;
+ continue;
+ }
if (values != null) {
int possibleIndex = Collections.binarySearch(values.getTuples(), newValue, tree.comparator);
if (possibleIndex >= 0) {
@@ -179,6 +199,10 @@
return values.getTuples().get(index);
}
if (page == null) {
+ if (inPartial) {
+ inPartial = false;
+ continue;
+ }
return null;
}
if (values == null) {
@@ -217,7 +241,7 @@
}
private int getOffset() {
- if (valueSet != null) {
+ if (!inPartial && valueSet != null) {
return 0;
}
return direction?1:-1;
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -76,6 +76,7 @@
private LobManager lobManager;
private int[] lobIndexes;
+ private String uuid;
public TupleBuffer(BatchManager manager, String id, List<?> schema, int[] lobIndexes, int batchSize) {
this.manager = manager;
@@ -86,9 +87,16 @@
if (this.lobIndexes != null) {
this.lobManager = new LobManager();
}
- this.batchSize = batchSize;
+ this.batchSize = batchSize;
}
+ public String getId() {
+ if (this.uuid == null) {
+ this.uuid = java.util.UUID.randomUUID().toString();
+ }
+ return this.uuid;
+ }
+
public boolean isLobs() {
return lobIndexes != null;
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -47,8 +48,6 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import javax.xml.transform.Source;
-
import org.teiid.common.buffer.BatchManager;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.FileStore;
@@ -59,20 +58,13 @@
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.SourceTransform;
-import org.teiid.core.types.StandardXMLTranslator;
-import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.processor.relational.ListNestedSortComparator;
-import org.teiid.query.processor.xml.XMLUtil;
/**
@@ -391,7 +383,10 @@
private volatile int activeBatchColumnCount = 0;
private Map<String, TupleBufferInfo> activeBatches = new LinkedHashMap<String, TupleBufferInfo>();
+ private Map<String, TupleReference> tupleBufferMap = new ConcurrentHashMap<String, TupleReference>();
+ private ReferenceQueue<TupleBuffer> tupleBufferQueue = new ReferenceQueue<TupleBuffer>();
+
private StorageManager diskMgr;
private AtomicLong tsId = new AtomicLong();
@@ -498,25 +493,7 @@
@Override
public void initialize() throws TeiidComponentException {
- //TODO: remove me - connectors should be able to do this statefully
- DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- SQLXMLImpl sqlxml;
- try {
- sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt);
- } catch (TeiidComponentException e) {
- throw new TeiidRuntimeException(e);
- } catch (TeiidProcessingException e) {
- throw new TeiidRuntimeException(e);
- }
- return new XMLType(sqlxml);
- }
- });
+
}
@Override
@@ -614,5 +591,38 @@
public void shutdown() {
}
-
+
+ @Override
+ public void addTupleBuffer(TupleBuffer tb) {
+ cleanDefunctTupleBuffers();
+ this.tupleBufferMap.put(tb.getId(), new TupleReference(tb, this.tupleBufferQueue));
+ }
+
+ @Override
+ public TupleBuffer getTupleBuffer(String id) {
+ cleanDefunctTupleBuffers();
+ Reference<TupleBuffer> r = this.tupleBufferMap.get(id);
+ if (r != null) {
+ return r.get();
+ }
+ return null;
+ }
+
+ private void cleanDefunctTupleBuffers() {
+ while (true) {
+ Reference r = this.tupleBufferQueue.poll();
+ if (r == null) {
+ break;
+ }
+ this.tupleBufferMap.remove(((TupleReference)r).id);
+ }
+ }
+
+ static class TupleReference extends WeakReference<TupleBuffer>{
+ String id;
+ public TupleReference(TupleBuffer referent, ReferenceQueue<? super TupleBuffer> q) {
+ super(referent, q);
+ id = referent.getId();
+ }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -31,8 +31,6 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.TransformationException;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.message.AtomicRequestID;
@@ -49,7 +47,6 @@
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionFactory;
@@ -75,9 +72,7 @@
private volatile ResultSetExecution execution;
private ProcedureBatchHandler procedureBatchHandler;
private org.teiid.language.Command translatedCommand;
- private Class<?>[] schema;
- private List<Integer> convertToRuntimeType;
- private boolean[] convertToDesiredRuntimeType;
+ private int expectedColumns;
/* End state information */
private boolean lastBatch;
@@ -200,17 +195,7 @@
this.connection = this.connector.getConnection(this.connectionFactory);
// Translate the command
Command command = this.requestMsg.getCommand();
- List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
- this.schema = new Class[symbols.size()];
- this.convertToDesiredRuntimeType = new boolean[symbols.size()];
- this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
- for (int i = 0; i < schema.length; i++) {
- SingleElementSymbol symbol = symbols.get(i);
- this.schema[i] = symbol.getType();
- this.convertToDesiredRuntimeType[i] = true;
- this.convertToRuntimeType.add(i);
- }
-
+ this.expectedColumns = command.getProjectedSymbols().size();
LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
this.translatedCommand = factory.translate(command);
@@ -219,17 +204,15 @@
// Create the execution based on mode
final Execution exec = connector.createExecution(this.translatedCommand, this.securityContext, rmd, this.connection);
if (this.translatedCommand instanceof Call) {
- Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
- this.execution = (ProcedureExecution)exec;
+ this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
StoredProcedure proc = (StoredProcedure)command;
if (proc.returnParameters()) {
- this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
+ this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)exec);
}
} else if (this.translatedCommand instanceof QueryExpression){
- Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
- this.execution = (ResultSetExecution)exec;
+ this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
} else {
- Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
+ Assertion.isInstanceOf(exec, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
this.execution = new ResultSetExecution() {
private int[] results;
private int index;
@@ -287,8 +270,8 @@
this.lastBatch = true;
break;
}
- if (row.size() != this.schema.length) {
- throw new AssertionError("Inproper results returned. Expected " + this.schema.length + " columns, but was " + row.size()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (row.size() != this.expectedColumns) {
+ throw new AssertionError("Inproper results returned. Expected " + this.expectedColumns + " columns, but was " + row.size()); //$NON-NLS-1$ //$NON-NLS-2$
}
this.rowCount += 1;
batchSize++;
@@ -296,7 +279,6 @@
row = this.procedureBatchHandler.padRow(row);
}
- correctTypes(row);
rows.add(row);
// Check for max result rows exceeded
if(this.requestMsg.getMaxResultRows() > -1 && this.rowCount >= this.requestMsg.getMaxResultRows()){
@@ -320,7 +302,6 @@
if (this.procedureBatchHandler != null) {
List row = this.procedureBatchHandler.getParameterRow();
if (row != null) {
- correctTypes(row);
rows.add(row);
this.rowCount++;
}
@@ -348,46 +329,6 @@
return response;
}
- private void correctTypes(List row) throws TranslatorException {
- //TODO: add a proper source schema
- for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
- int index = convertToRuntimeType.get(i);
- Object value = row.get(index);
- if (value != null) {
- Object result = DataTypeManager.convertToRuntimeType(value);
- if (DataTypeManager.isLOB(result.getClass())) {
- this.securityContext.keepExecutionAlive(true);
- }
- if (value == result && !DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[index])) {
- convertToRuntimeType.remove(i);
- continue;
- }
- row.set(index, result);
- }
- }
- //TODO: add a proper intermediate schema
- for (int i = 0; i < row.size(); i++) {
- if (convertToDesiredRuntimeType[i]) {
- Object value = row.get(i);
- if (value != null) {
- Object result;
- try {
- result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
- } catch (TransformationException e) {
- throw new TranslatorException(e);
- }
- if (value == result) {
- convertToDesiredRuntimeType[i] = false;
- continue;
- }
- row.set(i, result);
- }
- } else {
- row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
- }
- }
- }
-
public static AtomicResultsMessage createResultsMessage(List[] batch, List columnSymbols) {
String[] dataTypes = TupleBuffer.getTypeNames(columnSymbols);
return new AtomicResultsMessage(batch, dataTypes);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -36,8 +36,6 @@
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.impl.DataPolicyMetadata;
-import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
@@ -75,32 +73,16 @@
STORED_PROCEDURE;
}
- private VDBMetaData vdb;
private HashMap<String, DataPolicy> allowedPolicies;
private String userName;
- private boolean useEntitlements;
- public AuthorizationValidationVisitor(VDBMetaData vdb, boolean useEntitlements, HashMap<String, DataPolicy> policies, String user) {
- this.vdb = vdb;
+ public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, String user) {
this.allowedPolicies = policies;
this.userName = user;
- this.useEntitlements = useEntitlements;
}
// ############### Visitor methods for language objects ##################
- @Override
- public void visit(GroupSymbol obj) {
- try {
- Object modelID = getMetadata().getModelID(obj.getMetadataID());
- this.validateModelVisibility(modelID, obj);
- } catch(QueryMetadataException e) {
- handleException(e, obj);
- } catch(TeiidComponentException e) {
- handleException(e, obj);
- }
- }
-
public void visit(Delete obj) {
validateEntitlements(obj);
}
@@ -118,7 +100,6 @@
}
public void visit(StoredProcedure obj) {
- this.validateModelVisibility(obj.getModelID(), obj.getGroup());
validateEntitlements(obj);
}
@@ -126,7 +107,6 @@
if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(obj, this.getMetadata());
- validateModelVisibility(getMetadata().getModelID(lookup.getGroup().getMetadataID()), lookup.getGroup());
List<Symbol> symbols = new LinkedList<Symbol>();
symbols.add(lookup.getGroup());
symbols.add(lookup.getKeyElement());
@@ -289,30 +269,10 @@
}
- protected void validateModelVisibility(Object modelID, GroupSymbol group) {
- if(modelID instanceof TempMetadataID){
- return;
- }
- try {
- String modelName = getMetadata().getFullName(modelID);
- ModelMetaData model = vdb.getModel(modelName);
- if(!model.isVisible()) {
- handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088", getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
- }
- } catch (TeiidComponentException e) {
- handleException(e, group);
- }
- }
-
-
/**
* Out of resources specified, return the subset for which the specified not have authorization to access.
*/
public Set<String> getInaccessibleResources(DataPolicy.PermissionType action, Set<String> resources, Context context) {
- if (!this.useEntitlements) {
- return Collections.emptySet();
- }
-
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// Audit - request
AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.api.exception.query.QueryResolverException;
@@ -62,8 +61,12 @@
private String[] types;
private CacheHint hint;
private int batchSize;
+ private String uuid;
+ private int rowCount;
- protected ArrayList<UUID> cachedBatches = new ArrayList<UUID>();
+ public String getId() {
+ return this.uuid;
+ }
public AnalysisRecord getAnalysisRecord() {
return analysisRecord;
@@ -81,6 +84,8 @@
this.results = results;
this.batchSize = results.getBatchSize();
this.types = TupleBuffer.getTypeNames(results.getSchema());
+ this.rowCount = results.getRowCount();
+ this.uuid = results.getId();
}
public void setCommand(Command command) {
@@ -88,6 +93,10 @@
this.hint = command.getCacheHint();
}
+ public void setHint(CacheHint hint) {
+ this.hint = hint;
+ }
+
public CacheHint getHint() {
return hint;
}
@@ -103,19 +112,8 @@
@Override
public boolean prepare(Cache cache, BufferManager bufferManager) {
Assertion.assertTrue(!this.results.isForwardOnly());
- try {
- for (int row = 1; row <= this.results.getRowCount(); row+=this.results.getBatchSize()) {
- TupleBatch batch = results.getBatch(row);
- UUID uuid = java.util.UUID.randomUUID();
- batch.preserveTypes();
- cache.put(uuid, batch, this.hint != null?this.hint.getTtl():null);
- this.cachedBatches.add(uuid);
- }
- return true;
- } catch (TeiidComponentException e) {
- LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("failed_to_put_in_cache")); //$NON-NLS-1$
- }
- return false;
+ bufferManager.addTupleBuffer(this.results);
+ return true;
}
@Override
@@ -133,13 +131,15 @@
if (this.hint != null) {
buffer.setPrefersMemory(this.hint.getPrefersMemory());
}
- for (UUID uuid : this.cachedBatches) {
- TupleBatch batch = (TupleBatch)cache.get(uuid);
+
+ for (int row = 1; row <= this.rowCount; row+=this.batchSize) {
+ TupleBatch batch = (TupleBatch)cache.get(uuid+","+row); //$NON-NLS-1$
if (batch != null) {
buffer.addTupleBatch(batch, true);
- }
+ }
}
- this.results = buffer;
+ this.results = buffer;
+ bufferManager.addTupleBuffer(this.results);
}
return true;
} catch (TeiidComponentException e) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -41,6 +41,7 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.Request.ProcessingState;
import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.cache.Cache;
@@ -338,8 +339,8 @@
ClientState state = this.getClientState(workContext.getSessionId(), true);
request.initialize(requestMsg, bufferManager,
dataTierMgr, transactionService, state.sessionTables,
- workContext, this.useEntitlements);
-
+ workContext, this.useEntitlements, this.prepPlanCache);
+ request.setResultSetCacheEnabled(this.rsCache != null);
ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
logMMCommand(workItem, Event.NEW, null);
@@ -554,7 +555,25 @@
}
}
+ public CacheStatisticsMetadata getCacheStatistics(String cacheType) {
+ if (cacheType.equalsIgnoreCase(Admin.Cache.PREPARED_PLAN_CACHE.toString())) {
+ return buildCacheStats(Admin.Cache.PREPARED_PLAN_CACHE.toString(), this.prepPlanCache);
+ }
+ else if (cacheType.equalsIgnoreCase(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString())) {
+ return buildCacheStats(Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString(), this.rsCache);
+ }
+ return null;
+ }
+ private CacheStatisticsMetadata buildCacheStats(String name, SessionAwareCache cache) {
+ CacheStatisticsMetadata stats = new CacheStatisticsMetadata();
+ stats.setName(name);
+ stats.setHitRatio(cache.getRequestCount() == 0?0:((double)cache.getCacheHitCount()/cache.getRequestCount())*100);
+ stats.setTotalEntries(cache.getTotalCacheEntries());
+ stats.setRequestCount(cache.getRequestCount());
+ return stats;
+ }
+
public Collection<String> getCacheTypes(){
ArrayList<String> caches = new ArrayList<String>();
caches.add(Admin.Cache.PREPARED_PLAN_CACHE.toString());
@@ -639,6 +658,9 @@
this.exceptionOnMaxSourceRows = config.isExceptionOnMaxSourceRows();
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
+
+ //get buffer manager
+ this.bufferManager = bufferService.getBufferManager();
//result set cache
CacheConfiguration rsCacheConfig = config.getResultsetCacheConfig();
@@ -651,13 +673,11 @@
prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount()));
prepPlanCache.setBufferManager(this.bufferManager);
- //get buffer manager
- this.bufferManager = bufferService.getBufferManager();
-
+
this.processWorkerPool = new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,
- this.bufferService), this.bufferManager, this.processWorkerPool);
+ this.bufferService), this.bufferManager, this.processWorkerPool, this.rsCache);
}
public void setBufferService(BufferService service) {
@@ -809,6 +829,6 @@
public void setCacheFactory(CacheFactory factory) {
this.cacheFactory = factory;
- }
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -203,9 +203,7 @@
}
// get data roles from the VDB
- List<DataPolicy> policies = getVDB().getDataPolicies();
-
- for (DataPolicy policy : policies) {
+ for (DataPolicy policy : getVDB().getDataPolicies()) {
if (matchesPrincipal(userRoles, policy)) {
this.policies.put(policy.getName(), policy);
}
@@ -215,9 +213,14 @@
}
private boolean matchesPrincipal(Set<String> userRoles, DataPolicy policy) {
+ if (policy.isAnyAuthenticated()) {
+ return true;
+ }
List<String> roles = policy.getMappedRoleNames();
for (String role:roles) {
- return userRoles.contains(role);
+ if (userRoles.contains(role)) {
+ return true;
+ }
}
return false;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -38,6 +38,7 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
@@ -398,4 +399,8 @@
requestMgr.scheduleWork(r, priority, delay);
}
+ BufferManager getBufferManager() {
+ return bufferService.getBufferManager();
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,22 +22,41 @@
package org.teiid.dqp.internal.process;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
+import javax.activation.DataSource;
+import javax.xml.transform.Source;
+
import org.teiid.client.SourceWarning;
import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.StandardXMLTranslator;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.dqp.internal.datamgr.ConnectorWork;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.query.processor.xml.XMLUtil;
+import org.teiid.query.processor.xml.XMLUtil.FileStoreInputStreamFactory;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.TranslatorException;
@@ -58,6 +77,10 @@
private final ConnectorWork cwi;
private final DataTierManagerImpl dtm;
+ private List<Integer> convertToRuntimeType;
+ private boolean[] convertToDesiredRuntimeType;
+ private Class<?>[] schema;
+
// Data state
private int index;
private int rowsProcessed;
@@ -66,6 +89,7 @@
private volatile boolean canceled;
private boolean executed;
private volatile boolean done;
+ private boolean explicitClose;
private volatile ResultsFuture<AtomicResultsMessage> futureResult;
private volatile boolean running;
@@ -75,6 +99,17 @@
this.workItem = workItem;
this.cwi = cwi;
this.dtm = dtm;
+ List<SingleElementSymbol> symbols = this.aqr.getCommand().getProjectedSymbols();
+ this.schema = new Class[symbols.size()];
+ this.convertToDesiredRuntimeType = new boolean[symbols.size()];
+ this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
+ for (int i = 0; i < symbols.size(); i++) {
+ SingleElementSymbol symbol = symbols.get(i);
+ this.schema[i] = symbol.getType();
+ this.convertToDesiredRuntimeType[i] = true;
+ this.convertToRuntimeType.add(i);
+ }
+
Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
if (!aqr.isTransactional()) {
@@ -96,10 +131,75 @@
});
}
- public List getSchema() {
- return this.aqr.getCommand().getProjectedSymbols();
- }
+ private List correctTypes(List row) throws TransformationException {
+ for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
+ int idx = convertToRuntimeType.get(i);
+ Object value = row.get(idx);
+ if (value != null) {
+ Object result = convertToRuntimeType(value, this.schema[idx]);
+ if (DataTypeManager.isLOB(result.getClass())) {
+ explicitClose = true;
+ }
+ if (value == result && !DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[idx])) {
+ convertToRuntimeType.remove(i);
+ continue;
+ }
+ row.set(idx, result);
+ }
+ }
+ //TODO: add a proper intermediate schema
+ for (int i = 0; i < row.size(); i++) {
+ if (convertToDesiredRuntimeType[i]) {
+ Object value = row.get(i);
+ if (value != null) {
+ Object result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
+ if (value == result) {
+ convertToDesiredRuntimeType[i] = false;
+ continue;
+ }
+ row.set(i, result);
+ }
+ } else {
+ row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
+ }
+ }
+ return row;
+ }
+ private Object convertToRuntimeType(Object value, Class<?> desiredType) throws TransformationException {
+ if (value instanceof DataSource && (!(value instanceof Source) || desiredType != DataTypeManager.DefaultDataClasses.XML)) {
+ if (value instanceof InputStreamFactory) {
+ return new BlobType(new BlobImpl((InputStreamFactory)value));
+ }
+ FileStore fs = dtm.getBufferManager().createFileStore("bytes"); //$NON-NLS-1$
+ //TODO: guess at the encoding from the content type
+ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING);
+
+ try {
+ ObjectConverterUtil.write(fsisf.getOuputStream(), ((DataSource)value).getInputStream(), -1);
+ } catch (IOException e) {
+ throw new TransformationException(e, e.getMessage());
+ }
+ return new BlobType(new BlobImpl(fsisf));
+ }
+ if (value instanceof Source) {
+ if (value instanceof InputStreamFactory) {
+ return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
+ }
+ StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value);
+ SQLXMLImpl sqlxml;
+ try {
+ sqlxml = XMLUtil.saveToBufferManager(dtm.getBufferManager(), sxt);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ return new XMLType(sqlxml);
+ }
+ return DataTypeManager.convertToRuntimeType(value);
+ }
+
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
while (true) {
if (arm == null) {
@@ -124,7 +224,7 @@
receiveResults(results);
}
if (index < arm.getResults().length) {
- return this.arm.getResults()[index++];
+ return correctTypes(this.arm.getResults()[index++]);
}
arm = null;
if (isDone()) {
@@ -247,7 +347,7 @@
* @see TupleSource#closeSource()
*/
public void closeSource() {
- if (this.arm == null || this.arm.supportsImplicitClose()) {
+ if (!explicitClose) {
fullyCloseSource();
}
}
@@ -274,6 +374,7 @@
void receiveResults(AtomicResultsMessage response) {
this.arm = response;
+ explicitClose |= !arm.supportsImplicitClose();
rowsProcessed += response.getResults().length;
index = 0;
if (response.getWarnings() != null) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -30,7 +30,7 @@
import org.teiid.query.sql.symbol.Reference;
-class PreparedPlan{
+public class PreparedPlan{
private ProcessorPlan plan;
private Command command;
private List<Reference> refs;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -146,7 +146,7 @@
// Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
prepPlan.setPlan(processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
- this.prepPlanCache.put(id, this.context.getDeterminismLevel(), prepPlan);
+ this.prepPlanCache.put(id, this.context.getDeterminismLevel(), prepPlan, userCommand.getCacheHint() != null?userCommand.getCacheHint().getTtl():null);
}
} else {
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java (from rev 2524, branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryProcessorFactoryImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.parser.ParseInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.validator.AbstractValidationVisitor;
+import org.teiid.query.validator.ValidationVisitor;
+
+public class QueryProcessorFactoryImpl implements QueryProcessor.ProcessorFactory {
+
+ private QueryMetadataInterface metadata;
+ private CapabilitiesFinder finder;
+ private IDGenerator idGenerator;
+ private BufferManager bufferMgr;
+ private ProcessorDataManager dataMgr;
+
+ public QueryProcessorFactoryImpl(BufferManager bufferMgr,
+ ProcessorDataManager dataMgr, CapabilitiesFinder finder,
+ IDGenerator idGenerator, QueryMetadataInterface metadata) {
+ this.bufferMgr = bufferMgr;
+ this.dataMgr = dataMgr;
+ this.finder = finder;
+ this.idGenerator = idGenerator;
+ this.metadata = metadata;
+ }
+
+ @Override
+ public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException {
+ PreparedPlan pp = commandContext.getPlan(query);
+ CommandContext copy = commandContext.clone();
+ if (recursionGroup != null) {
+ copy.pushCall(recursionGroup);
+ }
+ if (pp == null) {
+ ParseInfo parseInfo = new ParseInfo();
+ Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
+ QueryResolver.resolveCommand(newCommand, metadata);
+
+ List<Reference> references = ReferenceCollectorVisitor.getReferences(newCommand);
+
+ AbstractValidationVisitor visitor = new ValidationVisitor();
+ Request.validateWithVisitor(visitor, metadata, newCommand);
+ int determinismLevel = copy.resetDeterminismLevel();
+ newCommand = QueryRewriter.rewrite(newCommand, metadata, copy);
+ AnalysisRecord record = new AnalysisRecord(false, false);
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, finder, record, copy);
+ pp = new PreparedPlan();
+ pp.setPlan(plan);
+ pp.setReferences(references);
+ pp.setAnalysisRecord(record);
+ pp.setCommand(newCommand);
+ commandContext.putPlan(query, pp, copy.getDeterminismLevel());
+ copy.setDeterminismLevel(determinismLevel);
+ }
+ copy.pushVariableContext(new VariableContext());
+ PreparedStatementRequest.resolveParameterValues(pp.getReferences(), Arrays.asList(params), copy, metadata);
+ return new QueryProcessor(pp.getPlan().clone(), copy, bufferMgr, dataMgr);
+ }
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -96,7 +96,7 @@
/**
* Server side representation of the RequestMessage. Knows how to process itself.
*/
-public class Request implements QueryProcessor.ProcessorFactory {
+public class Request {
// init state
protected RequestMessage requestMsg;
@@ -130,6 +130,8 @@
protected boolean returnsUpdateCount;
protected boolean useEntitlements;
private TempTableStore globalTables;
+ private SessionAwareCache<PreparedPlan> planCache;
+ private boolean resultSetCacheEnabled = true;
void initialize(RequestMessage requestMsg,
BufferManager bufferManager,
@@ -137,7 +139,8 @@
TransactionService transactionService,
TempTableStore tempTableStore,
DQPWorkContext workContext,
- boolean useEntitlements) {
+ boolean useEntitlements,
+ SessionAwareCache<PreparedPlan> planCache) {
this.requestMsg = requestMsg;
this.vdbName = workContext.getVdbName();
@@ -150,7 +153,8 @@
this.workContext = workContext;
this.requestId = workContext.getRequestID(this.requestMsg.getExecutionId());
this.connectorManagerRepo = workContext.getVDB().getAttachment(ConnectorManagerRepository.class);
- this.useEntitlements = useEntitlements;
+ this.useEntitlements = useEntitlements && !workContext.getVDB().getDataPolicies().isEmpty();
+ this.planCache = planCache;
}
void setMetadata(CapabilitiesFinder capabilitiesFinder, QueryMetadataInterface metadata, Set multiSourceModels) {
@@ -158,6 +162,10 @@
this.metadata = metadata;
this.multiSourceModels = multiSourceModels;
}
+
+ public void setResultSetCacheEnabled(boolean resultSetCacheEnabled) {
+ this.resultSetCacheEnabled = resultSetCacheEnabled;
+ }
/**
* if the metadata has not been supplied via setMetadata, this method will create the appropriate state
@@ -253,9 +261,11 @@
}
});
context.setTempTableStore(tempTableStore);
- context.setQueryProcessorFactory(this);
+ context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(this.bufferManager, this.processorDataManager, this.capabilitiesFinder, idGenerator, metadata));
context.setMetadata(this.metadata);
context.setBufferManager(this.bufferManager);
+ context.setPreparedPlanCache(planCache);
+ context.setResultSetCacheEnabled(this.resultSetCacheEnabled);
}
protected void checkReferences(List<Reference> references) throws QueryValidatorException {
@@ -449,31 +459,12 @@
}
this.context.setValidateXML(requestMsg.getValidationMode());
}
-
- public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws TeiidProcessingException, TeiidComponentException {
- ParseInfo parseInfo = new ParseInfo();
- Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
- QueryResolver.resolveCommand(newCommand, metadata);
-
- List<Reference> references = ReferenceCollectorVisitor.getReferences(newCommand);
-
- referenceCheck(references);
-
- validateQuery(newCommand);
-
- CommandContext copy = commandContext.clone();
- if (recursionGroup != null) {
- copy.pushCall(recursionGroup);
- }
-
- newCommand = QueryRewriter.rewrite(newCommand, metadata, copy);
- ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, capabilitiesFinder, analysisRecord, copy);
- return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
- }
protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getVDB(), this.useEntitlements, this.workContext.getAllowedDataPolicies(), this.workContext.getUserName());
- validateWithVisitor(visitor, this.metadata, command);
+ if (useEntitlements) {
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getAllowedDataPolicies(), this.workContext.getUserName());
+ validateWithVisitor(visitor, this.metadata, command);
+ }
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -336,8 +336,8 @@
SessionAwareCache<CachedResults> rsCache = dqpCore.getRsCache();
ParseInfo pi = Request.createParseInfo(requestMsg);
CacheID cacheId = new CacheID(this.dqpWorkContext, pi, requestMsg.getCommandString());
- cacheId.setParameters(requestMsg.getParameterValues());
- if (rsCache != null) {
+ boolean cachable = cacheId.setParameters(requestMsg.getParameterValues());
+ if (rsCache != null && cachable) {
CachedResults cr = rsCache.get(cacheId);
if (cr != null && (requestMsg.useResultSetCache() || cr.getHint() != null)) {
this.resultsBuffer = cr.getResults();
@@ -351,7 +351,7 @@
}
request.processRequest();
originalCommand = request.userCommand;
- if ((requestMsg.useResultSetCache() || originalCommand.getCacheHint() != null) && rsCache != null && originalCommand.areResultsCachable()) {
+ if (cachable && (requestMsg.useResultSetCache() || originalCommand.getCacheHint() != null) && rsCache != null && originalCommand.areResultsCachable()) {
this.cid = cacheId;
}
processor = request.processor;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,6 +35,7 @@
import org.teiid.cache.DefaultCacheFactory;
import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.function.metadata.FunctionMethod;
@@ -46,19 +47,21 @@
* This class is used to cache session aware objects
*/
public class SessionAwareCache<T> {
- public static final int DEFAULT_MAX_SIZE_TOTAL = 250;
+ public static final int DEFAULT_MAX_SIZE_TOTAL = 512;
private Cache<CacheID, T> localCache;
private Cache<CacheID, T> distributedCache;
+ private Cache tupleBatchCache;
private int maxSize = DEFAULT_MAX_SIZE_TOTAL;
private AtomicInteger cacheHit = new AtomicInteger();
+ private AtomicInteger totalRequests = new AtomicInteger();
private BufferManager bufferManager;
- SessionAwareCache(){
- this(new DefaultCacheFactory(), Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, DEFAULT_MAX_SIZE_TOTAL));
+ public SessionAwareCache(){
+ this(DEFAULT_MAX_SIZE_TOTAL);
}
SessionAwareCache(int maxSize){
@@ -77,10 +80,18 @@
}
else {
this.distributedCache = cacheFactory.get(type, config);
+ if (type == Cache.Type.RESULTSET) {
+ this.tupleBatchCache = cacheFactory.get(Cache.Type.RESULTSET_BATCHES, config);
+ }
+ else {
+ this.tupleBatchCache = this.distributedCache;
+ }
}
}
public T get(CacheID id){
+
+ this.totalRequests.getAndIncrement();
id.setSessionId(id.originalSessionId);
T result = localCache.get(id);
@@ -98,7 +109,7 @@
if (result != null && result instanceof Cachable) {
Cachable c = (Cachable)result;
- if (!c.restore(this.distributedCache, this.bufferManager)) {
+ if (!c.restore(this.tupleBatchCache, this.bufferManager)) {
result = null;
}
}
@@ -113,16 +124,19 @@
public int getCacheHitCount() {
return cacheHit.get();
}
+
+ public int getRequestCount() {
+ return this.totalRequests.get();
+ }
- public void put(CacheID id, int determinismLevel, T t){
- this.put(id, determinismLevel, t, null);
+ public int getTotalCacheEntries() {
+ if (this.localCache == this.distributedCache) {
+ return this.localCache.size();
+ }
+ return localCache.size() + distributedCache.size();
}
public void put(CacheID id, int determinismLevel, T t, Long ttl){
- if (!id.cachable) {
- return;
- }
-
if (determinismLevel >= FunctionMethod.SESSION_DETERMINISTIC) {
id.setSessionId(id.originalSessionId);
this.localCache.put(id, t, ttl);
@@ -142,7 +156,7 @@
if (t instanceof Cachable) {
Cachable c = (Cachable)t;
- insert = c.prepare(this.distributedCache, this.bufferManager);
+ insert = c.prepare(this.tupleBatchCache, this.bufferManager);
}
if (insert) {
@@ -160,7 +174,7 @@
this.distributedCache.clear();
}
- static class CacheID implements Serializable {
+ public static class CacheID implements Serializable {
private static final long serialVersionUID = 8261905111156764744L;
private String sql;
private VDBKey vdbInfo;
@@ -170,39 +184,64 @@
private List<Serializable> parameters;
private String userName;
private String originalUserName;
- private boolean cachable = true;
-
- CacheID(DQPWorkContext context, ParseInfo pi, String sql){
+
+ public CacheID(DQPWorkContext context, ParseInfo pi, String sql){
+ this(pi, sql, context.getVdbName(), context.getVdbVersion(), context.getSessionId(), context.getUserName());
+ }
+
+ public CacheID(ParseInfo pi, String sql, String vdbName, int vdbVersion, String sessionId, String userName){
this.sql = sql;
- this.vdbInfo = new VDBKey(context.getVdbName(), context.getVdbVersion());
+ this.vdbInfo = new VDBKey(vdbName, vdbVersion);
this.pi = pi;
- this.originalSessionId = context.getSessionId();
- this.originalUserName = context.getUserName();
+ this.originalSessionId = sessionId;
+ this.originalUserName = userName;
}
+
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
private void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
- public void setParameters(List<?> parameters) {
+ /**
+ * Set the raw (non-Constant) parameter values.
+ * @param parameters
+ * @return
+ */
+ public boolean setParameters(List<?> parameters) {
if (parameters != null && !parameters.isEmpty()) {
this.parameters = new ArrayList<Serializable>();
for (Object obj:parameters) {
- if (obj instanceof Serializable) {
- this.parameters.add((Serializable)obj);
+ if (obj == null) {
+ this.parameters.add(null);
+ continue;
}
- else{
- this.cachable = false;
+ if (!(obj instanceof Serializable)) {
+ return false;
}
+
+ Class<?> type = DataTypeManager.determineDataTypeClass(obj);
+ if (DataTypeManager.isLOB(type) || type == DataTypeManager.DefaultDataClasses.OBJECT) {
+ return false;
+ }
+ this.parameters.add((Serializable)obj);
}
}
+ return true;
}
public String getSql() {
return sql;
}
- public void setUserName(String name) {
+ void setUserName(String name) {
this.userName = name;
}
@@ -214,7 +253,7 @@
return false;
}
CacheID that = (CacheID)obj;
- return this.pi.equals(that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
+ return EquivalenceUtil.areEqual(this.pi, that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
&& EquivalenceUtil.areEqual(this.userName, that.userName)
&& EquivalenceUtil.areEqual(this.sessionId, that.sessionId)
&& EquivalenceUtil.areEqual(this.parameters, that.parameters);
@@ -228,18 +267,14 @@
public String toString() {
return "Cache Entry<" + originalSessionId + "="+ originalUserName + "> params:" + parameters + " sql:" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
+
}
- //for testing purpose
- int getSpaceUsed() {
- return localCache.size();
- }
int getSpaceAllowed() {
return maxSize;
}
public void setBufferManager(BufferManager bufferManager) {
this.bufferManager = bufferManager;
- }
-
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,9 +23,9 @@
package org.teiid.query.metadata;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -363,7 +363,11 @@
public Collection getIndexesInGroup(Object groupID)
throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
- return Collections.EMPTY_LIST;
+ List<List<TempMetadataID>> result = ((TempMetadataID)groupID).getIndexes();
+ if (result == null) {
+ return Collections.emptyList();
+ }
+ return result;
}
return this.actualMetadata.getIndexesInGroup(groupID);
}
@@ -372,11 +376,15 @@
throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
+ LinkedList<List<TempMetadataID>> result = new LinkedList<List<TempMetadataID>>();
TempMetadataID id = (TempMetadataID)groupID;
- if (id.getPrimaryKey() == null) {
- return Collections.emptyList();
+ if (id.getPrimaryKey() != null) {
+ result.add(id.getPrimaryKey());
}
- return Arrays.asList(groupID);
+ if (id.getUniqueKeys() != null) {
+ result.addAll(id.getUniqueKeys());
+ }
+ return result;
}
return this.actualMetadata.getUniqueKeysInGroup(groupID);
}
@@ -401,8 +409,8 @@
public List getElementIDsInKey(Object keyID)
throws TeiidComponentException, QueryMetadataException {
- if (keyID instanceof TempMetadataID) {
- return ((TempMetadataID)keyID).getPrimaryKey();
+ if (keyID instanceof List) {
+ return (List)keyID;
}
return this.actualMetadata.getElementIDsInKey(keyID);
@@ -692,10 +700,7 @@
@Override
public Object getPrimaryKey(Object metadataID) {
if (metadataID instanceof TempMetadataID) {
- if (((TempMetadataID)metadataID).getPrimaryKey() != null) {
- return metadataID;
- }
- return null;
+ return ((TempMetadataID)metadataID).getPrimaryKey();
}
return this.actualMetadata.getPrimaryKey(metadataID);
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,6 +25,7 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import org.teiid.core.util.LRUCache;
@@ -37,11 +38,28 @@
* does not exist in a real metadata source. Rather, it is used temporarily
* in context of processing a single query. This metadata ID can be used to
* represent either a group or an element depending on the constructor used.
+ *
+ * TODO: we should be using the real metadata objects, but internal and
+ * designer legacy keep us on the temp framework
*/
public class TempMetadataID implements Serializable {
private static final int LOCAL_CACHE_SIZE = 8;
+ static class TableData {
+ Collection<TempMetadataID> accessPatterns;
+ List<TempMetadataID> elements;
+ int cardinality = QueryMetadataInterface.UNKNOWN_CARDINALITY;
+ List<TempMetadataID> primaryKey;
+ QueryNode queryNode;
+ LRUCache<Object, Object> localCache;
+ CacheHint cacheHint;
+ List<List<TempMetadataID>> keys;
+ List<List<TempMetadataID>> indexes;
+ }
+
+ private static TableData DUMMY_DATA = new TableData();
+
public enum Type {
VIRTUAL,
TEMP,
@@ -50,18 +68,11 @@
private String ID; // never null, upper cased fully-qualified string
private Type metadataType = Type.VIRTUAL;
+ private Object originalMetadataID;
- //Table metadata
- private Collection<TempMetadataID> accessPatterns;
- private List<TempMetadataID> elements; // of TempMetadataID, only for group
- private int cardinality = QueryMetadataInterface.UNKNOWN_CARDINALITY;
- private List<TempMetadataID> primaryKey;
- private QueryNode queryNode;
- private transient LRUCache<Object, Object> localCache;
- private CacheHint cacheHint;
+ private TableData data;
- //Column metadata
- private Object originalMetadataID;
+ //Column metadata
private int position;
private Class<?> type; // type of this element, only for element
@@ -81,8 +92,9 @@
* @param isVirtual whether or not the group is a virtual group
*/
public TempMetadataID(String ID, List<TempMetadataID> elements, Type type) {
+ this.data = new TableData();
this.ID = ID;
- this.elements = elements;
+ this.data.elements = elements;
int pos = 1;
for (TempMetadataID tempMetadataID : elements) {
tempMetadataID.setPosition(pos++);
@@ -133,7 +145,7 @@
* @return List of TempMetadataID for groups, null for elements
*/
public List<TempMetadataID> getElements() {
- return this.elements;
+ return this.getTableData().elements;
}
/**
@@ -141,12 +153,12 @@
* @param elem
*/
protected void addElement(TempMetadataID elem) {
- if (this.elements != null) {
- this.elements.add(elem);
- elem.setPosition(this.elements.size());
+ if (this.getTableData().elements != null) {
+ this.getTableData().elements.add(elem);
+ elem.setPosition(this.getTableData().elements.size());
}
- if (this.localCache != null) {
- this.localCache.clear();
+ if (this.getTableData().localCache != null) {
+ this.getTableData().localCache.clear();
}
}
@@ -198,7 +210,7 @@
return this.ID.hashCode();
}
- public void setOriginalMetadataID(Object metadataId) {
+ public void setOriginalMetadataID(Object metadataId) {
this.originalMetadataID = metadataId;
}
@@ -211,22 +223,22 @@
}
public Collection<TempMetadataID> getAccessPatterns() {
- if (this.accessPatterns == null) {
+ if (this.getTableData().accessPatterns == null) {
return Collections.emptyList();
}
- return this.accessPatterns;
+ return this.getTableData().accessPatterns;
}
public void setAccessPatterns(Collection<TempMetadataID> accessPatterns) {
- this.accessPatterns = accessPatterns;
+ this.getTableData().accessPatterns = accessPatterns;
}
public int getCardinality() {
- return this.cardinality;
+ return this.getTableData().cardinality;
}
public void setCardinality(int cardinality) {
- this.cardinality = cardinality;
+ this.getTableData().cardinality = cardinality;
}
public void setTempTable(boolean isTempTable) {
@@ -238,17 +250,17 @@
}
Object getProperty(Object key) {
- if (this.localCache != null) {
- return this.localCache.get(key);
+ if (this.getTableData().localCache != null) {
+ return this.getTableData().localCache.get(key);
}
return null;
}
Object setProperty(Object key, Object value) {
- if (this.localCache == null) {
- this.localCache = new LRUCache<Object, Object>(LOCAL_CACHE_SIZE);
+ if (this.getTableData().localCache == null) {
+ this.getTableData().localCache = new LRUCache<Object, Object>(LOCAL_CACHE_SIZE);
}
- return this.localCache.put(key, value);
+ return this.getTableData().localCache.put(key, value);
}
public boolean isScalarGroup() {
@@ -260,11 +272,11 @@
}
public List<TempMetadataID> getPrimaryKey() {
- return primaryKey;
+ return getTableData().primaryKey;
}
public void setPrimaryKey(List<TempMetadataID> primaryKey) {
- this.primaryKey = primaryKey;
+ this.getTableData().primaryKey = primaryKey;
}
public int getPosition() {
@@ -276,19 +288,48 @@
}
public QueryNode getQueryNode() {
- return queryNode;
+ return getTableData().queryNode;
}
public void setQueryNode(QueryNode queryNode) {
- this.queryNode = queryNode;
+ this.getTableData().queryNode = queryNode;
}
public CacheHint getCacheHint() {
- return cacheHint;
+ return getTableData().cacheHint;
}
public void setCacheHint(CacheHint cacheHint) {
- this.cacheHint = cacheHint;
+ this.getTableData().cacheHint = cacheHint;
}
+
+ public List<List<TempMetadataID>> getIndexes() {
+ return getTableData().indexes;
+ }
+
+ public void addIndex(List<TempMetadataID> index) {
+ if (this.getTableData().indexes == null) {
+ this.getTableData().indexes = new LinkedList<List<TempMetadataID>>();
+ }
+ this.getTableData().indexes.add(index);
+ }
+
+ public List<List<TempMetadataID>> getUniqueKeys() {
+ return getTableData().keys;
+ }
+
+ public void addUniqueKey(List<TempMetadataID> key) {
+ if (this.getTableData().keys == null) {
+ this.getTableData().keys = new LinkedList<List<TempMetadataID>>();
+ }
+ this.getTableData().keys.add(key);
+ }
+
+ private TableData getTableData() {
+ if (data == null) {
+ return DUMMY_DATA;
+ }
+ return data;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -614,7 +614,7 @@
result.add(tableRecordImpl.getPrimaryKey());
}
for (KeyRecord key : tableRecordImpl.getIndexes()) {
- if (key.getType() == KeyRecord.Type.Index) {
+ if (key.getType() == KeyRecord.Type.Unique) {
result.add(key);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/ProcedurePlanner.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,8 +22,6 @@
package org.teiid.query.optimizer;
-import java.util.Map;
-
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
@@ -48,9 +46,6 @@
import org.teiid.query.processor.proc.WhileInstruction;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.DynamicCommand;
-import org.teiid.query.sql.lang.ProcedureContainer;
-import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.lang.TranslatableProcedureContainer;
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.CommandStatement;
@@ -92,7 +87,7 @@
analysisRecord.println("PROCEDURE COMMAND: " + procCommand); //$NON-NLS-1$
}
- Assertion.isInstanceOf(procCommand, CreateUpdateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$
+ CreateUpdateProcedureCommand cupc = Assertion.isInstanceOf(procCommand, CreateUpdateProcedureCommand.class, "Wrong command type"); //$NON-NLS-1$
if(debug) {
analysisRecord.println("OPTIMIZING SUB-COMMANDS: "); //$NON-NLS-1$
@@ -104,35 +99,20 @@
}
}
- Block block = ((CreateUpdateProcedureCommand) procCommand).getBlock();
+ Block block = cupc.getBlock();
- Program programBlock = planBlock(((CreateUpdateProcedureCommand)procCommand), block, metadata, debug, idGenerator, capFinder, analysisRecord, context);
+ Program programBlock = planBlock(cupc, block, metadata, debug, idGenerator, capFinder, analysisRecord, context);
if(debug) {
analysisRecord.println("\n####################################################"); //$NON-NLS-1$
}
-
+
// create plan from program and initialized environment
ProcedurePlan plan = new ProcedurePlan(programBlock);
- // propagate procedure parameters to the plan to allow runtime type checking
- ProcedureContainer container = (ProcedureContainer)((CreateUpdateProcedureCommand) procCommand).getUserCommand();
+ plan.setUpdateProcedure(cupc.isUpdateProcedure());
+ plan.setOutputElements(cupc.getProjectedSymbols());
- if (container != null) {
- if (container instanceof StoredProcedure) {
- plan.setRequiresTransaction(container.getUpdateCount() > 0);
- }
- Map params = container.getProcedureParameters();
- plan.setParams(params);
- plan.setMetadata(metadata);
- if (container instanceof TranslatableProcedureContainer) {
- plan.setImplicitParams(((TranslatableProcedureContainer)container).getImplicitParams());
- }
- }
-
- plan.setUpdateProcedure(((CreateUpdateProcedureCommand)procCommand).isUpdateProcedure());
- plan.setOutputElements(((CreateUpdateProcedureCommand)procCommand).getProjectedSymbols());
-
if(debug) {
analysisRecord.println("####################################################"); //$NON-NLS-1$
analysisRecord.println("PROCEDURE PLAN :"+plan); //$NON-NLS-1$
@@ -148,8 +128,8 @@
* @param block The <code>Block</code> to be planned
* @param metadata Metadata used during planning
* @param childNodes list of CommandTreeNode objects that contain the ProcessorPlans of the child nodes of this procedure
- * @param debug Boolean detemining if procedure plan needs to be printed for debug purposes
- * @param analysisRecord TODO
+ * @param debug Boolean determining if procedure plan needs to be printed for debug purposes
+ * @param analysisRecord
* @return A Program resulting in the block planning
* @throws QueryPlannerException if invalid statement is encountered in the block
* @throws QueryMetadataException if there is an error accessing metadata
@@ -183,14 +163,14 @@
/**
* <p> Plan a {@link Statement} object, depending on the type of the statement construct the appropriate
* {@link ProgramInstruction} return it to added to a {@link Program}. If the statement references a
- * <code>Command</code>, it looks up the child CommandTreeNodes to get approproiate child's ProcessrPlan
+ * <code>Command</code>, it looks up the child CommandTreeNodes to get appropriate child's ProcessrPlan
* and uses it for constructing the necessary instruction.</p>
* @param statement The statement to be planned
* @param metadata Metadata used during planning
* @param childNodes list of CommandTreeNode objects that contain the ProcessorPlans of the child nodes of this procedure
- * @param debug Boolean detemining if procedure plan needs to be printed for debug purposes
- * @param analysisRecord TODO
- * @return An array containing index of the next child to be accessesd and the ProgramInstruction resulting
+ * @param debug Boolean determining if procedure plan needs to be printed for debug purposes
+ * @param analysisRecord
+ * @return An array containing index of the next child to be accessed and the ProgramInstruction resulting
* in the statement planning
* @throws QueryPlannerException if invalid statement is encountered
* @throws QueryMetadataException if there is an error accessing metadata
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,15 +22,18 @@
package org.teiid.query.optimizer;
+import java.util.LinkedHashMap;
import java.util.Map;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.id.IDGenerator;
import org.teiid.core.id.IntegerIDFactory;
+import org.teiid.dqp.internal.process.PreparedPlan;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempCapabilitiesFinder;
@@ -40,20 +43,23 @@
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.optimizer.xml.XMLPlanner;
import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.proc.ProcedurePlan;
import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.ProcedureContainer;
import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.TranslatableProcedureContainer;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.util.CommandContext;
/**
* <p>This Class produces a ProcessorPlan object (a plan for query execution) from a
* user's command and a source of metadata.</p>
- *
- * <p>The user's Command object may in fact be a tree of commands and subcommands.
- * This component is architected to defer to the proper
- * {@link CommandPlanner CommandPlanner} implementation to plan each Command in the
- * tree.</p>
*/
public class QueryOptimizer {
@@ -65,7 +71,7 @@
private QueryOptimizer() {}
public static ProcessorPlan optimizePlan(Command command, QueryMetadataInterface metadata, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
+ throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
if (analysisRecord == null) {
analysisRecord = new AnalysisRecord(false, false);
@@ -98,7 +104,37 @@
ProcessorPlan result = null;
if (command.getType() == Command.TYPE_UPDATE_PROCEDURE){
- result = PROCEDURE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ CreateUpdateProcedureCommand cupc = (CreateUpdateProcedureCommand)command;
+ if (cupc.isUpdateProcedure()) {
+ result = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
+ } else {
+ String fullName = metadata.getFullName(cupc.getVirtualGroup().getMetadataID());
+ PreparedPlan pp = context.getPlan(fullName);
+ if (pp == null) {
+ int determinismLevel = context.resetDeterminismLevel();
+ ProcessorPlan plan = planProcedure(command, metadata, idGenerator, capFinder, analysisRecord, context);
+ //note that this is not a full prepared plan. It is not usable by user queries.
+ pp = new PreparedPlan();
+ pp.setPlan(plan);
+ context.putPlan(fullName, pp, context.getDeterminismLevel());
+ context.setDeterminismLevel(determinismLevel);
+ }
+ result = pp.getPlan().clone();
+ }
+ // propagate procedure parameters to the plan to allow runtime type checking
+ ProcedureContainer container = (ProcedureContainer)cupc.getUserCommand();
+ ProcedurePlan plan = (ProcedurePlan)result;
+ if (container != null) {
+ LinkedHashMap<ElementSymbol, Expression> params = container.getProcedureParameters();
+ if (container instanceof StoredProcedure) {
+ plan.setRequiresTransaction(container.getUpdateCount() > 0);
+ }
+ plan.setParams(params);
+ plan.setMetadata(metadata);
+ if (container instanceof TranslatableProcedureContainer) {
+ plan.setImplicitParams(((TranslatableProcedureContainer)container).getImplicitParams());
+ }
+ }
} else if (command.getType() == Command.TYPE_BATCHED_UPDATE){
result = BATCHED_UPDATE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
} else {
@@ -124,5 +160,20 @@
return result;
}
+
+ private static ProcessorPlan planProcedure(Command command,
+ QueryMetadataInterface metadata, IDGenerator idGenerator,
+ CapabilitiesFinder capFinder, AnalysisRecord analysisRecord,
+ CommandContext context) throws TeiidComponentException,
+ QueryPlannerException, QueryMetadataException {
+ ProcessorPlan result;
+ try {
+ command = QueryRewriter.rewrite(command, metadata, context);
+ } catch (TeiidProcessingException e) {
+ throw new QueryPlannerException(e, e.getMessage());
+ }
+ result = PROCEDURE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ return result;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -309,6 +309,9 @@
}
public void visit(ScalarSubquery obj) {
+ if (obj.shouldEvaluate()) {
+ return;
+ }
visitor.createChildNamingContext(false);
visitNode(obj.getCommand());
visitor.removeChildNamingContext();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -44,8 +44,6 @@
import org.teiid.core.id.IDGenerator;
import org.teiid.dqp.internal.process.Request;
import org.teiid.language.SQLConstants;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
import org.teiid.query.QueryPlugin;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.execution.QueryExecPlugin;
@@ -485,8 +483,25 @@
}
}
if (c != null) {
- c = QueryRewriter.rewrite(c, metadata, context);
- addNestedCommand(sourceNode, container.getGroup(), container, c, false);
+ if (c.getCacheHint() != null) {
+ if (container instanceof StoredProcedure) {
+ boolean noCache = isNoCacheGroup(metadata, ((StoredProcedure) container).getProcedureID(), option);
+ if (!noCache) {
+ if (container.areResultsCachable() && Query.areResultsCachable(container.getProcedureParameters().keySet()) && context.isResultSetCacheEnabled()) {
+ container.getGroup().setGlobalTable(true);
+ container.setCacheHint(c.getCacheHint());
+ recordAnnotation(analysisRecord, Annotation.CACHED_PROCEDURE, Priority.LOW, "SimpleQueryResolver.procedure_cache_used", container.getGroup()); //$NON-NLS-1$
+ return;
+ }
+ recordAnnotation(analysisRecord, Annotation.CACHED_PROCEDURE, Priority.MEDIUM, "SimpleQueryResolver.procedure_cache_not_usable", container.getGroup()); //$NON-NLS-1$
+ } else {
+ recordAnnotation(analysisRecord, Annotation.CACHED_PROCEDURE, Priority.LOW, "SimpleQueryResolver.procedure_cache_not_used", container.getGroup()); //$NON-NLS-1$
+ }
+ }
+ }
+ //skip the rewrite here, we'll do that in the optimizer
+ //so that we know what the determinism level is.
+ addNestedCommand(sourceNode, container.getGroup(), container, c, false);
}
}
@@ -926,14 +941,14 @@
//not use cache
qnode = metadata.getVirtualPlan(metadataID);
//TODO: update the table for defaultMat
- recordMaterializationTableAnnotation(analysisRecord, QueryPlugin.Util.getString("SimpleQueryResolver.materialized_table_not_used", virtualGroup, matTableName)); //$NON-NLS-1$
+ recordAnnotation(analysisRecord, Annotation.MATERIALIZED_VIEW, Priority.LOW, "SimpleQueryResolver.materialized_table_not_used", virtualGroup, matTableName); //$NON-NLS-1$
}else{
qnode = new QueryNode(groupName, null);
Query query = createMatViewQuery(matMetadataId, matTableName, Arrays.asList(new AllSymbol()), isImplicitGlobal);
query.setCacheHint(hint);
qnode.setCommand(query);
cacheString = "matview"; //$NON-NLS-1$
- recordMaterializationTableAnnotation(analysisRecord, QueryPlugin.Util.getString("SimpleQueryResolver.Query_was_redirected_to_Mat_table", virtualGroup, matTableName)); //$NON-NLS-1$
+ recordAnnotation(analysisRecord, Annotation.MATERIALIZED_VIEW, Priority.LOW, "SimpleQueryResolver.Query_was_redirected_to_Mat_table", virtualGroup, matTableName); //$NON-NLS-1$
}
} else {
// Not a materialized view - query the primary transformation
@@ -969,30 +984,44 @@
id.setCardinality(metadata.getCardinality(table.getMetadataID()));
Object pk = metadata.getPrimaryKey(table.getMetadataID());
- //primary key
if (pk != null) {
- List cols = metadata.getElementIDsInKey(pk);
- ArrayList<TempMetadataID> primaryKey = new ArrayList<TempMetadataID>(cols.size());
- for (Object coldId : cols) {
- int pos = metadata.getPosition(coldId) - 1;
- primaryKey.add(id.getElements().get(pos));
- }
+ ArrayList<TempMetadataID> primaryKey = resolveIndex(metadata, id, pk);
id.setPrimaryKey(primaryKey);
}
+ Collection keys = metadata.getUniqueKeysInGroup(table.getMetadataID());
+ for (Object key : keys) {
+ id.addUniqueKey(resolveIndex(metadata, id, key));
+ }
+ Collection indexes = metadata.getIndexesInGroup(table.getMetadataID());
+ for (Object index : indexes) {
+ id.addIndex(resolveIndex(metadata, id, index));
+ }
Command c = getCommand(table, metadata.getVirtualPlan(table.getMetadataID()), SQLConstants.Reserved.SELECT, metadata, analysisRecord);
CacheHint hint = c.getCacheHint();
if (hint != null) {
- recordMaterializationTableAnnotation(analysisRecord, QueryPlugin.Util.getString("SimpleQueryResolver.cache_hint_used", table, matTableName, hint)); //$NON-NLS-1$
+ recordAnnotation(analysisRecord, Annotation.MATERIALIZED_VIEW, Priority.LOW, "SimpleQueryResolver.cache_hint_used", table, matTableName, id.getCacheHint()); //$NON-NLS-1$
}
id.setCacheHint(hint);
}
}
} else if (id.getCacheHint() != null) {
- recordMaterializationTableAnnotation(analysisRecord, QueryPlugin.Util.getString("SimpleQueryResolver.cache_hint_used", table, matTableName, id.getCacheHint())); //$NON-NLS-1$
+ recordAnnotation(analysisRecord, Annotation.MATERIALIZED_VIEW, Priority.LOW, "SimpleQueryResolver.cache_hint_used", table, matTableName, id.getCacheHint()); //$NON-NLS-1$
}
return id;
}
+ private static ArrayList<TempMetadataID> resolveIndex(
+ QueryMetadataInterface metadata, TempMetadataID id, Object pk)
+ throws TeiidComponentException, QueryMetadataException {
+ List cols = metadata.getElementIDsInKey(pk);
+ ArrayList<TempMetadataID> primaryKey = new ArrayList<TempMetadataID>(cols.size());
+ for (Object coldId : cols) {
+ int pos = metadata.getPosition(coldId) - 1;
+ primaryKey.add(id.getElements().get(pos));
+ }
+ return primaryKey;
+ }
+
private static Command getCommand(GroupSymbol virtualGroup, QueryNode qnode,
String cacheString, QueryMetadataInterface qmi, AnalysisRecord analysisRecord) throws TeiidComponentException,
QueryMetadataException, QueryResolverException,
@@ -1034,29 +1063,23 @@
//only OPTION NOCACHE, no group specified
return true;
}
+ String fullName = metadata.getFullName(metadataID);
for (String groupName : option.getNoCacheGroups()) {
- try {
- Object noCacheGroupID = metadata.getGroupID(groupName);
- if(metadataID.equals(noCacheGroupID)){
- return true;
- }
- } catch (QueryMetadataException e) {
- //log that an unknown groups was used in the no cache
- LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, e, QueryPlugin.Util.getString("SimpleQueryResolver.unknown_group_in_nocache", groupName)); //$NON-NLS-1$
+ if(groupName.equalsIgnoreCase(fullName)){
+ return true;
}
}
return false;
}
- private static void recordMaterializationTableAnnotation(AnalysisRecord analysis,
- String msg) {
- if ( analysis.recordAnnotations() ) {
- Annotation annotation = new Annotation(Annotation.MATERIALIZED_VIEW,
- msg,
- null,
- Priority.LOW);
- analysis.addAnnotation(annotation);
- }
+ private static void recordAnnotation(AnalysisRecord analysis, String type, Priority priority, String msgKey, Object... parts) {
+ if (analysis.recordAnnotations()) {
+ Annotation annotation = new Annotation(type,
+ QueryPlugin.Util.getString(msgKey, parts),
+ null,
+ priority);
+ analysis.addAnnotation(annotation);
+ }
}
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -348,7 +348,7 @@
private void replaceCorrelatedReferences(List<SubqueryContainer> containers) {
for (SubqueryContainer container : containers) {
RelationalPlan subqueryPlan = (RelationalPlan)container.getCommand().getProcessorPlan();
- if (subqueryPlan == null) {
+ if (subqueryPlan == null || !(subqueryPlan.getRootNode() instanceof AccessNode)) {
continue;
}
AccessNode child = (AccessNode)subqueryPlan.getRootNode();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -107,7 +107,7 @@
}
// lookup mapping node for the user command
- GroupSymbol group = (GroupSymbol)xmlQuery.getFrom().getGroups().iterator().next();
+ GroupSymbol group = xmlQuery.getFrom().getGroups().iterator().next();
MappingDocument doc = (MappingDocument)metadata.getMappingNode(group.getMetadataID());
doc = (MappingDocument)doc.clone();
Modified: trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -106,39 +106,23 @@
throw new QueryParserException(QueryPlugin.Util.getString("QueryParser.emptysql")); //$NON-NLS-1$
}
- try {
- Command result = parseCommandWithParser(sql, parseInfo);
- if (parseInfo.cacheHint != null) {
- result.setCacheHint(parseInfo.cacheHint);
- }
- return result;
- } catch (QueryParserException e) {
- if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
- throw new QueryParserException(e, QueryPlugin.Util.getString("QueryParser.xqueryCompilation", sql)); //$NON-NLS-1$
- }
- throw e;
- }
- }
-
- /**
- * Parse the String sql into a Command using the MetaMatrix parser.
- * @param sql to parse
- * @return parsed Command
- * @throws QueryParserException
- */
- private Command parseCommandWithParser(String sql, ParseInfo parseInfo) throws QueryParserException {
- Command result = null;
+ Command result = null;
try{
result = getSqlParser(sql).command(parseInfo);
-
+ result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql));
} catch(ParseException pe) {
+ if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
+ throw new QueryParserException(pe, QueryPlugin.Util.getString("QueryParser.xqueryCompilation", sql)); //$NON-NLS-1$
+ }
throw convertParserException(pe);
-
} catch(TokenMgrError tme) {
+ if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
+ throw new QueryParserException(tme, QueryPlugin.Util.getString("QueryParser.xqueryCompilation", sql)); //$NON-NLS-1$
+ }
handleTokenMgrError(tme);
}
- return result;
- }
+ return result;
+ }
/**
* Takes a SQL string representing an SQL criteria (i.e. just the WHERE
Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -189,25 +189,25 @@
return hint;
}
- private static Pattern CACHE_HINT = Pattern.compile("\\s*cache(\\(\\s*(pref_mem)?\\s*(ttl:\\d{1,19})?\\s*(updatable)?[^)]*\\))?.*", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
+ private static Pattern CACHE_HINT = Pattern.compile("/\\*\\+?\\s*cache(\\(\\s*(pref_mem)?\\s*(ttl:\\d{1,19})?\\s*(updatable)?[^\\)]*\\))?[^\\*]*\\*\\/.*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
- void setQueryCacheOption(Token t, ParseInfo p) {
- String hint = getComment(t);
-
- Matcher match = CACHE_HINT.matcher(hint);
+ static CacheHint getQueryCacheOption(String query) {
+ Matcher match = CACHE_HINT.matcher(query);
if (match.matches()) {
- p.cacheHint = new CacheHint();
+ CacheHint hint = new CacheHint();
if (match.group(2) !=null) {
- p.cacheHint.setPrefersMemory(true);
+ hint.setPrefersMemory(true);
}
String ttl = match.group(3);
if (ttl != null) {
- p.cacheHint.setTtl(Long.valueOf(ttl.substring(4)));
+ hint.setTtl(Long.valueOf(ttl.substring(4)));
}
if (match.group(4) != null) {
- p.cacheHint.setUpdatable(true);
+ hint.setUpdatable(true);
}
+ return hint;
}
+ return null;
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -54,7 +54,7 @@
private static ExpiredTimeSliceException EXPIRED_TIME_SLICE = new ExpiredTimeSliceException();
public interface ProcessorFactory {
- QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws TeiidProcessingException, TeiidComponentException;
+ QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException;
}
private CommandContext context;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -69,10 +70,10 @@
*/
public class ProcedurePlan extends ProcessorPlan {
- public static class CursorState {
- private QueryProcessor processor;
- private IndexedTupleSource ts;
- private List<?> currentRow;
+ private static class CursorState {
+ QueryProcessor processor;
+ IndexedTupleSource ts;
+ List<?> currentRow;
}
private Program originalProgram;
@@ -91,7 +92,7 @@
private int beginBatch = 1;
private List batchRows;
private boolean lastBatch = false;
- private Map<ElementSymbol, Expression> params;
+ private LinkedHashMap<ElementSymbol, Expression> params;
private Map<ElementSymbol, Reference> implicitParams;
private QueryMetadataInterface metadata;
@@ -191,7 +192,7 @@
if (value == null && !metadata.elementSupports(param.getMetadataID(), SupportConstants.Element.NULL)) {
throw new QueryValidatorException(QueryExecPlugin.Util.getString("ProcedurePlan.nonNullableParam", expr)); //$NON-NLS-1$
}
- context.setValue(param, value);
+ setParameterValue(param, context, value);
}
}
if (this.implicitParams != null) {
@@ -207,6 +208,11 @@
this.evaluatedParams = true;
}
+ protected void setParameterValue(ElementSymbol param,
+ VariableContext context, Object value) {
+ context.setValue(param, value);
+ }
+
/**
* @see ProcessorPlan#nextBatch()
*/
@@ -378,7 +384,7 @@
this.metadata = metadata;
}
- public void setParams( Map<ElementSymbol, Expression> params ) {
+ public void setParams( LinkedHashMap<ElementSymbol, Expression> params ) {
this.params = params;
}
@@ -539,7 +545,6 @@
}
}
-
/**
* Get the schema from the tuple source that
* represents the columns in a result set
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -56,7 +56,12 @@
private TupleSource tupleSource;
private boolean isUpdate = false;
private boolean returnedRows = false;
+ private Command nextCommand;
+ protected AccessNode() {
+ super();
+ }
+
public AccessNode(int nodeID) {
super(nodeID);
}
@@ -66,6 +71,7 @@
tupleSource = null;
isUpdate = false;
returnedRows = false;
+ nextCommand = null;
}
public void setCommand(Command command) {
@@ -95,8 +101,9 @@
Command atomicCommand = command;
boolean needProcessing = true;
if(shouldEvaluate) {
- atomicCommand = (Command) command.clone();
+ atomicCommand = nextCommand();
needProcessing = prepareNextCommand(atomicCommand);
+ nextCommand = null;
} else {
needProcessing = RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
@@ -111,6 +118,15 @@
}
}
+ private Command nextCommand() {
+ //it's important to save the next command
+ //to ensure that the subquery ids remain stable
+ if (nextCommand == null) {
+ nextCommand = (Command) command.clone();
+ }
+ return nextCommand;
+ }
+
protected boolean prepareNextCommand(Command atomicCommand) throws TeiidComponentException, TeiidProcessingException {
return prepareCommand(atomicCommand, getEvaluator(Collections.emptyMap()), this.getContext(), this.getContext().getMetadata());
}
@@ -155,11 +171,13 @@
if (processCommandsIndividually() && hasPendingRows()) {
return pullBatch();
}
- Command atomicCommand = (Command)command.clone();
+ Command atomicCommand = nextCommand();
if (prepareNextCommand(atomicCommand)) {
+ nextCommand = null;
registerRequest(atomicCommand);
break;
}
+ nextCommand = null;
}
}
@@ -204,7 +222,7 @@
}
public Object clone(){
- AccessNode clonedNode = new AccessNode(super.getID());
+ AccessNode clonedNode = new AccessNode();
this.copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -45,6 +45,10 @@
private boolean isOpen;
private boolean needsProcessing;
+ protected PlanExecutionNode() {
+ super();
+ }
+
public PlanExecutionNode(int nodeID) {
super(nodeID);
}
@@ -154,7 +158,7 @@
}
public Object clone(){
- PlanExecutionNode clonedNode = new PlanExecutionNode(super.getID());
+ PlanExecutionNode clonedNode = new PlanExecutionNode();
copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -72,6 +72,10 @@
private TupleBatch currentBatch;
private TupleSource tupleSource;
+
+ protected ProjectIntoNode() {
+ super();
+ }
public ProjectIntoNode(int nodeID) {
super(nodeID);
@@ -244,7 +248,7 @@
}
public Object clone(){
- ProjectIntoNode clonedNode = new ProjectIntoNode(super.getID());
+ ProjectIntoNode clonedNode = new ProjectIntoNode();
super.copy(this, clonedNode);
clonedNode.intoGroup = intoGroup;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -62,6 +62,10 @@
// Saved state when blocked on evaluating a row - must be reset
private TupleBatch currentBatch;
private int currentRow = 1;
+
+ protected ProjectNode() {
+ super();
+ }
public ProjectNode(int nodeID) {
super(nodeID);
@@ -224,7 +228,7 @@
}
public Object clone(){
- ProjectNode clonedNode = new ProjectNode(super.getID());
+ ProjectNode clonedNode = new ProjectNode();
this.copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -50,88 +50,102 @@
public abstract class RelationalNode implements Cloneable, BatchProducer {
+
+ static class NodeData {
+ int nodeID;
+ List elements;
+ Number estimateNodeCardinality;
+ Number setSizeEstimate;
+ Number depAccessEstimate;
+ Number estimateDepJoinCost;
+ Number estimateJoinCost;
+ }
- // External context and state
- private CommandContext context;
- private BufferManager bufferManager;
- private ProcessorDataManager dataMgr;
-
- // Node state
- private int nodeID;
- private List elements;
- private int batchSize;
- private RelationalNodeStatistics nodeStatistics;
+ static class ProcessingState {
+ CommandContext context;
+ BufferManager bufferManager;
+ ProcessorDataManager dataMgr;
+ int batchSize;
+ RelationalNodeStatistics nodeStatistics;
+ int beginBatch = 1;
+ List batchRows;
+ boolean lastBatch;
+ boolean closed;
+
+ void reset() {
+ this.beginBatch = 1;
+ this.batchRows = null;
+ this.lastBatch = false;
+ this.closed = false;
+ }
+ }
- // For collecting result batches
- private int beginBatch = 1;
- private List batchRows;
- private boolean lastBatch = false;
-
+ private ProcessingState processingState;
+ private NodeData data;
/** The parent of this node, null if root. */
private RelationalNode parent;
/** Child nodes, usually just 1 or 2 */
private RelationalNode[] children = new RelationalNode[2];
-
- // Cost Estimates
- private Number estimateNodeCardinality;
- private Number setSizeEstimate;
- private Number depAccessEstimate;
- private Number estimateDepJoinCost;
- private Number estimateJoinCost;
-
- private boolean closed = false;
-
+
+ protected RelationalNode() {
+
+ }
+
public RelationalNode(int nodeID) {
- this.nodeID = nodeID;
+ this.data = new NodeData();
+ this.data.nodeID = nodeID;
}
public boolean isLastBatch() {
- return lastBatch;
+ return getProcessingState().lastBatch;
}
public void setContext(CommandContext context) {
- this.context = context;
+ this.getProcessingState().context = context;
}
public void initialize(CommandContext context, BufferManager bufferManager, ProcessorDataManager dataMgr) {
- this.context = context;
- this.bufferManager = bufferManager;
- this.dataMgr = dataMgr;
+ this.getProcessingState().context = context;
+ this.getProcessingState().bufferManager = bufferManager;
+ this.getProcessingState().dataMgr = dataMgr;
if(context.getCollectNodeStatistics()) {
- this.nodeStatistics = new RelationalNodeStatistics();
+ this.getProcessingState().nodeStatistics = new RelationalNodeStatistics();
}
- this.batchSize = bufferManager.getProcessorBatchSize();
+ this.getProcessingState().batchSize = bufferManager.getProcessorBatchSize();
}
public CommandContext getContext() {
- return this.context;
+ return this.getProcessingState().context;
}
public int getID() {
- return this.nodeID;
+ return this.data.nodeID;
}
public void setID(int nodeID) {
- this.nodeID = nodeID;
+ NodeData newData = new NodeData();
+ newData.nodeID = nodeID;
+ newData.elements = this.data.elements;
+ this.data = newData;
}
protected BufferManager getBufferManager() {
- return this.bufferManager;
+ return this.getProcessingState().bufferManager;
}
protected ProcessorDataManager getDataManager() {
- return this.dataMgr;
+ return this.getProcessingState().dataMgr;
}
protected String getConnectionID() {
- return this.context.getConnectionID();
+ return this.getProcessingState().context.getConnectionID();
}
protected int getBatchSize() {
- return this.batchSize;
+ return this.getProcessingState().batchSize;
}
public void reset() {
@@ -142,15 +156,13 @@
break;
}
}
-
- beginBatch = 1;
- batchRows = null;
- lastBatch = false;
- closed = false;
+ if (this.getProcessingState() != null) {
+ this.getProcessingState().reset();
+ }
}
public void setElements(List elements) {
- this.elements = elements;
+ this.data.elements = elements;
}
@Override
@@ -159,7 +171,7 @@
}
public List getElements() {
- return this.elements;
+ return this.data.elements;
}
public RelationalNode getParent() {
@@ -193,38 +205,38 @@
}
protected void addBatchRow(List row) {
- if(this.batchRows == null) {
- this.batchRows = new ArrayList(this.batchSize / 4);
+ if(this.getProcessingState().batchRows == null) {
+ this.getProcessingState().batchRows = new ArrayList(this.getProcessingState().batchSize / 4);
}
- this.batchRows.add(row);
+ this.getProcessingState().batchRows.add(row);
}
protected void terminateBatches() {
- this.lastBatch = true;
+ this.getProcessingState().lastBatch = true;
}
protected boolean isBatchFull() {
- return (this.batchRows != null) && (this.batchRows.size() >= this.batchSize);
+ return (this.getProcessingState().batchRows != null) && (this.getProcessingState().batchRows.size() >= this.getProcessingState().batchSize);
}
protected boolean hasPendingRows() {
- return this.batchRows != null;
+ return this.getProcessingState().batchRows != null;
}
protected TupleBatch pullBatch() {
TupleBatch batch = null;
- if(this.batchRows != null) {
- batch = new TupleBatch(this.beginBatch, this.batchRows);
- beginBatch += this.batchRows.size();
+ if(this.getProcessingState().batchRows != null) {
+ batch = new TupleBatch(this.getProcessingState().beginBatch, this.getProcessingState().batchRows);
+ getProcessingState().beginBatch += this.getProcessingState().batchRows.size();
} else {
- batch = new TupleBatch(this.beginBatch, Collections.EMPTY_LIST);
+ batch = new TupleBatch(this.getProcessingState().beginBatch, Collections.EMPTY_LIST);
}
- batch.setTerminationFlag(this.lastBatch);
+ batch.setTerminationFlag(this.getProcessingState().lastBatch);
// Reset batch state
- this.batchRows = null;
- this.lastBatch = false;
+ this.getProcessingState().batchRows = null;
+ this.getProcessingState().lastBatch = false;
// Return batch
return batch;
@@ -251,22 +263,22 @@
* @since 4.2
*/
public final TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException {
- boolean recordStats = this.context != null && this.context.getCollectNodeStatistics();
+ boolean recordStats = this.getProcessingState().context != null && this.getProcessingState().context.getCollectNodeStatistics();
try {
while (true) {
//start timer for this batch
- if(recordStats && this.context.getCollectNodeStatistics()) {
- this.nodeStatistics.startBatchTimer();
+ if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
+ this.getProcessingState().nodeStatistics.startBatchTimer();
}
TupleBatch batch = nextBatchDirect();
if (recordStats) {
- if(this.context.getCollectNodeStatistics()) {
+ if(this.getProcessingState().context.getCollectNodeStatistics()) {
// stop timer for this batch (normal)
- this.nodeStatistics.stopBatchTimer();
- this.nodeStatistics.collectCumulativeNodeStats(batch, RelationalNodeStatistics.BATCHCOMPLETE_STOP);
+ this.getProcessingState().nodeStatistics.stopBatchTimer();
+ this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(batch, RelationalNodeStatistics.BATCHCOMPLETE_STOP);
if (batch.getTerminationFlag()) {
- this.nodeStatistics.collectNodeStats(this.getChildren(), this.getClassName());
+ this.getProcessingState().nodeStatistics.collectNodeStats(this.getChildren(), this.getClassName());
//this.nodeStatistics.dumpProperties(this.getClassName());
}
}
@@ -283,21 +295,21 @@
}
}
} catch (BlockedException e) {
- if(recordStats && this.context.getCollectNodeStatistics()) {
+ if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
// stop timer for this batch (BlockedException)
- this.nodeStatistics.stopBatchTimer();
- this.nodeStatistics.collectCumulativeNodeStats(null, RelationalNodeStatistics.BLOCKEDEXCEPTION_STOP);
+ this.getProcessingState().nodeStatistics.stopBatchTimer();
+ this.getProcessingState().nodeStatistics.collectCumulativeNodeStats(null, RelationalNodeStatistics.BLOCKEDEXCEPTION_STOP);
}
throw e;
} catch (QueryProcessor.ExpiredTimeSliceException e) {
- if(recordStats && this.context.getCollectNodeStatistics()) {
- this.nodeStatistics.stopBatchTimer();
+ if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
+ this.getProcessingState().nodeStatistics.stopBatchTimer();
}
throw e;
} catch (TeiidComponentException e) {
// stop timer for this batch (MetaMatrixComponentException)
- if(recordStats && this.context.getCollectNodeStatistics()) {
- this.nodeStatistics.stopBatchTimer();
+ if(recordStats && this.getProcessingState().context.getCollectNodeStatistics()) {
+ this.getProcessingState().nodeStatistics.stopBatchTimer();
}
throw e;
}
@@ -317,7 +329,7 @@
public final void close()
throws TeiidComponentException {
- if (!this.closed) {
+ if (!this.getProcessingState().closed) {
closeDirect();
for(int i=0; i<children.length; i++) {
if(children[i] != null) {
@@ -326,7 +338,7 @@
break;
}
}
- this.closed = true;
+ this.getProcessingState().closed = true;
}
}
@@ -339,7 +351,7 @@
* @return
*/
public boolean isClosed() {
- return this.closed;
+ return this.getProcessingState().closed;
}
/**
@@ -487,9 +499,7 @@
public abstract Object clone();
protected void copy(RelationalNode source, RelationalNode target){
- if(source.elements != null){
- target.elements = new ArrayList(source.elements);
- }
+ target.data = source.data;
target.children = new RelationalNode[source.children.length];
for(int i=0; i<source.children.length; i++) {
@@ -505,9 +515,9 @@
public PlanNode getDescriptionProperties() {
// Default implementation - should be overridden
PlanNode result = new PlanNode(getClassName());
- result.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(this.elements));
- if(this.context != null && this.context.getCollectNodeStatistics()) {
- result.addProperty(PROP_NODE_STATS_LIST, this.nodeStatistics.getStatisticsList());
+ result.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(this.data.elements));
+ if(this.getProcessingState().context != null && this.getProcessingState().context.getCollectNodeStatistics()) {
+ result.addProperty(PROP_NODE_STATS_LIST, this.getProcessingState().nodeStatistics.getStatisticsList());
}
List<String> costEstimates = this.getCostEstimates();
if(costEstimates != null) {
@@ -526,57 +536,64 @@
* @since 4.2
*/
public RelationalNodeStatistics getNodeStatistics() {
- return this.nodeStatistics;
+ return this.getProcessingState().nodeStatistics;
}
public void setEstimateNodeCardinality(Number estimateNodeCardinality) {
- this.estimateNodeCardinality = estimateNodeCardinality;
+ this.data.estimateNodeCardinality = estimateNodeCardinality;
}
public void setEstimateNodeSetSize(Number setSizeEstimate) {
- this.setSizeEstimate = setSizeEstimate;
+ this.data.setSizeEstimate = setSizeEstimate;
}
public void setEstimateDepAccessCardinality(Number depAccessEstimate) {
- this.depAccessEstimate = depAccessEstimate;
+ this.data.depAccessEstimate = depAccessEstimate;
}
public void setEstimateDepJoinCost(Number estimateDepJoinCost){
- this.estimateDepJoinCost = estimateDepJoinCost;
+ this.data.estimateDepJoinCost = estimateDepJoinCost;
}
public void setEstimateJoinCost(Number estimateJoinCost){
- this.estimateJoinCost = estimateJoinCost;
+ this.data.estimateJoinCost = estimateJoinCost;
}
private List<String> getCostEstimates() {
List<String> costEstimates = new ArrayList<String>();
- if(this.estimateNodeCardinality != null) {
- costEstimates.add("Estimated Node Cardinality: "+ this.estimateNodeCardinality); //$NON-NLS-1$
+ if(this.data.estimateNodeCardinality != null) {
+ costEstimates.add("Estimated Node Cardinality: "+ this.data.estimateNodeCardinality); //$NON-NLS-1$
}
- if(this.setSizeEstimate != null) {
- costEstimates.add("Estimated Independent Node Produced Set Size: "+ this.setSizeEstimate); //$NON-NLS-1$
+ if(this.data.setSizeEstimate != null) {
+ costEstimates.add("Estimated Independent Node Produced Set Size: "+ this.data.setSizeEstimate); //$NON-NLS-1$
}
- if(this.depAccessEstimate != null) {
- costEstimates.add("Estimated Dependent Access Cardinality: "+ this.depAccessEstimate); //$NON-NLS-1$
+ if(this.data.depAccessEstimate != null) {
+ costEstimates.add("Estimated Dependent Access Cardinality: "+ this.data.depAccessEstimate); //$NON-NLS-1$
}
- if(this.estimateDepJoinCost != null) {
- costEstimates.add("Estimated Dependent Join Cost: "+ this.estimateDepJoinCost); //$NON-NLS-1$
+ if(this.data.estimateDepJoinCost != null) {
+ costEstimates.add("Estimated Dependent Join Cost: "+ this.data.estimateDepJoinCost); //$NON-NLS-1$
}
- if(this.estimateJoinCost != null) {
- costEstimates.add("Estimated Join Cost: "+ this.estimateJoinCost); //$NON-NLS-1$
+ if(this.data.estimateJoinCost != null) {
+ costEstimates.add("Estimated Join Cost: "+ this.data.estimateJoinCost); //$NON-NLS-1$
}
if(costEstimates.size() <= 0) {
return null;
}
return costEstimates;
}
-
/**
* @return Returns the estimateNodeCardinality.
*/
public Number getEstimateNodeCardinality() {
- return this.estimateNodeCardinality;
+ return this.data.estimateNodeCardinality;
}
+
+ private ProcessingState getProcessingState() {
+ //construct lazily since not all tests call initialize
+ if (this.processingState == null) {
+ this.processingState = new ProcessingState();
+ }
+ return processingState;
+ }
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -51,6 +51,10 @@
// State if blocked on evaluating a criteria
private TupleBatch currentBatch;
private int currentRow = 1;
+
+ protected SelectNode() {
+ super();
+ }
public SelectNode(int nodeID) {
super(nodeID);
@@ -117,7 +121,7 @@
}
public Object clone(){
- SelectNode clonedNode = new SelectNode(super.getID());
+ SelectNode clonedNode = new SelectNode();
this.copy(this, clonedNode);
return clonedNode;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -37,6 +37,10 @@
private SubqueryAwareEvaluator evaluator;
+ protected SubqueryAwareRelationalNode() {
+ super();
+ }
+
public SubqueryAwareRelationalNode(int nodeID) {
super(nodeID);
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -45,7 +45,6 @@
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.resolver.ProcedureContainerResolver;
import org.teiid.query.resolver.QueryResolver;
-import org.teiid.query.resolver.VariableResolver;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.resolver.util.ResolverVisitor;
import org.teiid.query.sql.lang.Command;
@@ -63,7 +62,7 @@
/**
*/
-public class ExecResolver extends ProcedureContainerResolver implements VariableResolver {
+public class ExecResolver extends ProcedureContainerResolver {
/**
* @see org.teiid.query.resolver.CommandResolver#findCommandMetadata(org.teiid.query.sql.lang.Command,
@@ -217,7 +216,7 @@
// Create temporary metadata that defines a group based on either the stored proc
// name or the stored query name - this will be used later during planning
- String procName = storedProcedureCommand.getProcedureName();
+ String procName = metadata.getFullName(storedProcedureCommand.getProcedureID());
GroupContext context = new GroupContext();
@@ -291,29 +290,7 @@
QueryResolverException {
//Do nothing
}
-
- /**
- * Collect input expressions from a procedure and map them to the parameters they came from
- * @param command Procedure to collect input expressions from
- * @return Map of param name (full upper case) to Expression
- */
- public Map getVariableValues(Command command, QueryMetadataInterface metadata) {
- StoredProcedure proc = (StoredProcedure)command;
- List oldParams = proc.getInputParameters();
- Map inputMap = new HashMap();
-
- Iterator oldParamIter = oldParams.iterator();
- while(oldParamIter.hasNext()) {
- SPParameter param = (SPParameter) oldParamIter.next();
- String paramName = proc.getParamFullName(param).toUpperCase();
- Expression expr = param.getExpression();
- inputMap.put(paramName, expr);
- }
-
- return inputMap;
- }
-
/**
* @see org.teiid.query.resolver.ProcedureContainerResolver#getPlan(org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.sql.symbol.GroupSymbol)
*/
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -70,7 +70,6 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import org.teiid.query.util.ErrorMessageKeys;
@@ -115,7 +114,7 @@
// then in the query transformation, this info is used in evaluating/validating
// has criteria/translate criteria clauses
Command transformCmd = getQueryTransformCmd(virtualGroup, metadata);
- Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, (List<SingleElementSymbol>)transformCmd.getProjectedSymbols(), metadata).asMap();
+ Map symbolMap = SymbolMap.createSymbolMap(virtualGroup, transformCmd.getProjectedSymbols(), metadata).asMap();
procCommand.setSymbolMap(symbolMap);
}
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -979,7 +979,7 @@
if (predicate.getJoinType() == JoinType.JOIN_UNION) {
predicate.setJoinType(JoinType.JOIN_FULL_OUTER);
- predicate.setJoinCriteria(Arrays.asList(new Object[] {FALSE_CRITERIA}));
+ predicate.setJoinCriteria(new ArrayList<Criteria>(Arrays.asList(FALSE_CRITERIA)));
} else if (predicate.getJoinType() == JoinType.JOIN_RIGHT_OUTER) {
predicate.setJoinType(JoinType.JOIN_LEFT_OUTER);
FromClause leftClause = predicate.getLeftClause();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,14 +25,9 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
-import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.core.TeiidComponentException;
-import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.sql.LanguageVisitor;
-import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.util.VariableContext;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/CacheHint.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -24,10 +24,13 @@
import java.io.Serializable;
+import org.teiid.core.util.EquivalenceUtil;
import org.teiid.query.sql.visitor.SQLStringVisitor;
public class CacheHint implements Serializable {
+ private static final long serialVersionUID = -4119606289701982511L;
+
public static final String PREF_MEM = "pref_mem"; //$NON-NLS-1$
public static final String TTL = "ttl:"; //$NON-NLS-1$
public static final String UPDATABLE = "updatable"; //$NON-NLS-1$
@@ -75,5 +78,19 @@
public void setUpdatable(boolean updatable) {
this.updatable = updatable;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof CacheHint)) {
+ return false;
+ }
+ CacheHint other = (CacheHint)obj;
+ return this.prefersMemory == other.prefersMemory
+ && EquivalenceUtil.areEqual(this.ttl, other.ttl)
+ && this.updatable == other.updatable;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -32,6 +32,7 @@
import java.util.Map;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -334,4 +335,9 @@
public String toString() {
return SQLStringVisitor.getSQLString(this);
}
+
+ protected boolean sameOptionAndHint(Command cmd) {
+ return EquivalenceUtil.areEqual(this.cacheHint, cmd.cacheHint) &&
+ EquivalenceUtil.areEqual(this.option, cmd.option);
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,13 +22,14 @@
package org.teiid.query.sql.lang;
-import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -167,8 +168,8 @@
* @see org.teiid.query.sql.lang.ProcedureContainer#getParameters()
* @since 5.0
*/
- public Map getProcedureParameters() {
- return Collections.EMPTY_MAP;
+ public LinkedHashMap<ElementSymbol, Expression> getProcedureParameters() {
+ return new LinkedHashMap<ElementSymbol, Expression>();
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,11 +23,10 @@
package org.teiid.query.sql.lang;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.util.EquivalenceUtil;
@@ -50,11 +49,8 @@
/** Identifies the group to be udpdated. */
private GroupSymbol group;
- /** list of column variables, null = all columns */
- private List variables = new LinkedList();
-
- /** List of Expressions */
- private List values = new LinkedList();
+ private List<ElementSymbol> variables = new LinkedList<ElementSymbol>();
+ private List<Expression> values = new LinkedList<Expression>();
private QueryCommand queryExpression;
@@ -234,14 +230,13 @@
* @see org.teiid.query.sql.lang.ProcedureContainer#getParameters()
* @since 5.0
*/
- public Map getProcedureParameters() {
+ public LinkedHashMap<ElementSymbol, Expression> getProcedureParameters() {
int iSize = getVariables().size();
- HashMap map = new HashMap();
+ LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
for (int j = 0; j < iSize; j++) {
- ElementSymbol symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
- symbol = (ElementSymbol)((ElementSymbol)variables.get( j )).clone();
+ ElementSymbol symbol = (ElementSymbol)variables.get( j ).clone();
symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
map.put(symbol, values.get( j ) );
} // for
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,8 +22,10 @@
package org.teiid.query.sql.lang;
-import java.util.Map;
+import java.util.LinkedHashMap;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
@@ -59,5 +61,5 @@
this.updateCount = updateCount;
}
- public abstract Map getProcedureParameters();
+ public abstract LinkedHashMap<ElementSymbol, Expression> getProcedureParameters();
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,6 +23,7 @@
package org.teiid.query.sql.lang;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -373,12 +374,10 @@
* @return True if equal
*/
public boolean equals(Object obj) {
- // Quick same object test
if(this == obj) {
return true;
}
- // Quick fail tests
if(!(obj instanceof Query)) {
return false;
}
@@ -392,8 +391,8 @@
EquivalenceUtil.areEqual(getHaving(), other.getHaving()) &&
EquivalenceUtil.areEqual(getOrderBy(), other.getOrderBy()) &&
EquivalenceUtil.areEqual(getLimit(), other.getLimit()) &&
- EquivalenceUtil.areEqual(getOption(), other.getOption()) &&
- getIsXML() == other.getIsXML();
+ getIsXML() == other.getIsXML() &&
+ sameOptionAndHint(other);
}
/**
@@ -426,9 +425,8 @@
return areResultsCachable(projectedSymbols);
}
- static boolean areResultsCachable(List projectedSymbols) {
- for(int i=0; i<projectedSymbols.size(); i++){
- SingleElementSymbol projectedSymbol = (SingleElementSymbol)projectedSymbols.get(i);
+ public static boolean areResultsCachable(Collection<? extends SingleElementSymbol> projectedSymbols) {
+ for (SingleElementSymbol projectedSymbol : projectedSymbols) {
if(DataTypeManager.isLOB(projectedSymbol.getType()) || projectedSymbol.getType() == DataTypeManager.DefaultDataClasses.OBJECT) {
return false;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,10 +29,8 @@
import java.util.List;
import org.teiid.client.metadata.ParameterInfo;
-import org.teiid.core.TeiidException;
-import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.EquivalenceUtil;
import org.teiid.query.QueryPlugin;
-import org.teiid.query.eval.Evaluator;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.util.ErrorMessageKeys;
@@ -303,7 +301,7 @@
return true;
}
- if(obj == null || !(obj instanceof SPParameter)){
+ if(!(obj instanceof SPParameter)){
return false;
}
@@ -314,11 +312,7 @@
}
// If indexes match, check associated IDs if existent
- if (this.getMetadataID() != null && other.getMetadataID() != null) {
- return this.getMetadataID().equals(other.getMetadataID());
- }
-
- return true;
+ return EquivalenceUtil.areEqual(this.expression, other.expression);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -213,7 +213,7 @@
EquivalenceUtil.areEqual(this.rightQuery, other.rightQuery) &&
EquivalenceUtil.areEqual(getOrderBy(), other.getOrderBy()) &&
EquivalenceUtil.areEqual(getLimit(), other.getLimit()) &&
- EquivalenceUtil.areEqual(getOption(), other.getOption());
+ sameOptionAndHint(other);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -35,6 +36,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
import org.teiid.query.util.ErrorMessageKeys;
@@ -256,7 +258,7 @@
* @return Ordered list of SingleElementSymbol
*/
public List getProjectedSymbols(){
- List result = new ArrayList();
+ List<ElementSymbol> result = new ArrayList<ElementSymbol>();
//add result set columns
List rsColumns = getResultSetColumns();
result.addAll(rsColumns);
@@ -264,24 +266,15 @@
return result;
}
//add out/inout parameter symbols
- Iterator iter = mapOfParameters.values().iterator();
- while(iter.hasNext()){
- SPParameter parameter = (SPParameter)iter.next();
- if(parameter.getParameterType() == ParameterInfo.INOUT || parameter.getParameterType() == ParameterInfo.OUT){
+ for (SPParameter parameter : mapOfParameters.values()) {
+ if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
ElementSymbol symbol = parameter.getParameterSymbol();
symbol.setGroupSymbol(getGroup());
- result.add(symbol);
- }
- }
- //add return parameter
- iter = mapOfParameters.values().iterator();
- while(iter.hasNext()){
- SPParameter parameter = (SPParameter)iter.next();
- if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
+ result.add(0, symbol);
+ } else if(parameter.getParameterType() == ParameterInfo.INOUT || parameter.getParameterType() == ParameterInfo.OUT){
ElementSymbol symbol = parameter.getParameterSymbol();
symbol.setGroupSymbol(getGroup());
- result.add(symbol);
- break;
+ result.add(symbol);
}
}
return result;
@@ -300,7 +293,7 @@
*/
@Override
public int hashCode() {
- return this.toString().hashCode();
+ return this.getGroup().hashCode();
}
public boolean equals(Object obj) {
@@ -314,7 +307,11 @@
return false;
}
- return this.toString().equals(obj.toString());
+ StoredProcedure other = (StoredProcedure)obj;
+
+ return sameOptionAndHint(other) &&
+ this.getGroup().equals(other.getGroup()) &&
+ this.mapOfParameters.equals(other.mapOfParameters);
}
public void clearParameters(){
@@ -407,9 +404,9 @@
* @see org.teiid.query.sql.lang.ProcedureContainer#getProcedureParameters()
* @since 5.0
*/
- public Map getProcedureParameters() {
+ public LinkedHashMap<ElementSymbol, Expression> getProcedureParameters() {
- HashMap map = new HashMap();
+ LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
for (Iterator iter = this.getInputParameters().iterator(); iter.hasNext();) {
SPParameter element = (SPParameter)iter.next();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,10 +22,9 @@
package org.teiid.query.sql.lang;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
@@ -259,14 +258,13 @@
* @see org.teiid.query.sql.lang.ProcedureContainer#getProcedureParameters()
* @since 5.0
*/
- public Map getProcedureParameters() {
+ public LinkedHashMap<ElementSymbol, Expression> getProcedureParameters() {
- HashMap map = new HashMap();
+ LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
for (Iterator iter = getChangeList().getClauses().iterator(); iter.hasNext();) {
SetClause setClause = (SetClause)iter.next();
ElementSymbol symbol = (ElementSymbol)(setClause.getSymbol()).clone();
- symbol = (ElementSymbol)(setClause.getSymbol()).clone();
symbol.setName(ProcedureReservedWords.INPUTS + SingleElementSymbol.SEPARATOR + symbol.getShortCanonicalName());
map.put( symbol, setClause.getValue() );
} // for
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -32,6 +32,7 @@
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -185,9 +186,11 @@
if(! (obj instanceof CreateUpdateProcedureCommand)) {
return false;
}
+
+ CreateUpdateProcedureCommand other = (CreateUpdateProcedureCommand)obj;
// Compare the block
- return EquivalenceUtil.areEqual(getBlock(), ((CreateUpdateProcedureCommand)obj).getBlock());
+ return sameOptionAndHint(other) && EquivalenceUtil.areEqual(getBlock(), other.getBlock());
}
/**
@@ -279,7 +282,7 @@
if(isUpdateProcedure()){
return false;
}
- return true;
+ return Query.areResultsCachable(getProjectedSymbols());
}
public GroupSymbol getVirtualGroup() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -24,11 +24,9 @@
import static org.teiid.language.SQLConstants.Reserved.*;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import org.teiid.core.types.DataTypeManager;
@@ -128,8 +126,9 @@
import org.teiid.translator.SourceSystemFunctions;
/**
- * <p>The SQLStringVisitor will visit a set of language objects and return the
- * corresponding SQL string representation. </p>
+ * <p>
+ * The SQLStringVisitor will visit a set of language objects and return the corresponding SQL string representation.
+ * </p>
*/
public class SQLStringVisitor extends LanguageVisitor {
@@ -138,1099 +137,1010 @@
private static final String BEGIN_HINT = "/*+"; //$NON-NLS-1$
private static final String END_HINT = "*/"; //$NON-NLS-1$
private static final char ID_ESCAPE_CHAR = '\"';
-
- private LinkedList<Object> parts = new LinkedList<Object>();
+ protected StringBuilder parts = new StringBuilder();
+
/**
* Helper to quickly get the parser string for an object using the visitor.
+ *
* @param obj Language object
* @return String SQL String for obj
*/
- public static final String getSQLString(LanguageObject obj) {
- if(obj == null) {
- return UNDEFINED;
+ public static final String getSQLString( LanguageObject obj ) {
+ if (obj == null) {
+ return UNDEFINED;
}
- SQLStringVisitor visitor = new SQLStringVisitor();
+ SQLStringVisitor visitor = new SQLStringVisitor();
obj.acceptVisitor(visitor);
- return visitor.getSQLString();
+ return visitor.getSQLString();
}
/**
* Retrieve completed string from the visitor.
+ *
* @return Complete SQL string for the visited nodes
*/
public String getSQLString() {
- StringBuilder output = new StringBuilder();
- getSQLString(this.parts, output);
- return output.toString();
+ return this.parts.toString();
}
-
- public static void getSQLString(List<Object> parts, StringBuilder output) {
- for (Object object : parts) {
- if (object instanceof List) {
- getSQLString((List<Object>)object, output);
- } else {
- output.append(object);
- }
- }
- }
-
- public List<Object> registerNode(LanguageObject obj) {
+
+ protected void visitNode( LanguageObject obj ) {
if (obj == null) {
- return Arrays.asList((Object)UNDEFINED);
+ append(UNDEFINED);
+ return;
}
- SQLStringVisitor visitor = new SQLStringVisitor();
- obj.acceptVisitor(visitor);
- return visitor.parts;
+ obj.acceptVisitor(this);
}
-
- public void replaceStringParts(Object[] parts) {
- for (int i = 0; i < parts.length; i++) {
- this.parts.add(parts[i]);
- }
+
+ protected void append( Object value ) {
+ this.parts.append(value);
}
+ protected void beginClause( @SuppressWarnings("unused") int level ) {
+ append(SPACE);
+ }
+
// ############ Visitor methods for language objects ####################
- public void visit(BetweenCriteria obj) {
- parts.add(registerNode(obj.getExpression()));
- parts.add(SPACE);
-
+ public void visit( BetweenCriteria obj ) {
+ visitNode(obj.getExpression());
+ append(SPACE);
+
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(BETWEEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getLowerExpression()));
+ append(BETWEEN);
+ append(SPACE);
+ visitNode(obj.getLowerExpression());
- parts.add(SPACE);
- parts.add(AND);
- parts.add(SPACE);
- parts.add(registerNode(obj.getUpperExpression()));
+ append(SPACE);
+ append(AND);
+ append(SPACE);
+ visitNode(obj.getUpperExpression());
}
- public void visit(CaseExpression obj) {
- parts.add(CASE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getExpression()) );
- parts.add(SPACE);
+ public void visit( CaseExpression obj ) {
+ append(CASE);
+ append(SPACE);
+ visitNode(obj.getExpression());
+ append(SPACE);
for (int i = 0; i < obj.getWhenCount(); i++) {
- parts.add(WHEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getWhenExpression(i)) );
- parts.add(SPACE);
- parts.add(THEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getThenExpression(i)));
- parts.add(SPACE);
+ append(WHEN);
+ append(SPACE);
+ visitNode(obj.getWhenExpression(i));
+ append(SPACE);
+ append(THEN);
+ append(SPACE);
+ visitNode(obj.getThenExpression(i));
+ append(SPACE);
}
if (obj.getElseExpression() != null) {
- parts.add(ELSE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getElseExpression()));
- parts.add(SPACE);
+ append(ELSE);
+ append(SPACE);
+ visitNode(obj.getElseExpression());
+ append(SPACE);
}
- parts.add(END);
+ append(END);
}
- public void visit(CompareCriteria obj) {
+ public void visit( CompareCriteria obj ) {
Expression leftExpression = obj.getLeftExpression();
- Object leftPart = registerNode(leftExpression);
-
- String operator = obj.getOperatorAsString();
-
+ visitNode(leftExpression);
+ append(SPACE);
+ append(obj.getOperatorAsString());
+ append(SPACE);
Expression rightExpression = obj.getRightExpression();
- Object rightPart = registerNode(rightExpression);
-
- replaceStringParts(new Object[] { leftPart, SPACE, operator, SPACE, rightPart });
+ visitNode(rightExpression);
}
- public void visit(CompoundCriteria obj) {
+ public void visit( CompoundCriteria obj ) {
// Get operator string
int operator = obj.getOperator();
String operatorStr = ""; //$NON-NLS-1$
- if(operator == CompoundCriteria.AND) {
+ if (operator == CompoundCriteria.AND) {
operatorStr = AND;
- } else if(operator == CompoundCriteria.OR) {
+ } else if (operator == CompoundCriteria.OR) {
operatorStr = OR;
}
// Get criteria
- List subCriteria = obj.getCriteria();
+ List<Criteria> subCriteria = obj.getCriteria();
// Build parts
- if(subCriteria.size() == 1) {
+ if (subCriteria.size() == 1) {
// Special case - should really never happen, but we are tolerant
- Criteria firstChild = (Criteria) subCriteria.get(0);
- replaceStringParts(new Object[] { registerNode(firstChild) });
+ Criteria firstChild = subCriteria.get(0);
+ visitNode(firstChild);
} else {
- // Magic formula - suppose you have 2 sub criteria, then the string
- // has parts: (|x|)| |AND| |(|y|)
- // Each sub criteria has 3 parts and each connector has 3 parts
- // Number of connectors = number of sub criteria - 1
- // # parts = 3n + 3c ; c=n-1
- // = 3n + 3(n-1)
- // = 6n - 3
- Object[] parts = new Object[(6*subCriteria.size())-3];
-
// Add first criteria
- Iterator iter = subCriteria.iterator();
- Criteria crit = (Criteria) iter.next();
- parts[0] = "("; //$NON-NLS-1$
- parts[1] = registerNode(crit);
- parts[2] = ")"; //$NON-NLS-1$
+ Iterator<Criteria> iter = subCriteria.iterator();
- // Add rest of the criteria
- for(int i=3; iter.hasNext(); i=i+6) {
- // Add connector
- parts[i] = SPACE;
- parts[i+1] = operatorStr;
- parts[i+2] = SPACE;
-
+ while (iter.hasNext()) {
// Add criteria
- crit = (Criteria) iter.next();
- parts[i+3] = "("; //$NON-NLS-1$
- parts[i+4] = registerNode(crit);
- parts[i+5] = ")"; //$NON-NLS-1$
- }
+ Criteria crit = iter.next();
+ append(Tokens.LPAREN);
+ visitNode(crit);
+ append(Tokens.RPAREN);
- replaceStringParts(parts);
+ if (iter.hasNext()) {
+ // Add connector
+ append(SPACE);
+ append(operatorStr);
+ append(SPACE);
+ }
+ }
}
}
- public void visit(Delete obj) {
- //add delete clause
- parts.add(DELETE);
- parts.add(SPACE);
- //add from clause
- parts.add(FROM);
- parts.add(SPACE);
- parts.add(registerNode(obj.getGroup()));
+ public void visit( Delete obj ) {
+ // add delete clause
+ append(DELETE);
+ append(SPACE);
+ // add from clause
+ append(FROM);
+ append(SPACE);
+ visitNode(obj.getGroup());
- //add where clause
- if(obj.getCriteria() != null) {
- parts.add(SPACE);
- parts.add(WHERE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getCriteria()));
- }
+ // add where clause
+ if (obj.getCriteria() != null) {
+ beginClause(0);
+ visitCriteria(WHERE, obj.getCriteria());
+ }
- // Option clause
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
- }
+ // Option clause
+ if (obj.getOption() != null) {
+ beginClause(0);
+ visitNode(obj.getOption());
+ }
}
-
- public void visit(DependentSetCriteria obj) {
- parts.add(registerNode(obj.getExpression()));
+ public void visit( DependentSetCriteria obj ) {
+ visitNode(obj.getExpression());
+
// operator and beginning of list
- parts.add(SPACE);
+ append(SPACE);
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(IN);
- parts.add(" (<dependent values>)"); //$NON-NLS-1$
+ append(IN);
+ append(" (<dependent values>)"); //$NON-NLS-1$
}
- public void visit(From obj) {
- Object[] parts = null;
- List clauses = obj.getClauses();
- if(clauses.size() == 1) {
- replaceStringParts(new Object[] {
- FROM, SPACE,
- registerNode( (FromClause) clauses.get(0) ) });
- } else if(clauses.size() > 1) {
- parts = new Object[2 + clauses.size() + (clauses.size()-1)];
+ public void visit( From obj ) {
+ append(FROM);
+ beginClause(1);
+ registerNodes(obj.getClauses(), 0);
+ }
- // Add first clause
- parts[0] = FROM;
- parts[1] = SPACE;
- Iterator clauseIter = clauses.iterator();
- parts[2] = registerNode((FromClause) clauseIter.next());
-
- // Add rest of the clauses
- for(int i=3; clauseIter.hasNext(); i=i+2) {
- parts[i] = ", "; //$NON-NLS-1$
- parts[i+1] = registerNode((FromClause) clauseIter.next());
- }
-
- replaceStringParts(parts);
- } else {
- // Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { FROM });
- }
+ public void visit( GroupBy obj ) {
+ append(GROUP);
+ append(SPACE);
+ append(BY);
+ append(SPACE);
+ registerNodes(obj.getSymbols(), 0);
}
- public void visit(GroupBy obj) {
- Object[] parts = null;
- List symbols = obj.getSymbols();
- if(symbols.size() == 1) {
- replaceStringParts(new Object[] {
- GROUP, SPACE, BY, SPACE,
- registerNode( (Expression) symbols.get(0) ) });
- } else if(symbols.size() > 1) {
- parts = new Object[4 + symbols.size() + (symbols.size()-1)];
+ public void visit( Insert obj ) {
+ append(INSERT);
+ append(SPACE);
+ append(INTO);
+ append(SPACE);
+ visitNode(obj.getGroup());
- // Add first clause
- parts[0] = GROUP;
- parts[1] = SPACE;
- parts[2] = BY;
- parts[3] = SPACE;
- Iterator symbolIter = symbols.iterator();
- parts[4] = registerNode((Expression) symbolIter.next());
+ if (!obj.getVariables().isEmpty()) {
+ beginClause(2);
- // Add rest of the clauses
- for(int i=5; symbolIter.hasNext(); i=i+2) {
- parts[i] = ", "; //$NON-NLS-1$
- parts[i+1] = registerNode((Expression) symbolIter.next());
+ // Columns clause
+ List vars = obj.getVariables();
+ if (vars != null) {
+ append("("); //$NON-NLS-1$
+ registerNodes(vars, 0);
+ append(")"); //$NON-NLS-1$
}
-
- replaceStringParts(parts);
- } else {
- // Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { GROUP, SPACE, BY });
}
- }
-
- public void visit(Insert obj) {
- formatBasicInsert(obj);
-
- if ( obj.getQueryExpression() != null ) {
- parts.add(registerNode(obj.getQueryExpression()));
+ beginClause(1);
+ if (obj.getQueryExpression() != null) {
+ visitNode(obj.getQueryExpression());
} else if (obj.getTupleSource() != null) {
- parts.add(VALUES);
- parts.add(" (...)"); //$NON-NLS-1$
- } else {
- parts.add(VALUES);
- parts.add(" ("); //$NON-NLS-1$
- Iterator valueIter = obj.getValues().iterator();
- while(valueIter.hasNext()) {
- Expression valObj = (Expression) valueIter.next();
- parts.add(registerNode(valObj));
- if(valueIter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
- }
- parts.add(")"); //$NON-NLS-1$
+ append(VALUES);
+ append(" (...)"); //$NON-NLS-1$
+ } else if (obj.getValues() != null) {
+ append(VALUES);
+ beginClause(2);
+ append("("); //$NON-NLS-1$
+ registerNodes(obj.getValues(), 0);
+ append(")"); //$NON-NLS-1$
}
-
- // Option clause
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
- }
+
+ // Option clause
+ if (obj.getOption() != null) {
+ beginClause(1);
+ visitNode(obj.getOption());
+ }
}
- public void visit(Create obj) {
- parts.add(CREATE);
- parts.add(SPACE);
- parts.add(LOCAL);
- parts.add(SPACE);
- parts.add(TEMPORARY);
- parts.add(SPACE);
- parts.add(TABLE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getTable()));
- parts.add(SPACE);
+ public void visit( Create obj ) {
+ append(CREATE);
+ append(SPACE);
+ append(LOCAL);
+ append(SPACE);
+ append(TEMPORARY);
+ append(SPACE);
+ append(TABLE);
+ append(SPACE);
+ visitNode(obj.getTable());
+ append(SPACE);
// Columns clause
List<ElementSymbol> columns = obj.getColumns();
- parts.add("("); //$NON-NLS-1$
+ append("("); //$NON-NLS-1$
Iterator<ElementSymbol> iter = columns.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext()) {
ElementSymbol element = iter.next();
outputShortName(element);
- parts.add(SPACE);
- parts.add(DataTypeManager.getDataTypeName(element.getType()));
- if(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
+ append(SPACE);
+ append(DataTypeManager.getDataTypeName(element.getType()));
+ if (iter.hasNext()) {
+ append(", "); //$NON-NLS-1$
}
}
if (!obj.getPrimaryKey().isEmpty()) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(PRIMARY);
- parts.add(" "); //$NON-NLS-1$
- parts.add(NonReserved.KEY);
- parts.add(Tokens.LPAREN);
- iter = obj.getPrimaryKey().iterator();
- while(iter.hasNext()) {
- outputShortName(iter.next());
- if (iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
- }
- parts.add(Tokens.RPAREN);
- }
- parts.add(")"); //$NON-NLS-1$
- }
-
- public void visit(Drop obj) {
- parts.add(DROP);
- parts.add(SPACE);
- parts.add(TABLE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getTable()));
- }
-
- private void formatBasicInsert(Insert obj) {
- parts.add(INSERT);
- parts.add(SPACE);
- parts.add(INTO);
- parts.add(SPACE);
- parts.add(registerNode(obj.getGroup()));
- parts.add(SPACE);
-
- if (!obj.getVariables().isEmpty()) {
-
- // Columns clause
- List vars = obj.getVariables();
- if(vars != null) {
- parts.add("("); //$NON-NLS-1$
- Iterator iter = vars.iterator();
- while(iter.hasNext()) {
- ElementSymbol element = (ElementSymbol) iter.next();
- parts.add(registerNode(element));
- if(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
+ append(", "); //$NON-NLS-1$
+ append(PRIMARY);
+ append(" "); //$NON-NLS-1$
+ append(NonReserved.KEY);
+ append(Tokens.LPAREN);
+ iter = obj.getPrimaryKey().iterator();
+ while (iter.hasNext()) {
+ outputShortName(iter.next());
+ if (iter.hasNext()) {
+ append(", "); //$NON-NLS-1$
}
- parts.add(") "); //$NON-NLS-1$
}
+ append(Tokens.RPAREN);
}
+ append(")"); //$NON-NLS-1$
}
- public void visit(IsNullCriteria obj) {
+ public void visit( Drop obj ) {
+ append(DROP);
+ append(SPACE);
+ append(TABLE);
+ append(SPACE);
+ visitNode(obj.getTable());
+ }
+
+ public void visit( IsNullCriteria obj ) {
Expression expr = obj.getExpression();
- Object exprPart = registerNode(expr);
- parts.add(exprPart);
- parts.add(SPACE);
- parts.add(IS);
- parts.add(SPACE);
+ visitNode(expr);
+ append(SPACE);
+ append(IS);
+ append(SPACE);
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(NULL);
+ append(NULL);
}
- public void visit(JoinPredicate obj) {
+ public void visit( JoinPredicate obj ) {
addOptionComment(obj);
-
- if(obj.hasHint()) {
- parts.add("(");//$NON-NLS-1$
+
+ if (obj.hasHint()) {
+ append("(");//$NON-NLS-1$
}
// left clause
FromClause leftClause = obj.getLeftClause();
- if(leftClause instanceof JoinPredicate && !((JoinPredicate)leftClause).hasHint()) {
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(leftClause));
- parts.add(")"); //$NON-NLS-1$
- } else {
- parts.add(registerNode(leftClause));
- }
+ if (leftClause instanceof JoinPredicate && !((JoinPredicate)leftClause).hasHint()) {
+ append("("); //$NON-NLS-1$
+ visitNode(leftClause);
+ append(")"); //$NON-NLS-1$
+ } else {
+ visitNode(leftClause);
+ }
// join type
- parts.add(SPACE);
- parts.add(registerNode(obj.getJoinType()));
- parts.add(SPACE);
+ append(SPACE);
+ visitNode(obj.getJoinType());
+ append(SPACE);
// right clause
FromClause rightClause = obj.getRightClause();
- if(rightClause instanceof JoinPredicate && !((JoinPredicate)rightClause).hasHint()) {
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(rightClause));
- parts.add(")"); //$NON-NLS-1$
- } else {
- parts.add(registerNode(rightClause));
- }
+ if (rightClause instanceof JoinPredicate && !((JoinPredicate)rightClause).hasHint()) {
+ append("("); //$NON-NLS-1$
+ visitNode(rightClause);
+ append(")"); //$NON-NLS-1$
+ } else {
+ visitNode(rightClause);
+ }
// join criteria
List joinCriteria = obj.getJoinCriteria();
- if(joinCriteria != null && joinCriteria.size() > 0) {
- parts.add(SPACE);
- parts.add(ON);
- parts.add(SPACE);
- Iterator critIter = joinCriteria.iterator();
- while(critIter.hasNext()) {
- Criteria crit = (Criteria) critIter.next();
- if(crit instanceof PredicateCriteria || crit instanceof AtomicCriteria) {
- parts.add(registerNode(crit));
+ if (joinCriteria != null && joinCriteria.size() > 0) {
+ append(SPACE);
+ append(ON);
+ append(SPACE);
+ Iterator critIter = joinCriteria.iterator();
+ while (critIter.hasNext()) {
+ Criteria crit = (Criteria)critIter.next();
+ if (crit instanceof PredicateCriteria || crit instanceof AtomicCriteria) {
+ visitNode(crit);
} else {
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(crit));
- parts.add(")"); //$NON-NLS-1$
+ append("("); //$NON-NLS-1$
+ visitNode(crit);
+ append(")"); //$NON-NLS-1$
}
- if(critIter.hasNext()) {
- parts.add(SPACE);
- parts.add(AND);
- parts.add(SPACE);
- }
- }
- }
+ if (critIter.hasNext()) {
+ append(SPACE);
+ append(AND);
+ append(SPACE);
+ }
+ }
+ }
- if(obj.hasHint()) {
- parts.add(")"); //$NON-NLS-1$
+ if (obj.hasHint()) {
+ append(")"); //$NON-NLS-1$
}
addFromClasueDepOptions(obj);
}
- private void addFromClasueDepOptions(FromClause obj) {
+ private void addFromClasueDepOptions( FromClause obj ) {
if (obj.isMakeDep()) {
- parts.add(SPACE);
- parts.add(Option.MAKEDEP);
+ append(SPACE);
+ append(Option.MAKEDEP);
}
if (obj.isMakeNotDep()) {
- parts.add(SPACE);
- parts.add(Option.MAKENOTDEP);
+ append(SPACE);
+ append(Option.MAKENOTDEP);
}
}
- private void addOptionComment(FromClause obj) {
- if (obj.isOptional()) {
- parts.add(BEGIN_HINT);
- parts.add(SPACE);
- parts.add(Option.OPTIONAL);
- parts.add(SPACE);
- parts.add(END_HINT);
- parts.add(SPACE);
- }
+ private void addOptionComment( FromClause obj ) {
+ if (obj.isOptional()) {
+ append(BEGIN_HINT);
+ append(SPACE);
+ append(Option.OPTIONAL);
+ append(SPACE);
+ append(END_HINT);
+ append(SPACE);
+ }
}
- public void visit(JoinType obj) {
- Object[] parts = null;
- if(obj.equals(JoinType.JOIN_INNER)) {
- parts = new Object[] { INNER, SPACE, JOIN };
- } else if(obj.equals(JoinType.JOIN_CROSS)) {
- parts = new Object[] { CROSS, SPACE, JOIN };
- } else if(obj.equals(JoinType.JOIN_LEFT_OUTER)) {
- parts = new Object[] { LEFT, SPACE, OUTER, SPACE, JOIN };
- } else if(obj.equals(JoinType.JOIN_RIGHT_OUTER)) {
- parts = new Object[] { RIGHT, SPACE, OUTER, SPACE, JOIN };
- } else if(obj.equals(JoinType.JOIN_FULL_OUTER)) {
- parts = new Object[] { FULL, SPACE, OUTER, SPACE, JOIN };
- } else if(obj.equals(JoinType.JOIN_UNION)) {
- parts = new Object[] { UNION, SPACE, JOIN };
+ public void visit( JoinType obj ) {
+ String[] output = null;
+ if (obj.equals(JoinType.JOIN_INNER)) {
+ output = new String[] {INNER, SPACE, JOIN};
+ } else if (obj.equals(JoinType.JOIN_CROSS)) {
+ output = new String[] {CROSS, SPACE, JOIN};
+ } else if (obj.equals(JoinType.JOIN_LEFT_OUTER)) {
+ output = new String[] {LEFT, SPACE, OUTER, SPACE, JOIN};
+ } else if (obj.equals(JoinType.JOIN_RIGHT_OUTER)) {
+ output = new String[] {RIGHT, SPACE, OUTER, SPACE, JOIN};
+ } else if (obj.equals(JoinType.JOIN_FULL_OUTER)) {
+ output = new String[] {FULL, SPACE, OUTER, SPACE, JOIN};
+ } else if (obj.equals(JoinType.JOIN_UNION)) {
+ output = new String[] {UNION, SPACE, JOIN};
} else if (obj.equals(JoinType.JOIN_SEMI)) {
- parts = new Object[] { "SEMI", SPACE, JOIN }; //$NON-NLS-1$
+ output = new String[] {"SEMI", SPACE, JOIN}; //$NON-NLS-1$
} else if (obj.equals(JoinType.JOIN_ANTI_SEMI)) {
- parts = new Object[] { "ANTI SEMI", SPACE, JOIN }; //$NON-NLS-1$
+ output = new String[] {"ANTI SEMI", SPACE, JOIN}; //$NON-NLS-1$
+ } else {
+ throw new AssertionError();
}
-
- replaceStringParts(parts);
+ for (String part : output) {
+ append(part);
+ }
}
- public void visit(MatchCriteria obj) {
- parts.add(registerNode(obj.getLeftExpression()));
+ public void visit( MatchCriteria obj ) {
+ visitNode(obj.getLeftExpression());
- parts.add(SPACE);
+ append(SPACE);
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(LIKE);
- parts.add(SPACE);
+ append(LIKE);
+ append(SPACE);
- parts.add(registerNode(obj.getRightExpression()));
+ visitNode(obj.getRightExpression());
- if(obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
- parts.add(SPACE);
- parts.add(ESCAPE);
- parts.add(" '"); //$NON-NLS-1$
- parts.add("" + obj.getEscapeChar()); //$NON-NLS-1$
- parts.add("'"); //$NON-NLS-1$
+ if (obj.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
+ append(SPACE);
+ append(ESCAPE);
+ append(" '"); //$NON-NLS-1$
+ append("" + obj.getEscapeChar()); //$NON-NLS-1$
+ append("'"); //$NON-NLS-1$
}
}
- public void visit(NotCriteria obj) {
- parts.add(NOT);
- parts.add(" ("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCriteria()));
- parts.add(")"); //$NON-NLS-1$
+ public void visit( NotCriteria obj ) {
+ append(NOT);
+ append(" ("); //$NON-NLS-1$
+ visitNode(obj.getCriteria());
+ append(")"); //$NON-NLS-1$
}
- public void visit(Option obj) {
- parts.add(OPTION);
+ public void visit( Option obj ) {
+ append(OPTION);
Collection groups = obj.getDependentGroups();
- if(groups != null && groups.size() > 0) {
- parts.add(" "); //$NON-NLS-1$
- parts.add(MAKEDEP);
- parts.add(" "); //$NON-NLS-1$
+ if (groups != null && groups.size() > 0) {
+ append(" "); //$NON-NLS-1$
+ append(MAKEDEP);
+ append(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext()) {
outputDisplayName((String)iter.next());
-
+
if (iter.hasNext()) {
- parts.add(", ");
+ append(", ");
}
}
}
-
+
groups = obj.getNotDependentGroups();
- if(groups != null && groups.size() > 0) {
- parts.add(" "); //$NON-NLS-1$
- parts.add(MAKENOTDEP);
- parts.add(" "); //$NON-NLS-1$
+ if (groups != null && groups.size() > 0) {
+ append(" "); //$NON-NLS-1$
+ append(MAKENOTDEP);
+ append(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext()) {
outputDisplayName((String)iter.next());
-
+
if (iter.hasNext()) {
- parts.add(", ");
+ append(", ");
}
}
}
-
+
groups = obj.getNoCacheGroups();
- if(groups != null && groups.size() > 0) {
- parts.add(" "); //$NON-NLS-1$
- parts.add(NOCACHE);
- parts.add(" "); //$NON-NLS-1$
+ if (groups != null && groups.size() > 0) {
+ append(" "); //$NON-NLS-1$
+ append(NOCACHE);
+ append(" "); //$NON-NLS-1$
Iterator iter = groups.iterator();
- while(iter.hasNext()) {
+ while (iter.hasNext()) {
outputDisplayName((String)iter.next());
-
+
if (iter.hasNext()) {
- parts.add(", ");
+ append(", ");
}
}
- }else if(obj.isNoCache()){
- parts.add(" "); //$NON-NLS-1$
- parts.add(NOCACHE);
+ } else if (obj.isNoCache()) {
+ append(" "); //$NON-NLS-1$
+ append(NOCACHE);
}
}
- public void visit(OrderBy obj) {
- parts.add(ORDER);
- parts.add(SPACE);
- parts.add(BY);
- parts.add(SPACE);
- for (Iterator<OrderByItem> iterator = obj.getOrderByItems().iterator(); iterator.hasNext();) {
- OrderByItem item = iterator.next();
- parts.add(registerNode(item));
- if (iterator.hasNext()) {
- parts.add( ", " ); //$NON-NLS-1$
- }
- }
+ public void visit( OrderBy obj ) {
+ append(ORDER);
+ append(SPACE);
+ append(BY);
+ append(SPACE);
+ for (Iterator<OrderByItem> iterator = obj.getOrderByItems().iterator(); iterator.hasNext();) {
+ OrderByItem item = iterator.next();
+ visitNode(item);
+ if (iterator.hasNext()) {
+ append(", "); //$NON-NLS-1$
+ }
+ }
}
-
+
@Override
- public void visit(OrderByItem obj) {
- SingleElementSymbol ses = obj.getSymbol();
- if (ses instanceof AliasSymbol) {
- AliasSymbol as = (AliasSymbol)ses;
- outputDisplayName(as.getOutputName());
- } else {
- parts.add(registerNode(ses));
- }
- if(!obj.isAscending()) {
- parts.add(SPACE);
- parts.add(DESC);
+ public void visit( OrderByItem obj ) {
+ SingleElementSymbol ses = obj.getSymbol();
+ if (ses instanceof AliasSymbol) {
+ AliasSymbol as = (AliasSymbol)ses;
+ outputDisplayName(as.getOutputName());
+ } else {
+ visitNode(ses);
+ }
+ if (!obj.isAscending()) {
+ append(SPACE);
+ append(DESC);
} // Don't print default "ASC"
if (obj.getNullOrdering() != null) {
- parts.add(SPACE);
- parts.add(NonReserved.NULLS);
- parts.add(SPACE);
- parts.add(obj.getNullOrdering().name());
+ append(SPACE);
+ append(NonReserved.NULLS);
+ append(SPACE);
+ append(obj.getNullOrdering().name());
}
}
-
- public void visit(DynamicCommand obj) {
- parts.add(EXECUTE);
- parts.add(SPACE);
- parts.add(STRING);
- parts.add(SPACE);
- parts.add(registerNode(obj.getSql()));
- if(obj.isAsClauseSet()){
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
+ public void visit( DynamicCommand obj ) {
+ append(EXECUTE);
+ append(SPACE);
+ append(STRING);
+ append(SPACE);
+ visitNode(obj.getSql());
+
+ if (obj.isAsClauseSet()) {
+ beginClause(1);
+ append(AS);
+ append(SPACE);
for (int i = 0; i < obj.getAsColumns().size(); i++) {
ElementSymbol symbol = (ElementSymbol)obj.getAsColumns().get(i);
outputShortName(symbol);
- parts.add(SPACE);
- parts.add(DataTypeManager.getDataTypeName(symbol.getType()));
+ append(SPACE);
+ append(DataTypeManager.getDataTypeName(symbol.getType()));
if (i < obj.getAsColumns().size() - 1) {
- parts.add(", "); //$NON-NLS-1$
+ append(", "); //$NON-NLS-1$
}
}
}
- if(obj.getIntoGroup() != null){
- parts.add(SPACE);
- parts.add(INTO);
- parts.add(SPACE);
- parts.add(registerNode(obj.getIntoGroup()));
+ if (obj.getIntoGroup() != null) {
+ beginClause(1);
+ append(INTO);
+ append(SPACE);
+ visitNode(obj.getIntoGroup());
}
- if(obj.getUsing() != null && !obj.getUsing().isEmpty()) {
- parts.add(SPACE);
- parts.add(USING);
- parts.add(SPACE);
- parts.add(registerNode(obj.getUsing()));
+ if (obj.getUsing() != null && !obj.getUsing().isEmpty()) {
+ beginClause(1);
+ append(USING);
+ append(SPACE);
+ visitNode(obj.getUsing());
}
if (obj.getUpdatingModelCount() > 0) {
- parts.add(SPACE);
- parts.add(UPDATE);
- parts.add(SPACE);
+ beginClause(1);
+ append(UPDATE);
+ append(SPACE);
if (obj.getUpdatingModelCount() > 1) {
- parts.add("*"); //$NON-NLS-1$
+ append("*"); //$NON-NLS-1$
} else {
- parts.add("1"); //$NON-NLS-1$
+ append("1"); //$NON-NLS-1$
}
}
}
- public void visit(SetClauseList obj) {
- for (Iterator<SetClause> iterator = obj.getClauses().iterator(); iterator.hasNext();) {
- SetClause clause = iterator.next();
- parts.add(registerNode(clause));
+ public void visit( SetClauseList obj ) {
+ for (Iterator<SetClause> iterator = obj.getClauses().iterator(); iterator.hasNext();) {
+ SetClause clause = iterator.next();
+ visitNode(clause);
if (iterator.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
+ append(", "); //$NON-NLS-1$
}
- }
+ }
}
-
- public void visit(SetClause obj) {
+
+ public void visit( SetClause obj ) {
ElementSymbol symbol = obj.getSymbol();
outputShortName(symbol);
- parts.add(" = "); //$NON-NLS-1$
- parts.add(registerNode(obj.getValue()));
+ append(" = "); //$NON-NLS-1$
+ visitNode(obj.getValue());
}
- public void visit(Query obj) {
- addCacheHint(obj.getCacheHint());
- parts.add(registerNode(obj.getSelect()));
+ public void visit( Query obj ) {
+ addCacheHint(obj.getCacheHint());
+ visitNode(obj.getSelect());
- if(obj.getInto() != null){
- parts.add(SPACE);
- parts.add(INTO);
- parts.add(SPACE);
- parts.add(registerNode(obj.getInto()));
+ if (obj.getInto() != null) {
+ beginClause(1);
+ visitNode(obj.getInto());
}
- if(obj.getFrom() != null){
- parts.add(SPACE);
- parts.add(registerNode(obj.getFrom()));
+ if (obj.getFrom() != null) {
+ beginClause(1);
+ visitNode(obj.getFrom());
}
// Where clause
- if(obj.getCriteria() != null) {
- parts.add(SPACE);
- parts.add(WHERE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getCriteria()));
+ if (obj.getCriteria() != null) {
+ beginClause(1);
+ visitCriteria(WHERE, obj.getCriteria());
}
- // Group by clause
- if(obj.getGroupBy() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getGroupBy()));
+ // Group by clause
+ if (obj.getGroupBy() != null) {
+ beginClause(1);
+ visitNode(obj.getGroupBy());
}
- // Having clause
- if(obj.getHaving() != null) {
- parts.add(SPACE);
- parts.add(HAVING);
- parts.add(SPACE);
- parts.add(registerNode(obj.getHaving()));
- }
+ // Having clause
+ if (obj.getHaving() != null) {
+ beginClause(1);
+ visitCriteria(HAVING, obj.getHaving());
+ }
- // Order by clause
- if(obj.getOrderBy() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOrderBy()));
- }
-
+ // Order by clause
+ if (obj.getOrderBy() != null) {
+ beginClause(1);
+ visitNode(obj.getOrderBy());
+ }
+
if (obj.getLimit() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getLimit()));
+ beginClause(1);
+ visitNode(obj.getLimit());
}
- // Option clause
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
- }
+ // Option clause
+ if (obj.getOption() != null) {
+ beginClause(1);
+ visitNode(obj.getOption());
+ }
}
- public void visit(SearchedCaseExpression obj) {
- parts.add(CASE);
+ protected void visitCriteria( String keyWord,
+ Criteria crit ) {
+ append(keyWord);
+ append(SPACE);
+ visitNode(crit);
+ }
+
+ public void visit( SearchedCaseExpression obj ) {
+ append(CASE);
for (int i = 0; i < obj.getWhenCount(); i++) {
- parts.add(SPACE);
- parts.add(WHEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getWhenCriteria(i)));
- parts.add(SPACE);
- parts.add(THEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getThenExpression(i)));
+ append(SPACE);
+ append(WHEN);
+ append(SPACE);
+ visitNode(obj.getWhenCriteria(i));
+ append(SPACE);
+ append(THEN);
+ append(SPACE);
+ visitNode(obj.getThenExpression(i));
}
- parts.add(SPACE);
+ append(SPACE);
if (obj.getElseExpression() != null) {
- parts.add(ELSE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getElseExpression()));
- parts.add(SPACE);
+ append(ELSE);
+ append(SPACE);
+ visitNode(obj.getElseExpression());
+ append(SPACE);
}
- parts.add(END);
+ append(END);
}
- public void visit(Select obj) {
- parts.add(SELECT);
- parts.add(SPACE);
+ public void visit( Select obj ) {
+ append(SELECT);
+ if (obj.isDistinct()) {
+ append(SPACE);
+ append(DISTINCT);
+ }
+ beginClause(2);
- if(obj.isDistinct()) {
- parts.add(DISTINCT);
- parts.add(SPACE);
- }
-
- Iterator iter = obj.getSymbols().iterator();
- while( iter.hasNext() ) {
- SelectSymbol symbol = (SelectSymbol) iter.next();
- parts.add(registerNode(symbol));
- if(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
+ Iterator iter = obj.getSymbols().iterator();
+ while (iter.hasNext()) {
+ SelectSymbol symbol = (SelectSymbol)iter.next();
+ visitNode(symbol);
+ if (iter.hasNext()) {
+ append(", "); //$NON-NLS-1$
+ }
}
}
- public void visit(SetCriteria obj) {
- // variable
- parts.add(registerNode(obj.getExpression()));
+ public void visit( SetCriteria obj ) {
+ // variable
+ visitNode(obj.getExpression());
- // operator and beginning of list
- parts.add(SPACE);
+ // operator and beginning of list
+ append(SPACE);
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(IN);
- parts.add(" ("); //$NON-NLS-1$
+ append(IN);
+ append(" ("); //$NON-NLS-1$
- // value list
- Collection vals = obj.getValues();
- int size = vals.size();
- if(size == 1) {
- Iterator iter = vals.iterator();
- Expression expr = (Expression) iter.next();
- parts.add( registerNode( expr ) );
- } else if(size > 1) {
- Iterator iter = vals.iterator();
- Expression expr = (Expression) iter.next();
- parts.add( registerNode( expr ) );
- while(iter.hasNext()) {
- expr = (Expression) iter.next();
- parts.add(", "); //$NON-NLS-1$
- parts.add( registerNode( expr ) );
- }
- }
- parts.add(")"); //$NON-NLS-1$
+ // value list
+ Collection vals = obj.getValues();
+ int size = vals.size();
+ if (size == 1) {
+ Iterator iter = vals.iterator();
+ Expression expr = (Expression)iter.next();
+ visitNode(expr);
+ } else if (size > 1) {
+ Iterator iter = vals.iterator();
+ Expression expr = (Expression)iter.next();
+ visitNode(expr);
+ while (iter.hasNext()) {
+ expr = (Expression)iter.next();
+ append(", "); //$NON-NLS-1$
+ visitNode(expr);
+ }
+ }
+ append(")"); //$NON-NLS-1$
}
- public void visit(SetQuery obj) {
- addCacheHint(obj.getCacheHint());
+ public void visit( SetQuery obj ) {
+ addCacheHint(obj.getCacheHint());
QueryCommand query = obj.getLeftQuery();
- if(query instanceof Query) {
- parts.add(registerNode(query));
- } else {
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(query));
- parts.add(")"); //$NON-NLS-1$
- }
+ appendSetQuery(obj, query, false);
- parts.add(SPACE);
- parts.add(obj.getOperation());
- parts.add(SPACE);
+ beginClause(0);
+ append(obj.getOperation());
- if(obj.isAll()) {
- parts.add(ALL);
- parts.add(SPACE);
+ if (obj.isAll()) {
+ append(SPACE);
+ append(ALL);
}
-
+ beginClause(0);
query = obj.getRightQuery();
- if(query instanceof Query) {
- parts.add(registerNode(query));
- } else {
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(query));
- parts.add(")"); //$NON-NLS-1$
+ appendSetQuery(obj, query, true);
+
+ if (obj.getOrderBy() != null) {
+ beginClause(0);
+ visitNode(obj.getOrderBy());
}
- if(obj.getOrderBy() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOrderBy()));
+ if (obj.getLimit() != null) {
+ beginClause(0);
+ visitNode(obj.getLimit());
}
- if(obj.getLimit() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getLimit()));
+ if (obj.getOption() != null) {
+ beginClause(0);
+ visitNode(obj.getOption());
}
+ }
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
+ protected void appendSetQuery( SetQuery parent,
+ QueryCommand obj,
+ boolean right ) {
+ if (right && obj instanceof SetQuery
+ && ((parent.isAll() && !((SetQuery)obj).isAll()) || parent.getOperation() != ((SetQuery)obj).getOperation())) {
+ append(Tokens.LPAREN);
+ visitNode(obj);
+ append(Tokens.RPAREN);
+ } else {
+ visitNode(obj);
}
}
- public void visit(StoredProcedure obj) {
- addCacheHint(obj.getCacheHint());
- //exec clause
- parts.add(EXEC);
- parts.add(SPACE);
- parts.add(obj.getProcedureName());
- parts.add("("); //$NON-NLS-1$
- List params = obj.getInputParameters();
- if(params != null) {
+ public void visit( StoredProcedure obj ) {
+ addCacheHint(obj.getCacheHint());
+ // exec clause
+ append(EXEC);
+ append(SPACE);
+ append(obj.getProcedureName());
+ append("("); //$NON-NLS-1$
+ List params = obj.getInputParameters();
+ if (params != null) {
Iterator iter = params.iterator();
- while(iter.hasNext()) {
- SPParameter param = (SPParameter) iter.next();
-
- if (obj.displayNamedParameters()) {
- parts.add(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
- parts.add(" => "); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ SPParameter param = (SPParameter)iter.next();
+
+ if (obj.displayNamedParameters()) {
+ append(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
+ append(" => "); //$NON-NLS-1$
}
-
- if(param.getExpression() == null) {
- if(param.getName() != null) {
- outputDisplayName(obj.getParamFullName(param));
+
+ if (param.getExpression() == null) {
+ if (param.getName() != null) {
+ outputDisplayName(obj.getParamFullName(param));
} else {
- parts.add("?"); //$NON-NLS-1$
+ append("?"); //$NON-NLS-1$
}
} else {
- boolean addParens = !obj.displayNamedParameters() && param.getExpression() instanceof CompareCriteria;
- if (addParens) {
- parts.add(Tokens.LPAREN);
- }
- parts.add(registerNode(param.getExpression()));
+ boolean addParens = !obj.displayNamedParameters() && param.getExpression() instanceof CompareCriteria;
if (addParens) {
- parts.add(Tokens.RPAREN);
- }
+ append(Tokens.LPAREN);
+ }
+ visitNode(param.getExpression());
+ if (addParens) {
+ append(Tokens.RPAREN);
+ }
}
- if(iter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
+ if (iter.hasNext()) {
+ append(", "); //$NON-NLS-1$
}
}
}
- parts.add(")"); //$NON-NLS-1$
+ append(")"); //$NON-NLS-1$
// Option clause
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
- }else{
- parts.add(""); //$NON-NLS-1$
- }
+ if (obj.getOption() != null) {
+ beginClause(1);
+ visitNode(obj.getOption());
+ }
}
- public void addCacheHint(CacheHint obj) {
- if (obj == null) {
- return;
- }
- parts.add(BEGIN_HINT);
- parts.add(SPACE);
- parts.add(CacheHint.CACHE);
+ public void addCacheHint( CacheHint obj ) {
+ if (obj == null) {
+ return;
+ }
+ append(BEGIN_HINT);
+ append(SPACE);
+ append(CacheHint.CACHE);
boolean addParens = false;
if (obj.getPrefersMemory()) {
- parts.add(Tokens.LPAREN);
- addParens = true;
- parts.add(CacheHint.PREF_MEM);
+ append(Tokens.LPAREN);
+ addParens = true;
+ append(CacheHint.PREF_MEM);
}
if (obj.getTtl() != null) {
- if (!addParens) {
- parts.add(Tokens.LPAREN);
- addParens = true;
- } else {
- parts.add(SPACE);
- }
- parts.add(CacheHint.TTL);
- parts.add(obj.getTtl());
+ if (!addParens) {
+ append(Tokens.LPAREN);
+ addParens = true;
+ } else {
+ append(SPACE);
+ }
+ append(CacheHint.TTL);
+ append(obj.getTtl());
}
if (obj.isUpdatable()) {
- if (!addParens) {
- parts.add(Tokens.LPAREN);
- addParens = true;
- } else {
- parts.add(SPACE);
- }
- parts.add(CacheHint.UPDATABLE);
+ if (!addParens) {
+ append(Tokens.LPAREN);
+ addParens = true;
+ } else {
+ append(SPACE);
+ }
+ append(CacheHint.UPDATABLE);
}
if (addParens) {
- parts.add(Tokens.RPAREN);
+ append(Tokens.RPAREN);
}
- parts.add(SPACE);
- parts.add(END_HINT);
- parts.add(SPACE);
- }
+ append(SPACE);
+ append(END_HINT);
+ beginClause(0);
+ }
- public void visit(SubqueryFromClause obj) {
+ public void visit( SubqueryFromClause obj ) {
addOptionComment(obj);
if (obj.isTable()) {
- parts.add(TABLE);
+ append(TABLE);
}
- parts.add("(");//$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(")");//$NON-NLS-1$
- parts.add(" AS ");//$NON-NLS-1$
- parts.add(obj.getOutputName());
+ append("(");//$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(")");//$NON-NLS-1$
+ append(" AS ");//$NON-NLS-1$
+ append(obj.getOutputName());
addFromClasueDepOptions(obj);
}
- public void visit(SubquerySetCriteria obj) {
+ public void visit( SubquerySetCriteria obj ) {
// variable
- parts.add(registerNode(obj.getExpression()));
+ visitNode(obj.getExpression());
// operator and beginning of list
- parts.add(SPACE);
+ append(SPACE);
if (obj.isNegated()) {
- parts.add(NOT);
- parts.add(SPACE);
+ append(NOT);
+ append(SPACE);
}
- parts.add(IN);
- parts.add(" ("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(")"); //$NON-NLS-1$
+ append(IN);
+ append(" ("); //$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(")"); //$NON-NLS-1$
}
-
- public void visit(UnaryFromClause obj) {
+ public void visit( UnaryFromClause obj ) {
addOptionComment(obj);
- parts.add(registerNode(obj.getGroup()));
+ visitNode(obj.getGroup());
addFromClasueDepOptions(obj);
}
- public void visit(Update obj) {
+ public void visit( Update obj ) {
// Update clause
- parts.add(UPDATE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getGroup()));
- parts.add(SPACE);
-
+ append(UPDATE);
+ append(SPACE);
+ visitNode(obj.getGroup());
+ beginClause(1);
// Set clause
- parts.add(SET);
- parts.add(SPACE);
+ append(SET);
+ beginClause(2);
+ visitNode(obj.getChangeList());
- parts.add(registerNode(obj.getChangeList()));
-
- // Where clause
- if(obj.getCriteria() != null) {
- parts.add(SPACE);
- parts.add(WHERE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getCriteria()));
- }
+ // Where clause
+ if (obj.getCriteria() != null) {
+ beginClause(1);
+ visitCriteria(WHERE, obj.getCriteria());
+ }
- // Option clause
- if(obj.getOption() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOption()));
- }
+ // Option clause
+ if (obj.getOption() != null) {
+ beginClause(1);
+ visitNode(obj.getOption());
+ }
}
- public void visit(Into obj) {
- parts.add(registerNode(obj.getGroup()));
+ public void visit( Into obj ) {
+ append(INTO);
+ append(SPACE);
+ visitNode(obj.getGroup());
}
// ############ Visitor methods for symbol objects ####################
- public void visit(AggregateSymbol obj) {
- parts.add(obj.getAggregateFunction().name());
- parts.add("("); //$NON-NLS-1$
+ public void visit( AggregateSymbol obj ) {
+ append(obj.getAggregateFunction().name());
+ append("("); //$NON-NLS-1$
- if(obj.isDistinct()) {
- parts.add(DISTINCT);
- parts.add(" "); //$NON-NLS-1$
- }
+ if (obj.isDistinct()) {
+ append(DISTINCT);
+ append(" "); //$NON-NLS-1$
+ }
- if(obj.getExpression() == null) {
- parts.add(Tokens.ALL_COLS);
- } else {
- parts.add(registerNode(obj.getExpression()));
- }
-
- if (obj.getOrderBy() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOrderBy()));
- }
- parts.add(")"); //$NON-NLS-1$
+ if (obj.getExpression() == null) {
+ append(Tokens.ALL_COLS);
+ } else {
+ visitNode(obj.getExpression());
+ }
+
+ if (obj.getOrderBy() != null) {
+ append(SPACE);
+ visitNode(obj.getOrderBy());
+ }
+ append(")"); //$NON-NLS-1$
}
- public void visit(AliasSymbol obj) {
- parts.add(registerNode(obj.getSymbol()));
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- parts.add(escapeSinglePart(obj.getOutputName()));
+ public void visit( AliasSymbol obj ) {
+ visitNode(obj.getSymbol());
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ append(escapeSinglePart(obj.getOutputName()));
}
- public void visit(AllInGroupSymbol obj) {
- parts.add(obj.getName());
+ public void visit( AllInGroupSymbol obj ) {
+ append(obj.getName());
}
- public void visit(AllSymbol obj) {
- parts.add(obj.getName());
+ public void visit( AllSymbol obj ) {
+ append(obj.getName());
}
- public void visit(Constant obj) {
+ public void visit( Constant obj ) {
Class<?> type = obj.getType();
- Object[] constantParts = null;
+ String[] constantParts = null;
if (obj.isMultiValued()) {
- constantParts = new Object[] {"?"}; //$NON-NLS-1$
- } else if(obj.isNull()) {
- if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] {UNKNOWN};
- } else {
- constantParts = new Object[] {"null"}; //$NON-NLS-1$
- }
- } else {
- if(Number.class.isAssignableFrom(type)) {
- constantParts = new Object[] { obj.getValue().toString() };
- } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ? TRUE : FALSE};
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
- constantParts = new Object[] { "{ts'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
- constantParts = new Object[] { "{t'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
- constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- }
+ constantParts = new String[] {"?"}; //$NON-NLS-1$
+ } else if (obj.isNull()) {
+ if (type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new String[] {UNKNOWN};
+ } else {
+ constantParts = new String[] {"null"}; //$NON-NLS-1$
+ }
+ } else {
+ if (Number.class.isAssignableFrom(type)) {
+ constantParts = new String[] {obj.getValue().toString()};
+ } else if (type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new String[] {obj.getValue().equals(Boolean.TRUE) ? TRUE : FALSE};
+ } else if (type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
+ constantParts = new String[] {"{ts'", obj.getValue().toString(), "'}"}; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
+ constantParts = new String[] {"{t'", obj.getValue().toString(), "'}"}; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
+ constantParts = new String[] {"{d'", obj.getValue().toString(), "'}"}; //$NON-NLS-1$ //$NON-NLS-2$
+ }
if (constantParts == null) {
- String strValue = obj.getValue().toString();
- strValue = escapeStringValue(strValue, "'"); //$NON-NLS-1$
- constantParts = new Object[] { "'", strValue, "'" }; //$NON-NLS-1$ //$NON-NLS-2$
+ String strValue = obj.getValue().toString();
+ strValue = escapeStringValue(strValue, "'"); //$NON-NLS-1$
+ constantParts = new String[] {"'", strValue, "'"}; //$NON-NLS-1$ //$NON-NLS-2$
}
}
- replaceStringParts(constantParts);
+ for (String string : constantParts) {
+ append(string);
+ }
}
- /**
- * Take a string literal and escape it as necessary. By default, this converts ' to ''.
- * @param str String literal value (unquoted), never null
- * @return Escaped string literal value
- */
- static String escapeStringValue(String str, String tick) {
+ /**
+ * Take a string literal and escape it as necessary. By default, this converts ' to ''.
+ *
+ * @param str String literal value (unquoted), never null
+ * @return Escaped string literal value
+ */
+ static String escapeStringValue( String str,
+ String tick ) {
return StringUtil.replaceAll(str, tick, tick + tick);
}
- public void visit(ElementSymbol obj) {
+ public void visit( ElementSymbol obj ) {
if (obj.getDisplayMode().equals(ElementSymbol.DisplayMode.SHORT_OUTPUT_NAME)) {
outputShortName(obj);
return;
@@ -1241,704 +1151,706 @@
}
outputDisplayName(name);
}
-
- private void outputShortName(ElementSymbol obj) {
- outputDisplayName(SingleElementSymbol.getShortName(obj.getOutputName()));
+
+ private void outputShortName( ElementSymbol obj ) {
+ outputDisplayName(SingleElementSymbol.getShortName(obj.getOutputName()));
}
- private void outputDisplayName(String name) {
+ private void outputDisplayName( String name ) {
String[] pathParts = name.split("\\."); //$NON-NLS-1$
for (int i = 0; i < pathParts.length; i++) {
if (i > 0) {
- parts.add(ElementSymbol.SEPARATOR);
+ append(ElementSymbol.SEPARATOR);
}
- parts.add(escapeSinglePart(pathParts[i]));
+ append(escapeSinglePart(pathParts[i]));
}
}
- public void visit(ExpressionSymbol obj) {
- parts.add(registerNode(obj.getExpression()));
+ public void visit( ExpressionSymbol obj ) {
+ visitNode(obj.getExpression());
}
- public void visit(Function obj) {
+ public void visit( Function obj ) {
String name = obj.getName();
Expression[] args = obj.getArgs();
- if(obj.isImplicit()) {
- // Hide this function, which is implicit
- parts.add(registerNode(args[0]));
+ if (obj.isImplicit()) {
+ // Hide this function, which is implicit
+ visitNode(args[0]);
- } else if(name.equalsIgnoreCase(CONVERT) || name.equalsIgnoreCase(CAST)) {
- parts.add(name);
- parts.add("("); //$NON-NLS-1$
+ } else if (name.equalsIgnoreCase(CONVERT) || name.equalsIgnoreCase(CAST)) {
+ append(name);
+ append("("); //$NON-NLS-1$
- if(args != null && args.length > 0) {
- parts.add(registerNode(args[0]));
+ if (args != null && args.length > 0) {
+ visitNode(args[0]);
- if(name.equalsIgnoreCase(CONVERT)) {
- parts.add(", "); //$NON-NLS-1$
- } else {
- parts.add(" "); //$NON-NLS-1$
- parts.add(AS);
- parts.add(" "); //$NON-NLS-1$
- }
+ if (name.equalsIgnoreCase(CONVERT)) {
+ append(", "); //$NON-NLS-1$
+ } else {
+ append(" "); //$NON-NLS-1$
+ append(AS);
+ append(" "); //$NON-NLS-1$
+ }
- if(args.length < 2 || args[1] == null || !(args[1] instanceof Constant)) {
- parts.add(UNDEFINED);
- } else {
- parts.add(((Constant)args[1]).getValue());
- }
- }
- parts.add(")"); //$NON-NLS-1$
+ if (args.length < 2 || args[1] == null || !(args[1] instanceof Constant)) {
+ append(UNDEFINED);
+ } else {
+ append(((Constant)args[1]).getValue());
+ }
+ }
+ append(")"); //$NON-NLS-1$
- } else if(name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- parts.add("("); //$NON-NLS-1$
+ } else if (name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ append("("); //$NON-NLS-1$
- if(args != null) {
- for(int i=0; i<args.length; i++) {
- parts.add(registerNode(args[i]));
- if(i < (args.length-1)) {
- parts.add(SPACE);
- parts.add(name);
- parts.add(SPACE);
- }
- }
- }
- parts.add(")"); //$NON-NLS-1$
+ if (args != null) {
+ for (int i = 0; i < args.length; i++) {
+ visitNode(args[i]);
+ if (i < (args.length - 1)) {
+ append(SPACE);
+ append(name);
+ append(SPACE);
+ }
+ }
+ }
+ append(")"); //$NON-NLS-1$
- } else if(name.equalsIgnoreCase(NonReserved.TIMESTAMPADD) || name.equalsIgnoreCase(NonReserved.TIMESTAMPDIFF)) {
- parts.add(name);
- parts.add("("); //$NON-NLS-1$
+ } else if (name.equalsIgnoreCase(NonReserved.TIMESTAMPADD) || name.equalsIgnoreCase(NonReserved.TIMESTAMPDIFF)) {
+ append(name);
+ append("("); //$NON-NLS-1$
- if(args != null && args.length > 0) {
- parts.add(((Constant)args[0]).getValue());
+ if (args != null && args.length > 0) {
+ append(((Constant)args[0]).getValue());
registerNodes(args, 1);
}
- parts.add(")"); //$NON-NLS-1$
+ append(")"); //$NON-NLS-1$
- } else if (name.equalsIgnoreCase(SourceSystemFunctions.XMLPI)){
- parts.add(name);
- parts.add("(NAME "); //$NON-NLS-1$
- outputDisplayName((String)((Constant)args[0]).getValue());
- registerNodes(args, 1);
- parts.add(")"); //$NON-NLS-1$
- } else {
- parts.add(name);
- parts.add("("); //$NON-NLS-1$
- registerNodes(args, 0);
- parts.add(")"); //$NON-NLS-1$
- }
+ } else if (name.equalsIgnoreCase(SourceSystemFunctions.XMLPI)) {
+ append(name);
+ append("(NAME "); //$NON-NLS-1$
+ outputDisplayName((String)((Constant)args[0]).getValue());
+ registerNodes(args, 1);
+ append(")"); //$NON-NLS-1$
+ } else {
+ append(name);
+ append("("); //$NON-NLS-1$
+ registerNodes(args, 0);
+ append(")"); //$NON-NLS-1$
+ }
}
-
- private void registerNodes(LanguageObject[] objects, int begin) {
- registerNodes(Arrays.asList(objects), begin);
+
+ private void registerNodes( LanguageObject[] objects,
+ int begin ) {
+ registerNodes(Arrays.asList(objects), begin);
}
-
- private void registerNodes(List<? extends LanguageObject> objects, int begin) {
- for (int i = begin; i < objects.size(); i++) {
- if (i > 0) {
- parts.add(", "); //$NON-NLS-1$
- }
- parts.add(registerNode(objects.get(i)));
- }
+
+ private void registerNodes( List<? extends LanguageObject> objects,
+ int begin ) {
+ for (int i = begin; i < objects.size(); i++) {
+ if (i > 0) {
+ append(", "); //$NON-NLS-1$
+ }
+ visitNode(objects.get(i));
+ }
}
- public void visit(GroupSymbol obj) {
+ public void visit( GroupSymbol obj ) {
String alias = null;
String fullGroup = obj.getOutputName();
- if(obj.getOutputDefinition() != null) {
+ if (obj.getOutputDefinition() != null) {
alias = obj.getOutputName();
fullGroup = obj.getOutputDefinition();
}
-
+
outputDisplayName(fullGroup);
- if(alias != null) {
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- parts.add(escapeSinglePart(alias));
+ if (alias != null) {
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ append(escapeSinglePart(alias));
}
}
- public void visit(Reference obj) {
+ public void visit( Reference obj ) {
if (!obj.isPositional() && obj.getExpression() != null) {
- replaceStringParts(new Object[] { obj.getExpression().toString() });
+ visitNode(obj.getExpression());
} else {
- replaceStringParts(new Object[] { "?" }); //$NON-NLS-1$
+ append("?"); //$NON-NLS-1$
}
}
// ############ Visitor methods for storedprocedure language objects ####################
- public void visit(Block obj) {
- List statements = obj.getStatements();
- if(statements.size() == 1) {
- replaceStringParts(new Object[] { BEGIN, "\n", //$NON-NLS-1$
- registerNode((Statement)obj.getStatements().get(0)), "\n", END}); //$NON-NLS-1$
- } else if(statements.size() > 1) {
- List parts = new ArrayList();
- // Add first clause
- parts.add(BEGIN);
- parts.add("\n"); //$NON-NLS-1$
- Iterator stmtIter = statements.iterator();
- while(stmtIter.hasNext()) {
- // Add each statement
- parts.add(registerNode((Statement) stmtIter.next()));
- parts.add("\n"); //$NON-NLS-1$
- }
- parts.add(END);
- replaceStringParts(parts.toArray());
- } else {
- // Shouldn't happen, but being tolerant
- replaceStringParts(new Object[] { BEGIN, "\n", //$NON-NLS-1$
- END });
+ public void visit( Block obj ) {
+ List statements = obj.getStatements();
+ // Add first clause
+ append(BEGIN);
+ append("\n"); //$NON-NLS-1$
+ Iterator stmtIter = statements.iterator();
+ while (stmtIter.hasNext()) {
+ // Add each statement
+ addTabs(1);
+ visitNode((Statement)stmtIter.next());
+ append("\n"); //$NON-NLS-1$
}
+ addTabs(0);
+ append(END);
}
- public void visit(CommandStatement obj) {
- parts.add(registerNode(obj.getCommand()));
- parts.add(";"); //$NON-NLS-1$
+ protected void addTabs( int level ) {
}
- public void visit(CreateUpdateProcedureCommand obj) {
- parts.add(CREATE);
- parts.add(SPACE);
- if(!obj.isUpdateProcedure()){
- parts.add(VIRTUAL);
- parts.add(SPACE);
+ public void visit( CommandStatement obj ) {
+ visitNode(obj.getCommand());
+ append(";"); //$NON-NLS-1$
+ }
+
+ public void visit( CreateUpdateProcedureCommand obj ) {
+ append(CREATE);
+ append(SPACE);
+ if (!obj.isUpdateProcedure()) {
+ append(VIRTUAL);
+ append(SPACE);
}
- parts.add(PROCEDURE);
- parts.add("\n"); //$NON-NLS-1$
- parts.add(registerNode(obj.getBlock()));
+ append(PROCEDURE);
+ append("\n"); //$NON-NLS-1$
+ addTabs(0);
+ visitNode(obj.getBlock());
}
- public void visit(DeclareStatement obj) {
- parts.add(DECLARE);
- parts.add(SPACE);
- parts.add(obj.getVariableType());
- parts.add(SPACE);
+ public void visit( DeclareStatement obj ) {
+ append(DECLARE);
+ append(SPACE);
+ append(obj.getVariableType());
+ append(SPACE);
createAssignment(obj);
}
- /**
+ /**
* @param obj
* @param parts
*/
- private void createAssignment(AssignmentStatement obj) {
- parts.add(registerNode(obj.getVariable()));
- if (obj.getValue() != null) {
- parts.add(" = "); //$NON-NLS-1$
+ private void createAssignment( AssignmentStatement obj ) {
+ visitNode(obj.getVariable());
+ if (obj.getExpression() != null) {
+ append(" = "); //$NON-NLS-1$
addStatementArgument(obj.getExpression());
}
- parts.add(";"); //$NON-NLS-1$
+ append(";"); //$NON-NLS-1$
}
- private void addStatementArgument(Expression expr) {
- if (expr instanceof ScalarSubquery) {
- parts.add(registerNode(((ScalarSubquery)expr).getCommand()));
- } else {
- parts.add(registerNode(expr));
- }
- }
+ private void addStatementArgument( Expression expr ) {
+ if (expr instanceof ScalarSubquery) {
+ visitNode(((ScalarSubquery)expr).getCommand());
+ } else {
+ visitNode(expr);
+ }
+ }
- public void visit(IfStatement obj) {
- parts.add(IF);
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCondition()));
- parts.add(")\n"); //$NON-NLS-1$
- parts.add(registerNode(obj.getIfBlock()));
- if(obj.hasElseBlock()) {
- parts.add("\n"); //$NON-NLS-1$
- parts.add(ELSE);
- parts.add("\n"); //$NON-NLS-1$
- parts.add(registerNode(obj.getElseBlock()));
+ public void visit( IfStatement obj ) {
+ append(IF);
+ append("("); //$NON-NLS-1$
+ visitNode(obj.getCondition());
+ append(")\n"); //$NON-NLS-1$
+ addTabs(0);
+ visitNode(obj.getIfBlock());
+ if (obj.hasElseBlock()) {
+ append("\n"); //$NON-NLS-1$
+ addTabs(0);
+ append(ELSE);
+ append("\n"); //$NON-NLS-1$
+ addTabs(0);
+ visitNode(obj.getElseBlock());
}
}
- public void visit(AssignmentStatement obj) {
+ public void visit( AssignmentStatement obj ) {
createAssignment(obj);
}
- public void visit(HasCriteria obj) {
- parts.add( HAS);
- parts.add(SPACE);
- parts.add(registerNode(obj.getSelector()));
+ public void visit( HasCriteria obj ) {
+ append(HAS);
+ append(SPACE);
+ visitNode(obj.getSelector());
}
- public void visit(TranslateCriteria obj) {
- parts.add(TRANSLATE);
- parts.add(SPACE);
- parts.add(registerNode(obj.getSelector()));
+ public void visit( TranslateCriteria obj ) {
+ append(TRANSLATE);
+ append(SPACE);
+ visitNode(obj.getSelector());
- if(obj.hasTranslations()) {
- parts.add(SPACE);
- parts.add(WITH);
- parts.add(SPACE);
- parts.add("("); //$NON-NLS-1$
- Iterator critIter = obj.getTranslations().iterator();
+ if (obj.hasTranslations()) {
+ append(SPACE);
+ append(WITH);
+ append(SPACE);
+ append("("); //$NON-NLS-1$
+ Iterator critIter = obj.getTranslations().iterator();
- while(critIter.hasNext()) {
- parts.add(registerNode((Criteria)critIter.next()));
- if(critIter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
- if(!critIter.hasNext()) {
- parts.add(")"); //$NON-NLS-1$
- }
- }
+ while (critIter.hasNext()) {
+ visitNode((Criteria)critIter.next());
+ if (critIter.hasNext()) {
+ append(", "); //$NON-NLS-1$
+ }
+ if (!critIter.hasNext()) {
+ append(")"); //$NON-NLS-1$
+ }
+ }
}
}
- public void visit(CriteriaSelector obj) {
+ public void visit( CriteriaSelector obj ) {
int selectorType = obj.getSelectorType();
- switch(selectorType) {
- case CriteriaSelector.COMPARE_EQ:
- parts.add("= "); //$NON-NLS-1$
- break;
- case CriteriaSelector.COMPARE_GE:
- parts.add(">= "); //$NON-NLS-1$
- break;
- case CriteriaSelector.COMPARE_GT:
- parts.add("> "); //$NON-NLS-1$
- break;
- case CriteriaSelector.COMPARE_LE:
- parts.add("<= "); //$NON-NLS-1$
- break;
- case CriteriaSelector.COMPARE_LT:
- parts.add("< "); //$NON-NLS-1$
- break;
- case CriteriaSelector.COMPARE_NE:
- parts.add("<> "); //$NON-NLS-1$
- break;
- case CriteriaSelector.IN:
- parts.add(IN);
- parts.add(SPACE);
- break;
- case CriteriaSelector.IS_NULL:
- parts.add(IS);
- parts.add(SPACE);
- parts.add(NULL);
- parts.add(SPACE);
- break;
+ switch (selectorType) {
+ case CriteriaSelector.COMPARE_EQ:
+ append("= "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.COMPARE_GE:
+ append(">= "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.COMPARE_GT:
+ append("> "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.COMPARE_LE:
+ append("<= "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.COMPARE_LT:
+ append("< "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.COMPARE_NE:
+ append("<> "); //$NON-NLS-1$
+ break;
+ case CriteriaSelector.IN:
+ append(IN);
+ append(SPACE);
+ break;
+ case CriteriaSelector.IS_NULL:
+ append(IS);
+ append(SPACE);
+ append(NULL);
+ append(SPACE);
+ break;
case CriteriaSelector.LIKE:
- parts.add(LIKE);
- parts.add(SPACE);
+ append(LIKE);
+ append(SPACE);
break;
case CriteriaSelector.BETWEEN:
- parts.add(BETWEEN);
- parts.add(SPACE);
+ append(BETWEEN);
+ append(SPACE);
break;
}
- parts.add(CRITERIA);
- if(obj.hasElements()) {
- parts.add(SPACE);
- parts.add(ON);
- parts.add(SPACE);
- parts.add("("); //$NON-NLS-1$
+ append(CRITERIA);
+ if (obj.hasElements()) {
+ append(SPACE);
+ append(ON);
+ append(SPACE);
+ append("("); //$NON-NLS-1$
- Iterator elmtIter = obj.getElements().iterator();
- while(elmtIter.hasNext()) {
- parts.add(registerNode((ElementSymbol)elmtIter.next()));
- if(elmtIter.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
- }
- parts.add(")"); //$NON-NLS-1$
- }
+ Iterator elmtIter = obj.getElements().iterator();
+ while (elmtIter.hasNext()) {
+ visitNode((ElementSymbol)elmtIter.next());
+ if (elmtIter.hasNext()) {
+ append(", "); //$NON-NLS-1$
+ }
+ }
+ append(")"); //$NON-NLS-1$
+ }
}
- public void visit(RaiseErrorStatement obj) {
- parts.add(ERROR);
- parts.add(SPACE);
+ public void visit( RaiseErrorStatement obj ) {
+ append(ERROR);
+ append(SPACE);
addStatementArgument(obj.getExpression());
- parts.add(";"); //$NON-NLS-1$
+ append(";"); //$NON-NLS-1$
}
- public void visit(BreakStatement obj) {
- parts.add(BREAK);
- parts.add(";"); //$NON-NLS-1$
+ public void visit( BreakStatement obj ) {
+ append(BREAK);
+ append(";"); //$NON-NLS-1$
}
- public void visit(ContinueStatement obj) {
- parts.add(CONTINUE);
- parts.add(";"); //$NON-NLS-1$
+ public void visit( ContinueStatement obj ) {
+ append(CONTINUE);
+ append(";"); //$NON-NLS-1$
}
- public void visit(LoopStatement obj) {
- parts.add(LOOP);
- parts.add(" "); //$NON-NLS-1$
- parts.add(ON);
- parts.add(" ("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(") "); //$NON-NLS-1$
- parts.add(AS);
- parts.add(" "); //$NON-NLS-1$
- parts.add(obj.getCursorName());
- parts.add("\n"); //$NON-NLS-1$
- parts.add(registerNode(obj.getBlock()));
+ public void visit( LoopStatement obj ) {
+ append(LOOP);
+ append(" "); //$NON-NLS-1$
+ append(ON);
+ append(" ("); //$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(") "); //$NON-NLS-1$
+ append(AS);
+ append(" "); //$NON-NLS-1$
+ append(obj.getCursorName());
+ append("\n"); //$NON-NLS-1$
+ addTabs(0);
+ visitNode(obj.getBlock());
}
- public void visit(WhileStatement obj) {
- parts.add(WHILE);
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCondition()));
- parts.add(")\n"); //$NON-NLS-1$
- parts.add(registerNode(obj.getBlock()));
+ public void visit( WhileStatement obj ) {
+ append(WHILE);
+ append("("); //$NON-NLS-1$
+ visitNode(obj.getCondition());
+ append(")\n"); //$NON-NLS-1$
+ addTabs(0);
+ visitNode(obj.getBlock());
}
- public void visit(ExistsCriteria obj) {
+ public void visit( ExistsCriteria obj ) {
// operator and beginning of list
- parts.add(EXISTS);
- parts.add(" ("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(")"); //$NON-NLS-1$
+ append(EXISTS);
+ append(" ("); //$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(")"); //$NON-NLS-1$
}
- public void visit(SubqueryCompareCriteria obj){
+ public void visit( SubqueryCompareCriteria obj ) {
Expression leftExpression = obj.getLeftExpression();
- parts.add(registerNode(leftExpression));
+ visitNode(leftExpression);
String operator = obj.getOperatorAsString();
String quantifier = obj.getPredicateQuantifierAsString();
// operator and beginning of list
- parts.add(SPACE);
- parts.add(operator);
- parts.add(SPACE);
- parts.add(quantifier);
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(")"); //$NON-NLS-1$
+ append(SPACE);
+ append(operator);
+ append(SPACE);
+ append(quantifier);
+ append("("); //$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(")"); //$NON-NLS-1$
}
- public void visit(ScalarSubquery obj) {
+ public void visit( ScalarSubquery obj ) {
// operator and beginning of list
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(obj.getCommand()));
- parts.add(")"); //$NON-NLS-1$
+ append("("); //$NON-NLS-1$
+ visitNode(obj.getCommand());
+ append(")"); //$NON-NLS-1$
}
-
+
@Override
- public void visit(XMLAttributes obj) {
- parts.add(XMLATTRIBUTES);
- parts.add("("); //$NON-NLS-1$
- registerNodes(obj.getArgs(), 0);
- parts.add(")"); //$NON-NLS-1$
+ public void visit( XMLAttributes obj ) {
+ append(XMLATTRIBUTES);
+ append("("); //$NON-NLS-1$
+ registerNodes(obj.getArgs(), 0);
+ append(")"); //$NON-NLS-1$
}
-
+
@Override
- public void visit(XMLElement obj) {
- parts.add(XMLELEMENT);
- parts.add("(NAME "); //$NON-NLS-1$
- outputDisplayName(obj.getName());
- if (obj.getNamespaces() != null) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(registerNode(obj.getNamespaces()));
- }
- if (obj.getAttributes() != null) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(registerNode(obj.getAttributes()));
- }
- if (!obj.getContent().isEmpty()) {
- parts.add(", "); //$NON-NLS-1$
- }
- registerNodes(obj.getContent(), 0);
- parts.add(")"); //$NON-NLS-1$
+ public void visit( XMLElement obj ) {
+ append(XMLELEMENT);
+ append("(NAME "); //$NON-NLS-1$
+ outputDisplayName(obj.getName());
+ if (obj.getNamespaces() != null) {
+ append(", "); //$NON-NLS-1$
+ visitNode(obj.getNamespaces());
+ }
+ if (obj.getAttributes() != null) {
+ append(", "); //$NON-NLS-1$
+ visitNode(obj.getAttributes());
+ }
+ if (!obj.getContent().isEmpty()) {
+ append(", "); //$NON-NLS-1$
+ }
+ registerNodes(obj.getContent(), 0);
+ append(")"); //$NON-NLS-1$
}
-
+
@Override
- public void visit(XMLForest obj) {
- parts.add(XMLFOREST);
- parts.add("("); //$NON-NLS-1$
- if (obj.getNamespaces() != null) {
- parts.add(registerNode(obj.getNamespaces()));
- parts.add(", "); //$NON-NLS-1$
- }
- registerNodes(obj.getArgs(), 0);
- parts.add(")"); //$NON-NLS-1$
+ public void visit( XMLForest obj ) {
+ append(XMLFOREST);
+ append("("); //$NON-NLS-1$
+ if (obj.getNamespaces() != null) {
+ visitNode(obj.getNamespaces());
+ append(", "); //$NON-NLS-1$
+ }
+ registerNodes(obj.getArgs(), 0);
+ append(")"); //$NON-NLS-1$
}
-
+
@Override
- public void visit(XMLNamespaces obj) {
- parts.add(XMLNAMESPACES);
- parts.add("("); //$NON-NLS-1$
- for (Iterator<NamespaceItem> items = obj.getNamespaceItems().iterator(); items.hasNext();) {
- NamespaceItem item = items.next();
- if (item.getPrefix() == null) {
- if (item.getUri() == null) {
- parts.add("NO DEFAULT"); //$NON-NLS-1$
- } else {
- parts.add("DEFAULT "); //$NON-NLS-1$
- parts.add(registerNode(new Constant(item.getUri())));
- }
- } else {
- parts.add(registerNode(new Constant(item.getUri())));
- parts.add(" AS "); //$NON-NLS-1$
- outputDisplayName(item.getPrefix());
- }
- if (items.hasNext()) {
- parts.add(", "); //$NON-NLS-1$
- }
- }
- parts.add(")"); //$NON-NLS-1$
+ public void visit( XMLNamespaces obj ) {
+ append(XMLNAMESPACES);
+ append("("); //$NON-NLS-1$
+ for (Iterator<NamespaceItem> items = obj.getNamespaceItems().iterator(); items.hasNext();) {
+ NamespaceItem item = items.next();
+ if (item.getPrefix() == null) {
+ if (item.getUri() == null) {
+ append("NO DEFAULT"); //$NON-NLS-1$
+ } else {
+ append("DEFAULT "); //$NON-NLS-1$
+ visitNode(new Constant(item.getUri()));
+ }
+ } else {
+ visitNode(new Constant(item.getUri()));
+ append(" AS "); //$NON-NLS-1$
+ outputDisplayName(item.getPrefix());
+ }
+ if (items.hasNext()) {
+ append(", "); //$NON-NLS-1$
+ }
+ }
+ append(")"); //$NON-NLS-1$
}
-
- public void visit(Limit obj) {
- parts.add(LIMIT);
+
+ public void visit( Limit obj ) {
+ append(LIMIT);
if (obj.getOffset() != null) {
- parts.add(SPACE);
- parts.add(registerNode(obj.getOffset()));
- parts.add(","); //$NON-NLS-1$
+ append(SPACE);
+ visitNode(obj.getOffset());
+ append(","); //$NON-NLS-1$
}
- parts.add(SPACE);
- parts.add(registerNode(obj.getRowLimit()));
+ append(SPACE);
+ visitNode(obj.getRowLimit());
}
-
+
@Override
- public void visit(TextTable obj) {
- parts.add("TEXTTABLE("); //$NON-NLS-1$
- parts.add(registerNode(obj.getFile()));
- parts.add(SPACE);
- parts.add(NonReserved.COLUMNS);
-
- for (Iterator<TextColumn> cols = obj.getColumns().iterator(); cols.hasNext();) {
- TextColumn col = cols.next();
- parts.add(SPACE);
- outputDisplayName(col.getName());
- parts.add(SPACE);
- parts.add(col.getType());
- if (col.getWidth() != null) {
- parts.add(SPACE);
- parts.add(NonReserved.WIDTH);
- parts.add(SPACE);
- parts.add(col.getWidth());
- }
- if (cols.hasNext()) {
- parts.add(","); //$NON-NLS-1$
- }
- }
- if (obj.getDelimiter() != null) {
- parts.add(SPACE);
- parts.add(NonReserved.DELIMITER);
- parts.add(SPACE);
- parts.add(registerNode(new Constant(obj.getDelimiter())));
- }
- if (obj.getQuote() != null) {
- parts.add(SPACE);
- if (obj.isEscape()) {
- parts.add(ESCAPE);
- } else {
- parts.add(NonReserved.QUOTE);
- }
- parts.add(SPACE);
- parts.add(registerNode(new Constant(obj.getQuote())));
- }
- if (obj.getHeader() != null) {
- parts.add(SPACE);
- parts.add(NonReserved.HEADER);
- if (1 != obj.getHeader()) {
- parts.add(SPACE);
- parts.add(obj.getHeader());
- }
- }
- if (obj.getSkip() != null) {
- parts.add(SPACE);
- parts.add("SKIP"); //$NON-NLS-1$
- parts.add(SPACE);
- parts.add(obj.getSkip());
- }
- parts.add(")");//$NON-NLS-1$
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- outputDisplayName(obj.getName());
+ public void visit( TextTable obj ) {
+ append("TEXTTABLE("); //$NON-NLS-1$
+ visitNode(obj.getFile());
+ append(SPACE);
+ append(NonReserved.COLUMNS);
+
+ for (Iterator<TextColumn> cols = obj.getColumns().iterator(); cols.hasNext();) {
+ TextColumn col = cols.next();
+ append(SPACE);
+ outputDisplayName(col.getName());
+ append(SPACE);
+ append(col.getType());
+ if (col.getWidth() != null) {
+ append(SPACE);
+ append(NonReserved.WIDTH);
+ append(SPACE);
+ append(col.getWidth());
+ }
+ if (cols.hasNext()) {
+ append(","); //$NON-NLS-1$
+ }
+ }
+ if (obj.getDelimiter() != null) {
+ append(SPACE);
+ append(NonReserved.DELIMITER);
+ append(SPACE);
+ visitNode(new Constant(obj.getDelimiter()));
+ }
+ if (obj.getQuote() != null) {
+ append(SPACE);
+ if (obj.isEscape()) {
+ append(ESCAPE);
+ } else {
+ append(NonReserved.QUOTE);
+ }
+ append(SPACE);
+ visitNode(new Constant(obj.getQuote()));
+ }
+ if (obj.getHeader() != null) {
+ append(SPACE);
+ append(NonReserved.HEADER);
+ if (1 != obj.getHeader()) {
+ append(SPACE);
+ append(obj.getHeader());
+ }
+ }
+ if (obj.getSkip() != null) {
+ append(SPACE);
+ append("SKIP"); //$NON-NLS-1$
+ append(SPACE);
+ append(obj.getSkip());
+ }
+ append(")");//$NON-NLS-1$
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ outputDisplayName(obj.getName());
}
@Override
- public void visit(XMLTable obj) {
- parts.add("XMLTABLE("); //$NON-NLS-1$
- if (obj.getNamespaces() != null) {
- parts.add(registerNode(obj.getNamespaces()));
- parts.add(","); //$NON-NLS-1$
- parts.add(SPACE);
- }
- parts.add(new Constant(obj.getXquery()));
- if (!obj.getPassing().isEmpty()) {
- parts.add(SPACE);
- parts.add(NonReserved.PASSING);
- parts.add(SPACE);
- registerNodes(obj.getPassing(), 0);
- }
- if (!obj.getColumns().isEmpty()) {
- parts.add(SPACE);
- parts.add(NonReserved.COLUMNS);
- for (Iterator<XMLColumn> cols = obj.getColumns().iterator(); cols.hasNext();) {
- XMLColumn col = cols.next();
- parts.add(SPACE);
- outputDisplayName(col.getName());
- parts.add(SPACE);
- if (col.isOrdinal()) {
- parts.add(FOR);
- parts.add(SPACE);
- parts.add(NonReserved.ORDINALITY);
- } else {
- parts.add(col.getType());
- if (col.getDefaultExpression() != null) {
- parts.add(SPACE);
- parts.add(DEFAULT);
- parts.add(SPACE);
- parts.add(registerNode(col.getDefaultExpression()));
- }
- if (col.getPath() != null) {
- parts.add(SPACE);
- parts.add(NonReserved.PATH);
- parts.add(SPACE);
- parts.add(new Constant(col.getPath()));
- }
- }
- if (cols.hasNext()) {
- parts.add(","); //$NON-NLS-1$
- }
- }
- }
- parts.add(")");//$NON-NLS-1$
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- outputDisplayName(obj.getName());
+ public void visit( XMLTable obj ) {
+ append("XMLTABLE("); //$NON-NLS-1$
+ if (obj.getNamespaces() != null) {
+ visitNode(obj.getNamespaces());
+ append(","); //$NON-NLS-1$
+ append(SPACE);
+ }
+ visitNode(new Constant(obj.getXquery()));
+ if (!obj.getPassing().isEmpty()) {
+ append(SPACE);
+ append(NonReserved.PASSING);
+ append(SPACE);
+ registerNodes(obj.getPassing(), 0);
+ }
+ if (!obj.getColumns().isEmpty()) {
+ append(SPACE);
+ append(NonReserved.COLUMNS);
+ for (Iterator<XMLColumn> cols = obj.getColumns().iterator(); cols.hasNext();) {
+ XMLColumn col = cols.next();
+ append(SPACE);
+ outputDisplayName(col.getName());
+ append(SPACE);
+ if (col.isOrdinal()) {
+ append(FOR);
+ append(SPACE);
+ append(NonReserved.ORDINALITY);
+ } else {
+ append(col.getType());
+ if (col.getDefaultExpression() != null) {
+ append(SPACE);
+ append(DEFAULT);
+ append(SPACE);
+ visitNode(col.getDefaultExpression());
+ }
+ if (col.getPath() != null) {
+ append(SPACE);
+ append(NonReserved.PATH);
+ append(SPACE);
+ visitNode(new Constant(col.getPath()));
+ }
+ }
+ if (cols.hasNext()) {
+ append(","); //$NON-NLS-1$
+ }
+ }
+ }
+ append(")");//$NON-NLS-1$
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ outputDisplayName(obj.getName());
}
-
+
@Override
- public void visit(XMLQuery obj) {
- parts.add("XMLQUERY("); //$NON-NLS-1$
- if (obj.getNamespaces() != null) {
- parts.add(registerNode(obj.getNamespaces()));
- parts.add(","); //$NON-NLS-1$
- parts.add(SPACE);
- }
- parts.add(new Constant(obj.getXquery()));
- if (!obj.getPassing().isEmpty()) {
- parts.add(SPACE);
- parts.add(NonReserved.PASSING);
- parts.add(SPACE);
- registerNodes(obj.getPassing(), 0);
- }
- if (obj.getEmptyOnEmpty() != null) {
- parts.add(SPACE);
- if (obj.getEmptyOnEmpty()) {
- parts.add(NonReserved.EMPTY);
- } else {
- parts.add(NULL);
- }
- parts.add(SPACE);
- parts.add(ON);
- parts.add(SPACE);
- parts.add(NonReserved.EMPTY);
- }
- parts.add(")");//$NON-NLS-1$
+ public void visit( XMLQuery obj ) {
+ append("XMLQUERY("); //$NON-NLS-1$
+ if (obj.getNamespaces() != null) {
+ visitNode(obj.getNamespaces());
+ append(","); //$NON-NLS-1$
+ append(SPACE);
+ }
+ visitNode(new Constant(obj.getXquery()));
+ if (!obj.getPassing().isEmpty()) {
+ append(SPACE);
+ append(NonReserved.PASSING);
+ append(SPACE);
+ registerNodes(obj.getPassing(), 0);
+ }
+ if (obj.getEmptyOnEmpty() != null) {
+ append(SPACE);
+ if (obj.getEmptyOnEmpty()) {
+ append(NonReserved.EMPTY);
+ } else {
+ append(NULL);
+ }
+ append(SPACE);
+ append(ON);
+ append(SPACE);
+ append(NonReserved.EMPTY);
+ }
+ append(")");//$NON-NLS-1$
}
-
+
@Override
- public void visit(DerivedColumn obj) {
- parts.add(registerNode(obj.getExpression()));
- if (obj.getAlias() != null) {
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- outputDisplayName(obj.getAlias());
- }
+ public void visit( DerivedColumn obj ) {
+ visitNode(obj.getExpression());
+ if (obj.getAlias() != null) {
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ outputDisplayName(obj.getAlias());
+ }
}
-
+
@Override
- public void visit(XMLSerialize obj) {
- parts.add(XMLSERIALIZE);
- parts.add(Tokens.LPAREN);
- if (obj.isDocument() != null) {
- if (obj.isDocument()) {
- parts.add(NonReserved.DOCUMENT);
- } else {
- parts.add(NonReserved.CONTENT);
- }
- parts.add(SPACE);
- }
- parts.add(registerNode(obj.getExpression()));
- if (obj.getTypeString() != null) {
- parts.add(SPACE);
- parts.add(AS);
- parts.add(SPACE);
- parts.add(obj.getTypeString());
- }
- parts.add(Tokens.RPAREN);
+ public void visit( XMLSerialize obj ) {
+ append(XMLSERIALIZE);
+ append(Tokens.LPAREN);
+ if (obj.isDocument() != null) {
+ if (obj.isDocument()) {
+ append(NonReserved.DOCUMENT);
+ } else {
+ append(NonReserved.CONTENT);
+ }
+ append(SPACE);
+ }
+ visitNode(obj.getExpression());
+ if (obj.getTypeString() != null) {
+ append(SPACE);
+ append(AS);
+ append(SPACE);
+ append(obj.getTypeString());
+ }
+ append(Tokens.RPAREN);
}
-
+
@Override
- public void visit(QueryString obj) {
- parts.add(NonReserved.QUERYSTRING);
- parts.add("("); //$NON-NLS-1$
- parts.add(registerNode(obj.getPath()));
- if (!obj.getArgs().isEmpty()) {
- parts.add(","); //$NON-NLS-1$
- parts.add(SPACE);
- registerNodes(obj.getArgs(), 0);
- }
- parts.add(")"); //$NON-NLS-1$
+ public void visit( QueryString obj ) {
+ append(NonReserved.QUERYSTRING);
+ append("("); //$NON-NLS-1$
+ visitNode(obj.getPath());
+ if (!obj.getArgs().isEmpty()) {
+ append(","); //$NON-NLS-1$
+ append(SPACE);
+ registerNodes(obj.getArgs(), 0);
+ }
+ append(")"); //$NON-NLS-1$
}
-
+
@Override
- public void visit(XMLParse obj) {
- parts.add(XMLPARSE);
- parts.add(Tokens.LPAREN);
- if (obj.isDocument()) {
- parts.add(NonReserved.DOCUMENT);
- } else {
- parts.add(NonReserved.CONTENT);
- }
- parts.add(SPACE);
- parts.add(registerNode(obj.getExpression()));
- if (obj.isWellFormed()) {
- parts.add(SPACE);
- parts.add(NonReserved.WELLFORMED);
- }
- parts.add(Tokens.RPAREN);
+ public void visit( XMLParse obj ) {
+ append(XMLPARSE);
+ append(Tokens.LPAREN);
+ if (obj.isDocument()) {
+ append(NonReserved.DOCUMENT);
+ } else {
+ append(NonReserved.CONTENT);
+ }
+ append(SPACE);
+ visitNode(obj.getExpression());
+ if (obj.isWellFormed()) {
+ append(SPACE);
+ append(NonReserved.WELLFORMED);
+ }
+ append(Tokens.RPAREN);
}
-
+
@Override
- public void visit(ExpressionCriteria obj) {
- obj.getExpression().acceptVisitor(this);
+ public void visit( ExpressionCriteria obj ) {
+ visitNode(obj.getExpression());
}
- public static String escapeSinglePart(String part) {
- if(isReservedWord(part)) {
- return ID_ESCAPE_CHAR + part + ID_ESCAPE_CHAR;
- }
- boolean escape = true;
- char start = part.charAt(0);
- if (start == '#' || start == '@' || StringUtil.isLetter(start)) {
- escape = false;
- for (int i = 1; !escape && i < part.length(); i++) {
- char c = part.charAt(i);
- escape = !StringUtil.isLetterOrDigit(c) && c != '_';
- }
- }
- if (escape) {
- return ID_ESCAPE_CHAR + escapeStringValue(part, "\"") + ID_ESCAPE_CHAR; //$NON-NLS-1$
- }
- return part;
+ public static String escapeSinglePart( String part ) {
+ if (isReservedWord(part)) {
+ return ID_ESCAPE_CHAR + part + ID_ESCAPE_CHAR;
+ }
+ boolean escape = true;
+ char start = part.charAt(0);
+ if (start == '#' || start == '@' || StringUtil.isLetter(start)) {
+ escape = false;
+ for (int i = 1; !escape && i < part.length(); i++) {
+ char c = part.charAt(i);
+ escape = !StringUtil.isLetterOrDigit(c) && c != '_';
+ }
+ }
+ if (escape) {
+ return ID_ESCAPE_CHAR + escapeStringValue(part, "\"") + ID_ESCAPE_CHAR; //$NON-NLS-1$
+ }
+ return part;
}
/**
- * Check whether a string is considered a reserved word or not. Subclasses
- * may override to change definition of reserved word.
+ * Check whether a string is considered a reserved word or not. Subclasses may override to change definition of reserved word.
+ *
* @param string String to check
* @return True if reserved word
*/
- static boolean isReservedWord(String string) {
- if(string == null) {
- return false;
- }
- return SQLConstants.isReservedWord(string);
+ static boolean isReservedWord( String string ) {
+ if (string == null) {
+ return false;
+ }
+ return SQLConstants.isReservedWord(string);
}
-
+
}
Deleted: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/IndexCondition.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.query.tempdata;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.TreeSet;
-
-import org.teiid.query.sql.lang.CompareCriteria;
-import org.teiid.query.sql.lang.Criteria;
-import org.teiid.query.sql.lang.IsNullCriteria;
-import org.teiid.query.sql.lang.MatchCriteria;
-import org.teiid.query.sql.lang.SetCriteria;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
-
-/**
- * Accumulates information from criteria about a specific index column.
- */
-class IndexCondition {
-
- static IndexCondition[] getIndexConditions(Criteria condition, List<ElementSymbol> keyColumns) {
- List<Criteria> crits = Criteria.separateCriteriaByAnd(condition);
- IndexCondition[] conditions = new IndexCondition[keyColumns.size()];
- for (int i = 0; i < conditions.length; i++) {
- conditions[i] = new IndexCondition();
- ElementSymbol keyColumn = keyColumns.get(i);
- for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
- Criteria criteria = critIter.next();
- if (criteria instanceof CompareCriteria) {
- CompareCriteria cc = (CompareCriteria)criteria;
- if (cc.getOperator() == CompareCriteria.NE
- || !(cc.getRightExpression() instanceof Constant)) {
- critIter.remove();
- continue;
- }
- if (!cc.getLeftExpression().equals(keyColumn)) {
- continue;
- }
- conditions[i].addCondition((Constant)cc.getRightExpression(), cc.getOperator());
- critIter.remove();
- } else if (criteria instanceof IsNullCriteria) {
- IsNullCriteria inc = (IsNullCriteria)criteria;
- if (inc.isNegated() || !inc.getExpression().equals(keyColumn)) {
- continue;
- }
- conditions[i].addCondition(new Constant(null), CompareCriteria.EQ);
- critIter.remove();
- } else {
- if (i > 0) {
- critIter.remove();
- continue;
- }
- if (criteria instanceof MatchCriteria) {
- MatchCriteria matchCriteria = (MatchCriteria)criteria;
- if (matchCriteria.isNegated() || !matchCriteria.getLeftExpression().equals(keyColumn) || !(matchCriteria.getRightExpression() instanceof Constant)) {
- continue;
- }
- Constant value = (Constant)matchCriteria.getRightExpression();
- String pattern = (String)value.getValue();
- boolean escaped = false;
- StringBuilder prefix = new StringBuilder();
- for (int j = 0; i < pattern.length(); j++) {
- char character = pattern.charAt(j);
-
- if (character == matchCriteria.getEscapeChar() && character != MatchCriteria.NULL_ESCAPE_CHAR) {
- if (escaped) {
- prefix.append(character);
- escaped = false;
- } else {
- escaped = true;
- }
- } else if (character == MatchCriteria.WILDCARD_CHAR || character == MatchCriteria.MATCH_CHAR) {
- break;
- } else {
- prefix.append(character);
- }
- }
- if (prefix.length() > 0) {
- conditions[i].addCondition(new Constant(prefix.toString()), CompareCriteria.GE);
- }
- } else if (criteria instanceof SetCriteria) {
- SetCriteria setCriteria = (SetCriteria)criteria;
- if (!setCriteria.getExpression().equals(keyColumn) || !setCriteria.isAllConstants()) {
- continue;
- }
- TreeSet<Constant> values = (TreeSet<Constant>) setCriteria.getValues();
- conditions[i].addSet(values);
- }
- }
- }
- }
- return conditions;
- }
-
- Constant lower = null;
- Constant upper = null;
- TreeSet<Constant> valueSet = new TreeSet<Constant>();
-
- void addCondition(Constant value, int comparisionMode) {
- switch (comparisionMode) {
- case CompareCriteria.EQ:
- valueSet.clear();
- valueSet.add(value);
- lower = null;
- upper = null;
- break;
- case CompareCriteria.GE:
- case CompareCriteria.GT:
- if (valueSet.isEmpty()) {
- lower = value;
- }
- break;
- case CompareCriteria.LE:
- case CompareCriteria.LT:
- if (valueSet.isEmpty()) {
- upper = value;
- }
- break;
- }
- }
-
- void addSet(TreeSet<Constant> values) {
- if (!valueSet.isEmpty()) {
- return;
- }
- lower = null;
- upper = null;
- valueSet.addAll(values);
- }
-
-}
\ No newline at end of file
Copied: trunk/engine/src/main/java/org/teiid/query/tempdata/IndexInfo.java (from rev 2524, branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/IndexInfo.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/IndexInfo.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/IndexInfo.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.tempdata;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.TreeSet;
+
+import org.teiid.common.buffer.TupleBrowser;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.processor.CollectionTupleSource;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+
+/**
+ * Accumulates information about index usage.
+ */
+class IndexInfo {
+
+ List<Object> lower = null;
+ List<Object> upper = null;
+ ArrayList<List<Object>> valueSet = new ArrayList<List<Object>>();
+ TempTable table;
+ Boolean ordering;
+ boolean covering;
+ TupleSource valueTs;
+ List<Criteria> nonCoveredCriteria = new LinkedList<Criteria>();
+ List<Criteria> coveredCriteria = new LinkedList<Criteria>();
+
+ public IndexInfo(TempTable table, final List<? extends SingleElementSymbol> projectedCols, final Criteria condition, OrderBy orderBy, boolean primary) {
+ this.table = table;
+ if (primary || this.table.getColumnMap().keySet().containsAll(projectedCols)) {
+ covering = true;
+ }
+ if (table.getPkLength() > 0) {
+ processCriteria(condition, primary);
+ if (orderBy != null && (covering || this.table.getColumnMap().keySet().containsAll(orderBy.getSortKeys()))) {
+ ordering = useIndexForOrderBy(orderBy);
+ }
+ }
+ }
+
+ private void processCriteria(Criteria condition, boolean primary) {
+ List<Criteria> crits = Criteria.separateCriteriaByAnd(condition);
+ if (!primary) {
+ for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
+ Criteria criteria = critIter.next();
+ if (table.getColumnMap().keySet().containsAll(ElementCollectorVisitor.getElements(criteria, false))) {
+ coveredCriteria.add(criteria);
+ } else {
+ covering = false;
+ nonCoveredCriteria.add(criteria);
+ critIter.remove();
+ }
+ }
+ }
+ for (int i = 0; i < table.getPkLength(); i++) {
+ ElementSymbol keyColumn = table.getColumns().get(i);
+ for (Iterator<Criteria> critIter = crits.iterator(); critIter.hasNext();) {
+ Criteria criteria = critIter.next();
+ if (criteria instanceof CompareCriteria) {
+ CompareCriteria cc = (CompareCriteria)criteria;
+ if (cc.getOperator() == CompareCriteria.NE
+ || !(cc.getRightExpression() instanceof Constant)) {
+ critIter.remove();
+ continue;
+ }
+ if (!cc.getLeftExpression().equals(keyColumn)) {
+ continue;
+ }
+ this.addCondition(i, (Constant)cc.getRightExpression(), cc.getOperator());
+ critIter.remove();
+ } else if (criteria instanceof IsNullCriteria) {
+ IsNullCriteria inc = (IsNullCriteria)criteria;
+ if (inc.isNegated() || !inc.getExpression().equals(keyColumn)) {
+ continue;
+ }
+ this.addCondition(i, new Constant(null), CompareCriteria.EQ);
+ critIter.remove();
+ } else {
+ if (i > 0) {
+ critIter.remove();
+ continue;
+ }
+ if (criteria instanceof MatchCriteria) {
+ MatchCriteria matchCriteria = (MatchCriteria)criteria;
+ if (matchCriteria.isNegated() || !matchCriteria.getLeftExpression().equals(keyColumn) || !(matchCriteria.getRightExpression() instanceof Constant)) {
+ continue;
+ }
+ Constant value = (Constant)matchCriteria.getRightExpression();
+ String pattern = (String)value.getValue();
+ boolean escaped = false;
+ StringBuilder prefix = new StringBuilder();
+ for (int j = 0; i < pattern.length(); j++) {
+ char character = pattern.charAt(j);
+
+ if (character == matchCriteria.getEscapeChar() && character != MatchCriteria.NULL_ESCAPE_CHAR) {
+ if (escaped) {
+ prefix.append(character);
+ escaped = false;
+ } else {
+ escaped = true;
+ }
+ } else if (character == MatchCriteria.WILDCARD_CHAR || character == MatchCriteria.MATCH_CHAR) {
+ break;
+ } else {
+ prefix.append(character);
+ }
+ }
+ if (prefix.length() > 0) {
+ this.addCondition(i, new Constant(prefix.toString()), CompareCriteria.GE);
+ }
+ } else if (criteria instanceof SetCriteria) {
+ SetCriteria setCriteria = (SetCriteria)criteria;
+ if (!setCriteria.getExpression().equals(keyColumn) || !setCriteria.isAllConstants()) {
+ continue;
+ }
+ TreeSet<Constant> values = (TreeSet<Constant>) setCriteria.getValues();
+ this.addSet(i, values);
+ }
+ }
+ }
+ }
+ }
+
+ void addCondition(int i, Constant value, int comparisionMode) {
+ switch (comparisionMode) {
+ case CompareCriteria.EQ:
+ if (i == 0) {
+ valueSet.clear();
+ valueSet.add(new ArrayList<Object>(table.getPkLength()));
+ }
+ if (valueSet.size() == 1) {
+ valueSet.get(0).add(value.getValue());
+ }
+ lower = null;
+ upper = null;
+ break;
+ case CompareCriteria.GE:
+ case CompareCriteria.GT:
+ if (valueSet.isEmpty()) {
+ if (i == 0) {
+ lower = new ArrayList<Object>(table.getPkLength());
+ lower.add(value.getValue());
+ } if (lower != null && lower.size() == i) {
+ lower.add(value.getValue());
+ }
+ }
+ break;
+ case CompareCriteria.LE:
+ case CompareCriteria.LT:
+ if (valueSet.isEmpty()) {
+ if (i == 0) {
+ upper = new ArrayList<Object>(table.getPkLength());
+ upper.add(value.getValue());
+ } else if (upper != null && upper.size() == i) {
+ upper.add(value.getValue());
+ }
+ }
+ break;
+ }
+ }
+
+ void addSet(int i, TreeSet<Constant> values) {
+ if (!valueSet.isEmpty()) {
+ return;
+ }
+ if (i == 0) {
+ for (Constant constant : values) {
+ List<Object> value = new ArrayList<Object>(table.getPkLength());
+ value.add(constant.getValue());
+ valueSet.add(value);
+ }
+ lower = null;
+ upper = null;
+ }
+ }
+
+ /**
+ * Return a non-null direction if the index can be used, otherwise null.
+ * @param orderBy
+ * @return
+ */
+ private Boolean useIndexForOrderBy(OrderBy orderBy) {
+ Boolean direction = null;
+ int[] orderByIndexes = RelationalNode.getProjectionIndexes(this.table.getColumnMap(), orderBy.getSortKeys());
+ for (int i = 0; i < table.getPkLength(); i++) {
+ if (orderByIndexes.length <= i) {
+ break;
+ }
+ if (orderByIndexes[i] != i) {
+ return null;
+ }
+ }
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ if (item.getNullOrdering() != null) {
+ return null;
+ }
+ if (item.isAscending()) {
+ if (direction == null) {
+ direction = OrderBy.ASC;
+ } else if (direction != OrderBy.ASC) {
+ return null;
+ }
+ } else if (direction == null) {
+ direction = OrderBy.DESC;
+ } else if (direction != OrderBy.DESC) {
+ return null;
+ }
+ }
+ return direction;
+ }
+
+ TupleBrowser createTupleBrowser() throws TeiidComponentException {
+ boolean direction = OrderBy.ASC;
+ if (ordering != null) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Using index for ordering"); //$NON-NLS-1$
+ direction = ordering;
+ }
+ if (valueTs != null) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Using index value set"); //$NON-NLS-1$
+ return new TupleBrowser(this.table.getTree(), valueTs, direction);
+ }
+ if (!valueSet.isEmpty()) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Using index value set"); //$NON-NLS-1$
+ CollectionTupleSource cts = null;
+ if (direction == OrderBy.ASC) {
+ cts = new CollectionTupleSource(valueSet.iterator());
+ } else {
+ cts = new CollectionTupleSource(new Iterator<List<Object>>() {
+ ListIterator<List<Object>> iter = valueSet.listIterator(valueSet.size());
+ @Override
+ public boolean hasNext() {
+ return iter.hasPrevious();
+ }
+ @Override
+ public List<Object> next() {
+ return iter.previous();
+ }
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ });
+ }
+ return new TupleBrowser(this.table.getTree(), cts, direction);
+ }
+ if (lower != null || upper != null) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Using index for range query", lower, upper); //$NON-NLS-1$
+ }
+ return new TupleBrowser(this.table.getTree(), lower, upper, direction);
+ }
+
+}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,9 +58,7 @@
import org.teiid.query.sql.lang.CacheHint;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.OrderBy;
-import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetClauseList;
-import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
@@ -123,14 +122,16 @@
private TupleBrowser browser;
private QueryTupleSource(TupleBrowser browser, Map map,
- List<SingleElementSymbol> projectedCols, Criteria condition) {
+ List<? extends SingleElementSymbol> projectedCols, Criteria condition) {
this.browser = browser;
this.indexes = RelationalNode.getProjectionIndexes(map, projectedCols);
this.eval = new Evaluator(map, null, null);
this.condition = condition;
this.project = shouldProject();
this.reserved = reserveBuffers();
- lock.readLock().lock();
+ if (updatable) {
+ lock.readLock().lock();
+ }
}
@Override
@@ -143,9 +144,6 @@
reserved = 0;
return null;
}
- if (rowId != null) {
- next = next.subList(1, next.size());
- }
if (condition != null && !eval.evaluate(condition, next)) {
continue;
}
@@ -158,7 +156,9 @@
@Override
public void closeSource() {
- lock.readLock().unlock();
+ if (updatable) {
+ lock.readLock().unlock();
+ }
bm.releaseBuffers(reserved);
reserved = 0;
browser.closeSource();
@@ -259,9 +259,11 @@
private TempMetadataID tid;
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private boolean updatable = true;
+ private LinkedHashMap<List<ElementSymbol>, TempTable> indexTables;
private int keyBatchSize;
private int leafBatchSize;
+ private Map columnMap;
TempTable(TempMetadataID tid, BufferManager bm, List<ElementSymbol> columns, int primaryKeyLength, String sessionID) {
this.tid = tid;
@@ -275,71 +277,93 @@
} else {
tree = bm.createSTree(columns, sessionID, primaryKeyLength);
}
+ this.columnMap = RelationalNode.createLookupMap(columns);
this.columns = columns;
this.sessionID = sessionID;
this.keyBatchSize = bm.getSchemaSize(columns);
this.leafBatchSize = bm.getSchemaSize(columns.subList(0, primaryKeyLength));
}
+ void addIndex(List<ElementSymbol> indexColumns) throws TeiidComponentException, TeiidProcessingException {
+ List<ElementSymbol> keyColumns = columns.subList(0, tree.getKeyLength());
+ if (keyColumns.equals(indexColumns) || (indexTables != null && indexTables.containsKey(indexColumns))) {
+ return;
+ }
+ List<ElementSymbol> allColumns = new ArrayList<ElementSymbol>(indexColumns);
+ for (ElementSymbol elementSymbol : keyColumns) {
+ if (allColumns.indexOf(elementSymbol) < 0) {
+ allColumns.add(elementSymbol);
+ }
+ }
+ TempTable indexTable = new TempTable(new TempMetadataID("idx", Collections.EMPTY_LIST), this.bm, allColumns, allColumns.size(), this.sessionID); //$NON-NLS-1$
+ indexTable.setPreferMemory(this.tree.isPreferMemory());
+ indexTable.lock = this.lock;
+ if (indexTables == null) {
+ indexTables = new LinkedHashMap<List<ElementSymbol>, TempTable>();
+ indexTables.put(indexColumns, indexTable);
+ }
+ //TODO: ordered insert optimization
+ TupleSource ts = createTupleSource(allColumns, null, null);
+ indexTable.insert(ts, allColumns);
+ }
+
private int reserveBuffers() {
return bm.reserveBuffers(leafBatchSize + (tree.getHeight() - 1)*keyBatchSize, BufferReserveMode.WAIT);
}
- public TupleSource createTupleSource(final List<SingleElementSymbol> projectedCols, final Criteria condition, OrderBy orderBy) throws TeiidComponentException, TeiidProcessingException {
- Map map = RelationalNode.createLookupMap(getColumns());
-
- Boolean direction = null;
- boolean orderByUsingIndex = false;
- if (orderBy != null && rowId == null) {
- int[] orderByIndexes = RelationalNode.getProjectionIndexes(map, orderBy.getSortKeys());
- if (orderByIndexes.length < tree.getKeyLength()) {
- orderByUsingIndex = false;
- } else {
- orderByUsingIndex = true;
- for (int i = 0; i < tree.getKeyLength(); i++) {
- if (orderByIndexes[i] != i) {
- orderByUsingIndex = false;
- break;
- }
+ public TupleSource createTupleSource(final List<? extends SingleElementSymbol> projectedCols, final Criteria condition, OrderBy orderBy) throws TeiidComponentException, TeiidProcessingException {
+ IndexInfo primary = new IndexInfo(this, projectedCols, condition, orderBy, true);
+ IndexInfo ii = primary;
+ if (indexTables != null && (condition != null || orderBy != null) && ii.valueSet.size() != 1) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Considering indexes on table", this, "for query", projectedCols, condition, orderBy); //$NON-NLS-1$ //$NON-NLS-2$
+ int rowCost = this.tree.getRowCount();
+ int bestCost = estimateCost(orderBy, ii, rowCost);
+ for (TempTable table : this.indexTables.values()) {
+ IndexInfo secondary = new IndexInfo(table, projectedCols, condition, orderBy, false);
+ int cost = estimateCost(orderBy, secondary, rowCost);
+ if (cost < bestCost) {
+ ii = secondary;
+ bestCost = cost;
}
- if (orderByUsingIndex) {
- for (int i = 0; i < tree.getKeyLength(); i++) {
- OrderByItem item = orderBy.getOrderByItems().get(i);
- if (item.getNullOrdering() != null) {
- orderByUsingIndex = false;
- break;
- }
- if (item.isAscending()) {
- if (direction == null) {
- direction = OrderBy.ASC;
- } else if (direction != OrderBy.ASC) {
- orderByUsingIndex = false;
- break;
- }
- } else if (direction == null) {
- direction = OrderBy.DESC;
- } else if (direction != OrderBy.DESC) {
- orderByUsingIndex = false;
- break;
- }
- }
- }
}
+ LogManager.logDetail(LogConstants.CTX_DQP, "Choose index", ii.table, "covering:", ii.coveredCriteria,"ordering:", ii.ordering); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (ii.covering) {
+ return ii.table.createTupleSource(projectedCols, condition, orderBy, ii);
+ }
+ List<ElementSymbol> pkColumns = this.columns.subList(0, this.tree.getKeyLength());
+ if (ii.ordering != null) {
+ //use order and join
+ primary.valueTs = ii.table.createTupleSource(pkColumns,
+ Criteria.combineCriteria(ii.coveredCriteria), orderBy, ii);
+ primary.ordering = null;
+ return createTupleSource(projectedCols, Criteria.combineCriteria(ii.nonCoveredCriteria), null, primary);
+ }
+ //order by pk to localize lookup costs, then join
+ OrderBy pkOrderBy = new OrderBy();
+ for (ElementSymbol elementSymbol : pkColumns) {
+ pkOrderBy.addVariable(elementSymbol);
+ }
+ primary.valueTs = ii.table.createTupleSource(pkColumns,
+ Criteria.combineCriteria(ii.coveredCriteria), pkOrderBy, ii);
+ return createTupleSource(projectedCols, Criteria.combineCriteria(ii.nonCoveredCriteria), orderBy, primary);
}
- if (!orderByUsingIndex) {
- direction = OrderBy.ASC;
- }
+ return createTupleSource(projectedCols, condition, orderBy, ii);
+ }
+
+ private TupleSource createTupleSource(
+ final List<? extends SingleElementSymbol> projectedCols,
+ final Criteria condition, OrderBy orderBy, IndexInfo ii)
+ throws TeiidComponentException, TeiidProcessingException {
+ TupleBrowser browser = ii.createTupleBrowser();
+ TupleSource ts = new QueryTupleSource(browser, columnMap, projectedCols, condition);
- TupleBrowser browser = createTupleBrower(condition, direction);
- TupleSource ts = new QueryTupleSource(browser, map, projectedCols, condition);
-
boolean usingQueryTupleSource = false;
try {
TupleBuffer tb = null;
- if (!orderByUsingIndex && orderBy != null) {
+ if (ii.ordering == null && orderBy != null) {
SortUtility sort = new SortUtility(ts, orderBy.getOrderByItems(), Mode.SORT, bm, sessionID, projectedCols);
tb = sort.sort();
- } else if (!updatable) {
+ } else if (updatable) {
tb = bm.createTupleBuffer(projectedCols, sessionID, TupleSourceType.PROCESSOR);
List<?> next = null;
while ((next = ts.nextTuple()) != null) {
@@ -359,62 +383,32 @@
}
}
- private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException {
- List<Object> lower = null;
- List<Object> upper = null;
- List<List<Object>> values = null;
- if (condition != null && rowId == null) {
- IndexCondition[] indexConditions = IndexCondition.getIndexConditions(condition, columns.subList(0, tree.getKeyLength()));
- for (int i = 0; i < indexConditions.length; i++) {
- IndexCondition indexCondition = indexConditions[i];
- if (indexCondition.lower != null) {
- if (i == 0) {
- lower = new ArrayList<Object>(tree.getKeyLength());
- lower.add(indexCondition.lower.getValue());
- } if (lower != null && lower.size() == i) {
- lower.add(indexCondition.lower.getValue());
- }
- }
- if (indexCondition.upper != null) {
- if (i == 0) {
- upper = new ArrayList<Object>(tree.getKeyLength());
- upper.add(indexCondition.upper.getValue());
- } else if (upper != null && upper.size() == i) {
- upper.add(indexCondition.upper.getValue());
- }
- }
- if (!indexCondition.valueSet.isEmpty()) {
- if (i == 0) {
- values = new ArrayList<List<Object>>();
- for (Constant constant : indexCondition.valueSet) {
- List<Object> value = new ArrayList<Object>(tree.getKeyLength());
- value.add(constant.getValue());
- values.add(value);
- }
- } else if (values != null && values.size() == 1 && indexCondition.valueSet.size() == 1) {
- values.iterator().next().add(indexCondition.valueSet.first().getValue());
- }
- }
- }
- if (indexConditions.length > 0) {
- if (values != null) {
- List<Object> value = values.iterator().next();
- if (value.size() != tree.getKeyLength()) {
- values = null;
- lower = new ArrayList<Object>(value);
- lower.addAll(Collections.nCopies(tree.getKeyLength() - value.size(), null));
- upper = new ArrayList<Object>(value);
- }
- } else if (lower != null) {
- lower.addAll(Collections.nCopies(tree.getKeyLength() - lower.size(), null));
- }
- }
+ /**
+ * TODO: this could easily use statistics - the tree level 1 would be an ideal place
+ * to compute them, since it minimizes page loads, and is a random sample.
+ * TODO: this should also factor in the block size
+ */
+ private int estimateCost(OrderBy orderBy, IndexInfo ii, int rowCost) {
+ if (ii.valueSet.size() != 0) {
+ int length = ii.valueSet.get(0).size();
+ rowCost = ii.valueSet.size() * (ii.table.getPkLength() - length + 1);
+ } else if (ii.upper != null) {
+ rowCost /= 3;
+ } else if (ii.lower != null) {
+ rowCost /= 3;
}
- if (values != null) {
- return new TupleBrowser(this.tree, values, direction);
+ int cost = Math.max(1, rowCost);
+ if (cost > 1 && (!ii.covering || (orderBy != null && ii.ordering == null))) {
+ cost *= (32 - Integer.numberOfLeadingZeros(cost - 1));
}
- return new TupleBrowser(this.tree, lower, upper, direction);
+ return cost;
}
+
+ private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException {
+ IndexInfo ii = new IndexInfo(this, null, condition, null, true);
+ ii.ordering = direction;
+ return ii.createTupleBrowser();
+ }
public int getRowCount() {
return tree.getRowCount();
@@ -426,6 +420,11 @@
public void remove() {
tree.remove();
+ if (this.indexTables != null) {
+ for (TempTable indexTable : this.indexTables.values()) {
+ indexTable.remove();
+ }
+ }
}
public List<ElementSymbol> getColumns() {
@@ -546,7 +545,7 @@
return CollectionTupleSource.createUpdateCountTupleSource(updateCount);
}
- private void insertTuple(List<Object> list, boolean ordered) throws TeiidComponentException, TeiidProcessingException {
+ private void insertTuple(List<?> list, boolean ordered) throws TeiidComponentException, TeiidProcessingException {
if (tree.insert(list, ordered?InsertMode.ORDERED:InsertMode.NEW) != null) {
throw new TeiidProcessingException(QueryPlugin.Util.getString("TempTable.duplicate_key")); //$NON-NLS-1$
}
@@ -562,9 +561,26 @@
try {
lock.writeLock().lock();
if (remove) {
- return tree.remove(tuple);
+ List<?> result = tree.remove(tuple);
+ if (result == null) {
+ return null;
+ }
+ if (indexTables != null) {
+ for (TempTable index : this.indexTables.values()) {
+ tuple = RelationalNode.projectTuple(RelationalNode.getProjectionIndexes(index.getColumnMap(), index.columns), result);
+ index.tree.remove(tuple);
+ }
+ }
+ return result;
}
- return tree.insert(tuple, InsertMode.UPDATE);
+ List<?> result = tree.insert(tuple, InsertMode.UPDATE);
+ if (indexTables != null) {
+ for (TempTable index : this.indexTables.values()) {
+ tuple = RelationalNode.projectTuple(RelationalNode.getProjectionIndexes(index.getColumnMap(), index.columns), tuple);
+ index.tree.insert(tuple, InsertMode.UPDATE);
+ }
+ }
+ return result;
} finally {
lock.writeLock().unlock();
}
@@ -582,6 +598,11 @@
void setUpdatable(boolean updatable) {
this.updatable = updatable;
+ if (this.indexTables != null) {
+ for (TempTable index : this.indexTables.values()) {
+ index.setUpdatable(updatable);
+ }
+ }
}
CacheHint getCacheHint() {
@@ -598,5 +619,18 @@
public boolean isUpdatable() {
return updatable;
}
+
+ @Override
+ public String toString() {
+ return tid.getID() + " (" + columns + ")\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ Map getColumnMap() {
+ return this.columnMap;
+ }
+
+ STree getTree() {
+ return tree;
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
@@ -36,12 +38,16 @@
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.StringUtil;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.language.SQLConstants.Reserved;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -52,6 +58,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.parser.ParseInfo;
import org.teiid.query.processor.BatchCollector;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
@@ -65,8 +72,10 @@
import org.teiid.query.sql.lang.Delete;
import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Option;
import org.teiid.query.sql.lang.ProcedureContainer;
import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.Update;
import org.teiid.query.sql.navigator.PostOrderNavigator;
@@ -93,28 +102,15 @@
private ProcessorDataManager processorDataManager;
private BufferManager bufferManager;
-
+ private SessionAwareCache<CachedResults> cache;
private Executor executor;
- public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager) {
- this(processorDataManager, bufferManager, new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- });
- }
-
- /**
- * Constructor takes the "real" ProcessorDataManager that this object will be a proxy to,
- * and will pass most calls through to transparently. Only when a request is registered for
- * a temp group will this proxy do it's thing.
- * @param processorDataManager the real ProcessorDataManager that this object is a proxy to
- */
- public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager, Executor executor){
+ public TempTableDataManager(ProcessorDataManager processorDataManager, BufferManager bufferManager,
+ Executor executor, SessionAwareCache<CachedResults> cache){
this.processorDataManager = processorDataManager;
this.bufferManager = bufferManager;
this.executor = executor;
+ this.cache = cache;
}
public TupleSource registerRequest(
@@ -141,12 +137,17 @@
return registerQuery(context, contextStore, query);
}
if (command instanceof ProcedureContainer) {
-
- if (command instanceof StoredProcedure && CoreConstants.SYSTEM_MODEL.equals(modelName)) {
- TupleSource result = handleSystemProcedures(context, command);
- if (result != null) {
- return result;
+ if (command instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)command;
+ if (CoreConstants.SYSTEM_MODEL.equals(modelName)) {
+ TupleSource result = handleSystemProcedures(context, proc);
+ if (result != null) {
+ return result;
+ }
+ } else if (proc.getGroup().isGlobalTable()) {
+ return handleCachedProcedure(context, proc);
}
+ return null; //it's not a stored procedure we want to handle
}
GroupSymbol group = ((ProcedureContainer)command).getGroup();
@@ -200,18 +201,62 @@
return null;
}
- private TupleSource handleSystemProcedures(CommandContext context, Command command)
+ private TupleSource handleCachedProcedure(CommandContext context,
+ StoredProcedure proc) throws TeiidComponentException,
+ QueryMetadataException, TeiidProcessingException {
+ String fullName = context.getMetadata().getFullName(proc.getProcedureID());
+ LogManager.logDetail(LogConstants.CTX_DQP, "processing cached procedure request for", fullName); //$NON-NLS-1$
+ LinkedList<Object> vals = new LinkedList<Object>();
+ for (SPParameter param : proc.getInputParameters()) {
+ vals.add(((Constant)param.getExpression()).getValue());
+ }
+ //collapse the hash to single byte for the key to restrict the possible results to 256
+ int hash = vals.hashCode();
+ hash |= (hash >>> 16);
+ hash |= (hash >>> 8);
+ hash &= 0x000000ff;
+ CacheID cid = new CacheID(new ParseInfo(), fullName + hash, context.getVdbName(),
+ context.getVdbVersion(), context.getConnectionID(), context.getUserName());
+ cid.setParameters(vals);
+ CachedResults results = cache.get(cid);
+ if (results != null) {
+ TupleBuffer buffer = results.getResults();
+ return buffer.createIndexedTupleSource();
+ }
+ //construct a query with a no cache hint
+ //note that it's safe to use the stringified form of the parameters because
+ //it's not possible to use xml/clob/blob/object
+ CacheHint hint = proc.getCacheHint();
+ proc.setCacheHint(null);
+ Option option = new Option();
+ option.setNoCache(true);
+ option.addNoCacheGroup(fullName);
+ proc.setOption(option);
+ int determinismLevel = context.resetDeterminismLevel();
+ QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(proc.toString(), fullName.toUpperCase(), context);
+ qp.setNonBlocking(true);
+ BatchCollector bc = qp.createBatchCollector();
+ TupleBuffer tb = bc.collectTuples();
+ CachedResults cr = new CachedResults();
+ cr.setResults(tb);
+ cr.setHint(hint);
+ cache.put(cid, context.getDeterminismLevel(), cr, hint != null?hint.getTtl():null);
+ context.setDeterminismLevel(determinismLevel);
+ return tb.createIndexedTupleSource();
+ }
+
+ private TupleSource handleSystemProcedures(CommandContext context, StoredProcedure proc)
throws TeiidComponentException, QueryMetadataException,
QueryProcessingException, QueryResolverException,
QueryValidatorException, TeiidProcessingException,
ExpressionEvaluationException {
QueryMetadataInterface metadata = context.getMetadata();
TempTableStore globalStore = context.getGlobalTableStore();
- StoredProcedure proc = (StoredProcedure)command;
if (StringUtil.endsWithIgnoreCase(proc.getProcedureCallableName(), REFRESHMATVIEW)) {
Object groupID = validateMatView(metadata, proc);
String matViewName = metadata.getFullName(groupID);
String matTableName = RelationalPlanner.MAT_PREFIX+matViewName.toUpperCase();
+ LogManager.logDetail(LogConstants.CTX_MATVIEWS, "processing refreshmatview for", matViewName); //$NON-NLS-1$
MatTableInfo info = globalStore.getMatTableInfo(matTableName);
boolean invalidate = Boolean.TRUE.equals(((Constant)proc.getParameter(1).getExpression()).getValue());
MatState oldState = info.setState(MatState.NEEDS_LOADING, invalidate?Boolean.FALSE:null);
@@ -248,8 +293,8 @@
Constant key = (Constant)proc.getParameter(2).getExpression();
LogManager.logInfo(LogConstants.CTX_MATVIEWS, QueryExecPlugin.Util.getString("TempTableDataManager.row_refresh", matViewName, key)); //$NON-NLS-1$
String queryString = Reserved.SELECT + " * " + Reserved.FROM + ' ' + matViewName + ' ' + Reserved.WHERE + ' ' + //$NON-NLS-1$
- metadata.getFullName(ids.iterator().next()) + '=' + key.toString() + ' ' + Reserved.OPTION + ' ' + Reserved.NOCACHE;
- QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(queryString, matViewName.toUpperCase(), context);
+ metadata.getFullName(ids.iterator().next()) + " = ?" + ' ' + Reserved.OPTION + ' ' + Reserved.NOCACHE; //$NON-NLS-1$
+ QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(queryString, matViewName.toUpperCase(), context, key.getValue());
qp.setNonBlocking(true);
TupleSource ts = new BatchCollector.BatchProducerTupleSource(qp);
tempTable = globalStore.getOrCreateTempTable(matTableName, new Query(), bufferManager, false);
@@ -340,36 +385,48 @@
QueryMetadataInterface metadata = context.getMetadata();
Create create = new Create();
create.setTable(group);
- create.setColumns(ResolverUtil.resolveElementsInGroup(group, metadata));
+ List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
+ create.setColumns(allColumns);
Object pk = metadata.getPrimaryKey(group.getMetadataID());
if (pk != null) {
- for (Object col : metadata.getElementIDsInKey(pk)) {
- create.getPrimaryKey().add(create.getColumns().get(metadata.getPosition(col)-1));
- }
+ List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk);
+ create.getPrimaryKey().addAll(pkColumns);
}
TempTable table = globalStore.addTempTable(tableName, create, bufferManager, false);
table.setUpdatable(false);
CacheHint hint = table.getCacheHint();
+ boolean updatable = false;
if (hint != null) {
table.setPreferMemory(hint.getPrefersMemory());
if (hint.getTtl() != null) {
info.setTtl(table.getCacheHint().getTtl());
}
if (pk != null) {
- table.setUpdatable(hint.isUpdatable());
+ updatable = hint.isUpdatable();
}
}
int rowCount = -1;
try {
+ String fullName = metadata.getFullName(group.getMetadataID());
//TODO: order by primary key nulls first - then have an insert ordered optimization
//TODO: use the getCommand logic in RelationalPlanner to reuse commands for this.
String transformation = metadata.getVirtualPlan(group.getMetadataID()).getQuery();
- QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(transformation, group.getCanonicalName(), context);
+ QueryProcessor qp = context.getQueryProcessorFactory().createQueryProcessor(transformation, fullName, context);
qp.setNonBlocking(true);
TupleSource ts = new BatchCollector.BatchProducerTupleSource(qp);
//TODO: if this insert fails, it's unnecessary to do the undo processing
table.insert(ts, table.getColumns());
rowCount = table.getRowCount();
+ //TODO: could pre-process indexes to remove overlap
+ for (Object index : metadata.getIndexesInGroup(group.getMetadataID())) {
+ List<ElementSymbol> columns = resolveIndex(metadata, allColumns, index);
+ table.addIndex(columns);
+ }
+ for (Object key : metadata.getUniqueKeysInGroup(group.getMetadataID())) {
+ List<ElementSymbol> columns = resolveIndex(metadata, allColumns, key);
+ table.addIndex(columns);
+ }
+ table.setUpdatable(updatable);
} catch (TeiidComponentException e) {
LogManager.logError(LogConstants.CTX_MATVIEWS, e, QueryExecPlugin.Util.getString("TempTableDataManager.failed_load", tableName)); //$NON-NLS-1$
throw e;
@@ -388,6 +445,20 @@
return rowCount;
}
+ /**
+ * Return a list of ElementSymbols for the given index/key object
+ */
+ private List<ElementSymbol> resolveIndex(QueryMetadataInterface metadata,
+ List<ElementSymbol> allColumns, Object pk)
+ throws TeiidComponentException, QueryMetadataException {
+ Collection<?> pkIds = metadata.getElementIDsInKey(pk);
+ List<ElementSymbol> pkColumns = new ArrayList<ElementSymbol>(pkIds.size());
+ for (Object col : pkIds) {
+ pkColumns.add(allColumns.get(metadata.getPosition(col)-1));
+ }
+ return pkColumns;
+ }
+
public Object lookupCodeValue(CommandContext context, String codeTableName,
String returnElementName, String keyElementName, Object keyValue)
throws BlockedException, TeiidComponentException,
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,11 +33,16 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.ArgCheck;
+import org.teiid.dqp.internal.process.PreparedPlan;
+import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.SecurityFunctionEvaluator;
import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.relational.PlanToProcessConverter;
+import org.teiid.query.parser.ParseInfo;
import org.teiid.query.processor.QueryProcessor;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
@@ -67,7 +72,7 @@
private Serializable commandPayload;
- private String vdbName;
+ private String vdbName = ""; //$NON-NLS-1$
private int vdbVersion;
@@ -101,6 +106,11 @@
private BufferManager bufferManager;
private TempTableStore globalTables;
+
+ private SessionAwareCache<PreparedPlan> planCache;
+
+ private boolean resultSetCacheEnabled = true;
+
}
private GlobalState globalState = new GlobalState();
@@ -136,13 +146,23 @@
}
- public CommandContext() {
+ public CommandContext() {
}
+ private CommandContext(GlobalState state) {
+ this.globalState = state;
+ }
+
public int getDeterminismLevel() {
return globalState.determinismLevel;
}
+ public int resetDeterminismLevel() {
+ int result = globalState.determinismLevel;
+ globalState.determinismLevel = 0;
+ return result;
+ }
+
public void setDeterminismLevel(int level) {
globalState.determinismLevel = Math.max(globalState.determinismLevel, level);
}
@@ -163,8 +183,7 @@
}
public CommandContext clone() {
- CommandContext clone = new CommandContext();
- clone.globalState = this.globalState;
+ CommandContext clone = new CommandContext(this.globalState);
clone.variableContext = this.variableContext;
clone.tempTableStore = this.tempTableStore;
if (this.recursionStack != null) {
@@ -454,5 +473,42 @@
public void setNonBlocking(boolean nonBlocking) {
this.nonBlocking = nonBlocking;
}
+
+ public void setPreparedPlanCache(SessionAwareCache<PreparedPlan> cache) {
+ this.globalState.planCache = cache;
+ }
+
+ public PreparedPlan getPlan(String key) {
+ if (this.globalState.planCache == null) {
+ return null;
+ }
+ CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionID(), getUserName());
+ PreparedPlan pp = this.globalState.planCache.get(id);
+ if (pp != null) {
+ if (id.getSessionId() != null) {
+ setDeterminismLevel(FunctionMethod.USER_DETERMINISTIC);
+ } else if (id.getUserName() != null) {
+ setDeterminismLevel(FunctionMethod.SESSION_DETERMINISTIC);
+ }
+ return pp;
+ }
+ return null;
+ }
+
+ public void putPlan(String key, PreparedPlan plan, int determinismLevel) {
+ if (this.globalState.planCache == null) {
+ return;
+ }
+ CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(), getConnectionID(), getUserName());
+ this.globalState.planCache.put(id, determinismLevel, plan, null);
+ }
+
+ public boolean isResultSetCacheEnabled() {
+ return globalState.resultSetCacheEnabled;
+ }
+
+ public void setResultSetCacheEnabled(boolean resultSetCacheEnabled) {
+ this.globalState.resultSetCacheEnabled = resultSetCacheEnabled;
+ }
}
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1171,17 +1171,10 @@
StoredProcedure storedProcedure = new StoredProcedure();
String procName = null;
Option option = null;
- Token execToken = null;
}
{
(
- (
- (execToken = <EXEC> { setQueryCacheOption(execToken, info); })
- |
- (execToken = <EXECUTE> { setQueryCacheOption(execToken, info); })
- |
- (execToken = <CALL> { setQueryCacheOption(execToken, info); })
- )
+ (<EXEC> | <EXECUTE> | <CALL>)
procName = id()
{
storedProcedure.setProcedureName(procName);
@@ -1594,13 +1587,9 @@
SelectSymbol symbol = null;
Select select = new Select();
info.aggregatesAllowed = true;
- Token selectToken = null;
}
{
- selectToken = <SELECT>
- {
- setQueryCacheOption(selectToken, info);
- }
+ <SELECT>
[<ALL> | (<DISTINCT> {isDistinct=true;})]
(<STAR>
{
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-09-03 01:45:43 UTC (rev 2526)
@@ -864,6 +864,9 @@
ResolveVariablesVisitor.reserved_word_for_temporary_used=Cursor names cannot begin with "#" as that indicates the name of a temporary table: {0}.
SimpleQueryResolver.materialized_table_not_used=The query against {0} did not use materialization table {1} due to the use of OPTION NOCACHE.
SimpleQueryResolver.cache_hint_used=Loading materialized view {1} for view {0} using cache hint {2}.
+SimpleQueryResolver.procedure_cache_used=Procedure caching will be used for {0}.
+SimpleQueryResolver.procedure_cache_not_usable=Procedure caching will not be used for {0} since the result set cache is disabled or the results/parameters cannot be cached.
+SimpleQueryResolver.procedure_cache_not_used=Procedure caching will not be used for {0} due to the use of OPTION NOCACHE.
ValidationVisitor.input_variable_data_type_not_match=The expression "{0}" assigned to input variable "{1}" is of type "{2}" which cannot be implicitly converted to the expected type "{3}".
ValidationVisitor.input_variable_can_not_in_function=Input variable "{0}" cannot be an argument of a function in the criteria.
ValidationVisitor.groupby_subquery=Expressions used in a GROUP BY cannot be constant and must not contain subqueries: "{0}".
Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/process/SimpleQueryProcessorFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/SimpleQueryProcessorFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/SimpleQueryProcessorFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import org.teiid.common.buffer.BufferManager;
-import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.id.IDGenerator;
-import org.teiid.query.analysis.AnalysisRecord;
-import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.optimizer.QueryOptimizer;
-import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
-import org.teiid.query.parser.QueryParser;
-import org.teiid.query.processor.ProcessorDataManager;
-import org.teiid.query.processor.ProcessorPlan;
-import org.teiid.query.processor.QueryProcessor;
-import org.teiid.query.resolver.QueryResolver;
-import org.teiid.query.rewriter.QueryRewriter;
-import org.teiid.query.sql.lang.Command;
-import org.teiid.query.util.CommandContext;
-
-
-
-public class SimpleQueryProcessorFactory implements QueryProcessor.ProcessorFactory {
-
- private QueryMetadataInterface metadata;
- private CapabilitiesFinder finder;
- private IDGenerator idGenerator;
- private BufferManager bufferMgr;
- private ProcessorDataManager dataMgr;
-
- public SimpleQueryProcessorFactory(BufferManager bufferMgr,
- ProcessorDataManager dataMgr, CapabilitiesFinder finder,
- IDGenerator idGenerator, QueryMetadataInterface metadata) {
- this.bufferMgr = bufferMgr;
- this.dataMgr = dataMgr;
- this.finder = finder;
- this.idGenerator = idGenerator;
- this.metadata = metadata;
- }
-
- @Override
- public QueryProcessor createQueryProcessor(String sql, String recursionGroup, CommandContext commandContext)
- throws TeiidProcessingException, TeiidComponentException {
- Command command = QueryParser.getQueryParser().parseCommand(sql);
- QueryResolver.resolveCommand(command, metadata);
- command = QueryRewriter.rewrite(command, metadata, commandContext);
- ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata,
- idGenerator, finder, AnalysisRecord.createNonRecordingRecord(),
- commandContext);
-
- CommandContext copy = commandContext.clone();
- return new QueryProcessor(plan, copy, bufferMgr, dataMgr);
- }
-}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,14 +22,16 @@
package org.teiid.dqp.internal.process;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import junit.framework.TestCase;
-
+import org.junit.Ignore;
+import org.junit.Test;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.DataPolicy.PermissionType;
import org.teiid.adminapi.impl.DataPolicyMetadata;
@@ -39,8 +41,6 @@
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.dqp.internal.process.AuthorizationValidationVisitor;
-import org.teiid.dqp.internal.process.Request;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
@@ -52,18 +52,10 @@
import org.teiid.query.validator.ValidatorReport;
-public class TestAuthorizationValidationVisitor extends TestCase {
+public class TestAuthorizationValidationVisitor {
public static final String CONN_ID = "connID"; //$NON-NLS-1$
- /**
- * Constructor for TestAuthorizationValidationVisitor.
- * @param name
- */
- public TestAuthorizationValidationVisitor(String name) {
- super(name);
- }
-
PermissionMetaData addResource(PermissionType type, boolean flag, String resource) {
PermissionMetaData p = new PermissionMetaData();
p.setResourceName(resource);
@@ -164,7 +156,7 @@
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
policies.put(policy.getName(), policy);
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(vdb, true, policies, "test"); //$NON-NLS-1$
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, "test"); //$NON-NLS-1$
ValidatorReport report = Validator.validate(command, metadata, visitor);
if(report.hasItems()) {
ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
@@ -184,116 +176,118 @@
}
}
- public void testEverythingAccessible() throws Exception {
+ @Test public void testEverythingAccessible() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testEverythingAccessible1() throws Exception {
+ @Test public void testEverythingAccessible1() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testEverythingAccessible2() throws Exception {
+ @Test public void testEverythingAccessible2() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testInaccesibleElement() throws Exception {
+ @Test public void testInaccesibleElement() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInaccesibleElement2() throws Exception {
+ @Test public void testInaccesibleElement2() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testInaccesibleGroup() throws Exception {
+ @Test public void testInaccesibleGroup() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testInsert() throws Exception {
+ @Test public void testInsert() throws Exception {
helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testInsertInaccessible() throws Exception {
+ @Test public void testInsertInaccessible() throws Exception {
helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUpdate() throws Exception {
+ @Test public void testUpdate() throws Exception {
helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testUpdateCriteriaInaccessibleForRead() throws Exception {
+ @Test public void testUpdateCriteriaInaccessibleForRead() throws Exception {
helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testUpdateElementInaccessibleForUpdate() throws Exception {
+ @Test public void testUpdateElementInaccessibleForUpdate() throws Exception {
helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDelete() throws Exception {
+ @Test public void testDelete() throws Exception {
helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testDeleteCriteriaInaccesibleForRead() throws Exception {
+ @Test public void testDeleteCriteriaInaccesibleForRead() throws Exception {
helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDeleteInaccesibleGroup() throws Exception {
+ @Test public void testDeleteInaccesibleGroup() throws Exception {
helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testProc() throws Exception {
+ @Test public void testProc() throws Exception {
helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testProcInaccesible() throws Exception {
+ @Test public void testProcInaccesible() throws Exception {
helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testSelectIntoEverythingAccessible() throws Exception {
+ @Test public void testSelectIntoEverythingAccessible() throws Exception {
helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
+ @Test public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
+ @Test public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e4", "pm3.g2.e3"},FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testTempTableSelectInto() throws Exception {
+ @Test public void testTempTableSelectInto() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testTempTableSelectInto1() throws Exception {
+ @Test public void testTempTableSelectInto1() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testTempTableInsert() throws Exception {
+ @Test public void testTempTableInsert() throws Exception {
helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
}
- public void testXMLAccessible() throws Exception {
+ @Test public void testXMLAccessible() throws Exception {
helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testXMLInAccessible() throws Exception {
+ @Test public void testXMLInAccessible() throws Exception {
helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, TeiidComponentException {
VDBMetaData vdb = FakeMetadataFactory.example1VDB();
vdb.getModel("pm1").setVisible(visible); //$NON-NLS-1$
- AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(vdb, false, new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
+ AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(sql);
Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command);
}
- public void testLookupVisibility() throws Exception {
+ @Ignore("visibility no longer ristricts access")
+ @Test public void testLookupVisibility() throws Exception {
helpTestLookupVisibility(true);
}
- public void testLookupVisibilityFails() throws Exception {
+ @Ignore("visibility no longer ristricts access")
+ @Test public void testLookupVisibilityFails() throws Exception {
try {
helpTestLookupVisibility(false);
fail("expected exception"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -21,7 +21,8 @@
*/
package org.teiid.dqp.internal.process;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -34,6 +35,7 @@
import org.teiid.cache.Cache;
import org.teiid.cache.DefaultCache;
import org.teiid.common.buffer.BatchManager;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.core.TeiidComponentException;
@@ -93,12 +95,20 @@
tb.close();
+ BufferManager bm = fbs.getBufferManager();
CachedResults results = new CachedResults();
results.setResults(tb);
results.setCommand(new Query());
Cache cache = new DefaultCache("dummy"); //$NON-NLS-1$
- results.prepare(cache, fbs.getBufferManager());
+ // simulate the jboss-cache remote transport, where the batches are remotely looked up
+ // in cache
+ for (int row=1; row<=tb.getRowCount();row+=4) {
+ cache.put(results.getId()+","+row, tb.getBatch(row), null); //$NON-NLS-1$
+ }
+
+ results.prepare(cache, bm);
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(results);
@@ -108,7 +118,7 @@
CachedResults cachedResults = (CachedResults)ois.readObject();
ois.close();
- cachedResults.restore(cache, fbs.getBufferManager());
+ cachedResults.restore(cache, bm);
// since restored, simulate a async cache flush
cache.clear();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -31,6 +31,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.api.exception.query.QueryResolverException;
@@ -172,6 +173,7 @@
}
}
+ @Ignore("visibility no longer ristricts access")
@Test public void testLookupVisibility() throws Exception {
helpTestVisibilityFails("select lookup('bqt3.smalla', 'intkey', 'stringkey', '?')"); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -24,6 +24,7 @@
import static org.junit.Assert.*;
+import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.cache.DefaultCacheFactory;
@@ -52,9 +53,13 @@
private AtomicRequestMessage request;
private Command command;
private DataTierTupleSource info;
- private AutoGenDataService connectorManager;
+ private AutoGenDataService connectorManager = new AutoGenDataService();
private RequestWorkItem workItem;
+ @Before public void setUp() {
+ connectorManager = new AutoGenDataService();
+ }
+
private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -69,7 +74,6 @@
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.exampleBQTVDB());
- connectorManager = new AutoGenDataService();
rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
rm.setBufferService(new FakeBufferService());
@@ -94,7 +98,7 @@
context.setProcessorID(requestID);
context.setVdbName("test"); //$NON-NLS-1$
context.setVdbVersion(1);
- context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
+ context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
request = new AtomicRequestMessage(original, workContext, nodeId);
@@ -126,8 +130,8 @@
}
@Test public void testNoRowsException() throws Exception {
+ this.connectorManager.setRows(0);
helpSetup(3);
- this.connectorManager.setRows(0);
while (true) {
try {
assertNull(info.nextTuple());
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -62,7 +62,7 @@
//No PreparedPlan at the begining
assertNull(cache.get(id));
//create one
- cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, new PreparedPlan());
+ cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, new PreparedPlan(), null);
//should have one now
assertNotNull("Unable to get prepared plan from cache", cache.get(id)); //$NON-NLS-1$
}
@@ -109,7 +109,7 @@
helpPutPreparedPlans(cache, token2, 0, 121);
helpPutPreparedPlans(cache, token, 0, 50);
- assertTrue(cache.getSpaceUsed() <= 100);
+ assertTrue(cache.getTotalCacheEntries() <= 100);
}
@Test public void testZeroSizeCache() {
@@ -120,12 +120,12 @@
// Add 1 plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 0, 1);
assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
- assertEquals(0, cache.getSpaceUsed());
+ assertEquals(0, cache.getTotalCacheEntries());
// Add another plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 1, 1);
assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1)));
- assertEquals(0, cache.getSpaceUsed());
+ assertEquals(0, cache.getTotalCacheEntries());
}
// set init size to negative number, which should default to 100 (default)
@@ -149,7 +149,7 @@
CacheID id = new CacheID(session, pi, dummy.toString());
PreparedPlan pPlan = new PreparedPlan();
- cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, pPlan);
+ cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, pPlan, null);
pPlan.setCommand(dummy);
pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
AnalysisRecord analysisRecord = new AnalysisRecord(true, false);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -245,7 +245,7 @@
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
- serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, workContext, false);
+ serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, workContext, false, prepPlanCache);
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -80,7 +80,7 @@
RequestMessage message = new RequestMessage();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- request.initialize(message, null, null,new FakeTransactionService(),null, workContext, false);
+ request.initialize(message, null, null,new FakeTransactionService(),null, workContext, false, null);
request.initMetadata();
request.validateAccess(command);
}
@@ -134,7 +134,7 @@
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
request.initialize(message, Mockito.mock(BufferManager.class),
- new FakeDataManager(), new FakeTransactionService(), null, workContext, false);
+ new FakeDataManager(), new FakeTransactionService(), null, workContext, false, null);
request.processRequest();
return request;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestSessionAwareCache.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -47,7 +47,7 @@
Cachable result = Mockito.mock(Cachable.class);
id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
- cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, result);
+ cache.put(id, FunctionMethod.SESSION_DETERMINISTIC, result, null);
// make sure that in the case of session specific; we do not call prepare
// as session is local only call for distributed
@@ -71,7 +71,7 @@
Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
- cache.put(id, FunctionMethod.USER_DETERMINISTIC, result);
+ cache.put(id, FunctionMethod.USER_DETERMINISTIC, result, null);
// make sure that in the case of session specific; we do not call prepare
// as session is local only call for distributed
@@ -97,7 +97,7 @@
Mockito.stub(result.prepare((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
Mockito.stub(result.restore((Cache)anyObject(), (BufferManager)anyObject())).toReturn(true);
- cache.put(id, FunctionMethod.VDB_DETERMINISTIC, result);
+ cache.put(id, FunctionMethod.VDB_DETERMINISTIC, result, null);
// make sure that in the case of session specific; we do not call prepare
// as session is local only call for distributed
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -119,6 +119,7 @@
Class type = symbol.getType();
row.add( getValue(type) );
}
+ rows[i] = row;
}
return rows;
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -4667,7 +4667,7 @@
ProcessorPlan plan = helpPlan(sql,
FakeMetadataFactory.exampleBQTCached(),
null, capFinder,
- new String[] {"(SELECT g_2.intkey AS c_0, 'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b' AS c_1 FROM BQT1.SmallA AS g_1) UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM BQT1.SmallA AS g_0"}, //$NON-NLS-1$
+ new String[] {"SELECT g_2.intkey AS c_0, 'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b' AS c_1 FROM BQT1.SmallA AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM BQT1.SmallA AS g_0"}, //$NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING );
checkNodeTypes(plan, FULL_PUSHDOWN);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -25,6 +25,8 @@
import static org.teiid.query.optimizer.TestOptimizer.*;
import org.junit.Test;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -735,15 +737,15 @@
/**
* Technically this is not a full push-down, but the subquery will be evaluated prior to pushdown
*/
- @Test public void testCompareSubquery4() {
+ @Test public void testCompareSubquery4() throws TeiidComponentException, TeiidProcessingException {
ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 > (select e1 FROM pm2.g1 where e2 = 13)", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 > (SELECT g_1.e1 FROM pm2.g1 AS g_1 WHERE g_1.e2 = 13)" }); //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 > (SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e2 = 13)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
- @Test public void testScalarSubquery1() {
+ @Test public void testScalarSubquery1() throws TeiidComponentException, TeiidProcessingException {
ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') from pm1.g1", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, (SELECT g_1.e1 FROM pm2.g1 AS g_1 WHERE g_1.e1 = 'x') FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, (SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 = 'x') FROM pm1.g1 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,12 +22,16 @@
package org.teiid.query.optimizer.proc;
+import java.util.Collections;
+
+import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.parser.QueryParser;
@@ -35,31 +39,19 @@
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorFailure;
import org.teiid.query.validator.ValidatorReport;
-import junit.framework.TestCase;
+@SuppressWarnings("nls")
+public class TestProcedurePlanner {
-
-public class TestProcedurePlanner extends TestCase {
-
- /**
- * Constructor for TestGenerateCanonical.
- * @param arg0
- */
- public TestProcedurePlanner(String arg0) {
- super(arg0);
- }
-
// ################ getReplacementClause tests ###################
- private ProcessorPlan helpPlanProcedure(String procedure, String procedureType) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
- return helpPlanProcedure(null, procedure, procedureType);
- }
-
private ProcessorPlan helpPlanProcedure(String userQuery,
String procedure,
String procedureType) throws TeiidComponentException,
@@ -68,6 +60,13 @@
QueryParser parser = QueryParser.getQueryParser();
Command userCommand = userQuery != null ? parser.parseCommand(userQuery) : parser.parseCommand(procedure);
+
+ if (userCommand instanceof CreateUpdateProcedureCommand) {
+ GroupSymbol gs = new GroupSymbol("proc");
+ gs.setMetadataID(new TempMetadataID("proc", Collections.EMPTY_LIST));
+ ((CreateUpdateProcedureCommand)userCommand).setVirtualGroup(gs);
+ }
+
QueryResolver.resolveCommand(userCommand, metadata);
ValidatorReport report = Validator.validate(userCommand, metadata);
@@ -92,7 +91,7 @@
// TESTS
// =============================================================================
- public void testCreateUpdateProcedure1() throws Exception {
+ @Test public void testCreateUpdateProcedure1() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Declare String var1;\n"; //$NON-NLS-1$
@@ -110,7 +109,7 @@
}
// special variable CHANGING used with declared variable
- public void testCreateUpdateProcedure2() throws Exception {
+ @Test public void testCreateUpdateProcedure2() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -129,7 +128,7 @@
}
// special variable CHANGING and INPUT used in conpound criteria
- public void testCreateUpdateProcedure3() throws Exception {
+ @Test public void testCreateUpdateProcedure3() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -148,7 +147,7 @@
}
// special variable CHANGING and INPUT used in conpound criteria, with declared variables
- public void testCreateUpdateProcedure4() throws Exception {
+ @Test public void testCreateUpdateProcedure4() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -167,7 +166,7 @@
}
// virtual group elements used in procedure(HAS CRITERIA)
- public void testCreateUpdateProcedure5() throws Exception {
+ @Test public void testCreateUpdateProcedure5() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -182,7 +181,7 @@
}
// virtual group elements used in procedure in if statement(HAS CRITERIA)
- public void testCreateUpdateProcedure6() throws Exception {
+ @Test public void testCreateUpdateProcedure6() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
@@ -200,7 +199,7 @@
}
// testing rows updated incremented, Input and assignment statements
- public void testCreateUpdateProcedure7() throws Exception {
+ @Test public void testCreateUpdateProcedure7() throws Exception {
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select pm1.g1.e2 from pm1.g1;\n"; //$NON-NLS-1$
@@ -215,42 +214,42 @@
}
// testing select into with virtual group in from clause
- public void testCreateVirtualProcedure1() throws Exception {
+ @Test public void testCreateVirtualProcedure1() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1 INTO #temptable FROM vm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1 FROM #temptable;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- helpPlanProcedure(procedure,
+ helpPlanProcedure(null, procedure,
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
// testing select into with function in select clause
- public void testCreateVirtualProcedure2() throws Exception {
+ @Test public void testCreateVirtualProcedure2() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, convert(e2, string) INTO #temptable FROM vm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1 FROM #temptable;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- helpPlanProcedure(procedure,
+ helpPlanProcedure(null, procedure,
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
// testing select into with function in select clause
- public void testCreateVirtualProcedure3() throws Exception {
+ @Test public void testCreateVirtualProcedure3() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1, convert(e2, string) as a1 INTO #temptable FROM vm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "SELECT e1 FROM #temptable;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- helpPlanProcedure(procedure,
+ helpPlanProcedure(null, procedure,
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
- public void testCase4504() throws Exception {
+ @Test public void testCase4504() throws Exception {
String procedure = "CREATE VIRTUAL PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "SELECT y INTO #temptable FROM (select x.e1 as y from (select convert(pm1.g1.e1, date) e1 from pm1.g1) x) z;\n"; //$NON-NLS-1$
@@ -260,7 +259,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- helpPlanProcedure(procedure,
+ helpPlanProcedure(null, procedure,
FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -43,11 +43,14 @@
import org.teiid.query.sql.lang.JoinType;
import org.teiid.query.sql.lang.Option;
import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetQuery;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.SubqueryFromClause;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.proc.AssignmentStatement;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
@@ -64,6 +67,7 @@
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.Reference;
+@SuppressWarnings("nls")
public class TestOptionsAndHints {
/*+* Select a From db.g1 MAKENOTDEP, db.g2 MAKENOTDEP WHERE a = b */
@@ -1074,9 +1078,55 @@
UnaryFromClause ufc = new UnaryFromClause();
from.addClause(ufc);
ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
- query.setFrom(from);
- query.setCacheHint(new CacheHint());
+ query.setFrom(from);
+ CacheHint hint = new CacheHint();
+ hint.setPrefersMemory(true);
+ hint.setTtl(Long.valueOf(2000));
+ query.setCacheHint(hint);
TestParser.helpTest(sql, "/*+ cache(pref_mem ttl:2000) */ SELECT * FROM t1", query); //$NON-NLS-1$
}
+ @Test public void testCacheHintUnion() {
+ String sql = "/*+ cache( pref_mem) */ SELECT * FROM t1 union select * from t2"; //$NON-NLS-1$
+
+ Query query = new Query();
+ Select select = new Select();
+ select.addSymbol(new AllSymbol());
+ query.setSelect(select);
+ From from = new From();
+ UnaryFromClause ufc = new UnaryFromClause();
+ from.addClause(ufc);
+ ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
+ query.setFrom(from);
+
+ Query query1 = new Query();
+ select = new Select();
+ select.addSymbol(new AllSymbol());
+ query1.setSelect(select);
+ from = new From();
+ ufc = new UnaryFromClause();
+ from.addClause(ufc);
+ ufc.setGroup(new GroupSymbol("t2")); //$NON-NLS-1$
+ query1.setFrom(from);
+
+ SetQuery sq = new SetQuery(Operation.UNION, false, query, query1);
+ CacheHint hint = new CacheHint();
+ hint.setPrefersMemory(true);
+ sq.setCacheHint(hint);
+ TestParser.helpTest(sql, "/*+ cache(pref_mem) */ SELECT * FROM t1 UNION SELECT * FROM t2", sq); //$NON-NLS-1$
+ }
+
+ @Test public void testCacheHintCallableStatement() {
+ String sql = "/*+ cache */ { ? = call proc() }"; //$NON-NLS-1$
+ StoredProcedure sp = new StoredProcedure();
+ SPParameter param = new SPParameter(1, null);
+ param.setParameterType(SPParameter.RETURN_VALUE);
+ sp.setParameter(param);
+ sp.setProcedureName("proc");
+ sp.setCallableStatement(true);
+ CacheHint hint = new CacheHint();
+ sp.setCacheHint(hint);
+ TestParser.helpTest(sql, "/*+ cache */ EXEC proc()", sp); //$NON-NLS-1$
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -197,7 +197,7 @@
setQuery = new SetQuery(Operation.UNION, false, setQuery, query);
TestParser.helpTest("select c1 from g1 union select c2 from g2 union select c3 from g3", //$NON-NLS-1$
- "(SELECT c1 FROM g1 UNION SELECT c2 FROM g2) UNION SELECT c3 FROM g3", //$NON-NLS-1$
+ "SELECT c1 FROM g1 UNION SELECT c2 FROM g2 UNION SELECT c3 FROM g3", //$NON-NLS-1$
setQuery);
}
@@ -258,7 +258,7 @@
setQuery = new SetQuery(SetQuery.Operation.UNION, false, setQuery, query);
TestParser.helpTest("select c1 from g1 union select c2 from g2 union all select c3 from g3 union select c4 from g4", //$NON-NLS-1$
- "((SELECT c1 FROM g1 UNION SELECT c2 FROM g2) UNION ALL SELECT c3 FROM g3) UNION SELECT c4 FROM g4", //$NON-NLS-1$
+ "SELECT c1 FROM g1 UNION SELECT c2 FROM g2 UNION ALL SELECT c3 FROM g3 UNION SELECT c4 FROM g4", //$NON-NLS-1$
setQuery);
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -23,7 +23,6 @@
package org.teiid.query.processor;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,7 +31,6 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.TeiidComponentException;
-import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.util.CommandContext;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestMaterialization.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -27,12 +27,16 @@
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Executor;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.dqp.internal.process.SimpleQueryProcessorFactory;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.QueryProcessorFactoryImpl;
+import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -59,17 +63,27 @@
hdm.addData("SELECT matsrc.x FROM matsrc", new List[] {Arrays.asList((String)null), Arrays.asList("one"), Arrays.asList("two"), Arrays.asList("three")});
hdm.addData("SELECT mattable.info.e1, mattable.info.e2 FROM mattable.info", new List[] {Arrays.asList("a", 1), Arrays.asList("a", 2)});
hdm.addData("SELECT mattable.info.e2, mattable.info.e1 FROM mattable.info", new List[] {Arrays.asList(1, "a"), Arrays.asList(2, "a")});
- dataManager = new TempTableDataManager(hdm, BufferManagerFactory.getStandaloneBufferManager());
+
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bm);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(hdm, bm, executor, cache);
}
- private void execute(String sql, List... expectedResults) throws Exception {
+ private void execute(String sql, List<?>... expectedResults) throws Exception {
CommandContext cc = TestProcessor.createCommandContext();
cc.setTempTableStore(tempStore);
cc.setGlobalTableStore(globalStore);
cc.setMetadata(metadata);
CapabilitiesFinder finder = new DefaultCapabilitiesFinder();
previousPlan = TestProcessor.helpGetPlan(TestProcessor.helpParse(sql), metadata, finder, cc);
- cc.setQueryProcessorFactory(new SimpleQueryProcessorFactory(BufferManagerFactory.getStandaloneBufferManager(), dataManager, finder, null, metadata));
+ cc.setQueryProcessorFactory(new QueryProcessorFactoryImpl(BufferManagerFactory.getStandaloneBufferManager(), dataManager, finder, null, metadata));
TestProcessor.doProcess(previousPlan, dataManager, expectedResults, cc);
}
@@ -101,5 +115,34 @@
execute("SELECT * from vgroup4 where x is null", Arrays.asList((String)null));
assertEquals(2, hdm.getCommandHistory().size());
}
+
+ @Test public void testProcedureCache() throws Exception {
+ execute("call sp1('one')", Arrays.asList("one"));
+ assertEquals(1, hdm.getCommandHistory().size());
+ execute("call sp1('one')", Arrays.asList("one"));
+ assertEquals(1, hdm.getCommandHistory().size());
+ execute("call sp1('one') option nocache sp.sp1", Arrays.asList("one"));
+ assertEquals(2, hdm.getCommandHistory().size());
+ execute("call sp1(null)");
+ assertEquals(3, hdm.getCommandHistory().size());
+ execute("call sp1(null)");
+ assertEquals(3, hdm.getCommandHistory().size());
+ }
+
+ @Test public void testCoveringSecondaryIndex() throws Exception {
+ execute("SELECT * from vgroup3 where y in ('zne', 'zwo') order by y desc", Arrays.asList("two", "zwo"), Arrays.asList("one", "zne"));
+ execute("SELECT * from vgroup3 where y is null", Arrays.asList((String)null, (String)null));
+ }
+
+ @Test public void testNonCoveringSecondaryIndex() throws Exception {
+ execute("SELECT * from vgroup5 where y in ('zne', 'zwo') order by y desc", Arrays.asList("two", "zwo", 1), Arrays.asList("one", "zne", 1));
+ execute("SELECT * from vgroup5 where y is null", Arrays.asList((String)null, (String)null, 1));
+ execute("SELECT * from vgroup5 where y is null and z = 2");
+ }
+
+ @Test public void testNonCoveringSecondaryIndexWithoutPrimaryKey() throws Exception {
+ execute("SELECT * from vgroup6 where y in ('zne', 'zwo') order by y desc", Arrays.asList("two", "zwo"), Arrays.asList("one", "zne"));
+ execute("SELECT * from vgroup6 where y is null", Arrays.asList((String)null, (String)null));
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -39,9 +39,11 @@
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.concurrent.Executor;
import org.junit.Test;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBuffer;
@@ -53,7 +55,10 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.XMLType;
-import org.teiid.dqp.internal.process.SimpleQueryProcessorFactory;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.PreparedPlan;
+import org.teiid.dqp.internal.process.QueryProcessorFactoryImpl;
+import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
@@ -241,17 +246,35 @@
context.setGlobalTableStore(new TempTableStore("SYSTEM"));
}
if (!(dataManager instanceof TempTableDataManager)) {
- dataManager = new TempTableDataManager(dataManager, bufferMgr);
+ SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bufferMgr);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(dataManager, bufferMgr, executor, cache);
}
if (context.getQueryProcessorFactory() == null) {
- context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bufferMgr, dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
+ context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(bufferMgr, dataManager, new DefaultCapabilitiesFinder(), null, context.getMetadata()));
}
TupleBuffer id = null;
try {
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- processor.setNonBlocking(true);
+ //processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
- id = collector.collectTuples();
+ for (int i = 0; i < 100; i++) {
+ try {
+ id = collector.collectTuples();
+ break;
+ } catch (BlockedException e) {
+
+ }
+ }
+ if (id == null) {
+ fail("did not complete processing");
+ }
if ( expectedResults != null ) {
examineResults(expectedResults, bufferMgr, id);
}
@@ -335,6 +358,7 @@
context.setProcessorBatchSize(BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE);
context.setConnectorBatchSize(BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE);
context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ context.setPreparedPlanCache(new SessionAwareCache<PreparedPlan>());
return context;
}
@@ -7502,7 +7526,7 @@
@Test public void testUncorrelatedScalarSubqueryPushdown() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, false);
@@ -7512,19 +7536,45 @@
ProcessorPlan plan = helpPlan("select pm1.g1.e1 from pm1.g1 where e1 < (select max(vm1.g1.e1) from vm1.g1)", metadata, //$NON-NLS-1$
null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 < (SELECT MAX(g_1.e1) FROM pm1.g1 AS g_1)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 < (SELECT MAX(g_0.e1) FROM pm1.g1 AS g_0)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
HardcodedDataManager hdm = new HardcodedDataManager();
hdm.addData("SELECT MAX(g_0.e1) FROM pm1.g1 AS g_0", new List[] {Arrays.asList("c")});
hdm.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 < 'c'", new List[] {Arrays.asList("a")});
-
+ hdm.setBlockOnce(true);
List[] expected = new List[] {
Arrays.asList("a"),
};
helpProcess(plan, hdm, expected);
}
+
+ @Test public void testUncorrelatedScalarSubqueryPushdown1() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, false);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select pm1.g1.e1 from pm1.g1 where e1 < (select e1 from (EXEC pm1.sq1()) x order by e2 limit 1)", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 < (SELECT e1 FROM (EXEC pm1.sq1()) AS x ORDER BY e2 LIMIT 1)" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ HardcodedDataManager hdm = new HardcodedDataManager();
+ hdm.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 < 'z'", new List[] {Arrays.asList("c")});
+ hdm.addData("SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", new List[] {Arrays.asList("z", 1), Arrays.asList("b", 2)});
+ hdm.setBlockOnce(true);
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ };
+
+ helpProcess(plan, hdm, expected);
+ }
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -27,11 +27,15 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.Executor;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.internal.process.CachedResults;
+import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.tempdata.TempTableDataManager;
import org.teiid.query.tempdata.TempTableStore;
@@ -60,9 +64,18 @@
metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), tempStore.getMetadataStore());
FakeDataManager fdm = new FakeDataManager();
TestProcessor.sampleData1(fdm);
- dataManager = new TempTableDataManager(fdm, BufferManagerFactory.getStandaloneBufferManager());
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ SessionAwareCache<CachedResults> cache = new SessionAwareCache<CachedResults>();
+ cache.setBufferManager(bm);
+ Executor executor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ command.run();
+ }
+ };
+ dataManager = new TempTableDataManager(fdm, bm, executor, cache);
}
-
+
@Test public void testInsertWithQueryExpression() throws Exception {
execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
@@ -236,6 +249,16 @@
sampleTable();
execute("select * from x where e1 >= 'b' order by e1 desc, e2 desc", new List[] {Arrays.asList("c", 1), Arrays.asList("b", 3), Arrays.asList("b", 2)}); //$NON-NLS-1$
}
+
+ @Test public void testCompositeKeyPartial5() throws Exception {
+ sampleTable();
+ execute("select * from x where e1 in ('a', 'b')", new List[] {Arrays.asList("a", 1), Arrays.asList("b", 2), Arrays.asList("b", 3)}); //$NON-NLS-1$
+ }
+
+ @Test public void testCompositeKeyPartial6() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, primary key (e1, e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("select * from x where e1 in ('a', 'b') order by e1 desc", new List[0]); //$NON-NLS-1$
+ }
private void sampleTable() throws Exception {
execute("create local temporary table x (e1 string, e2 integer, primary key (e1, e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -48,6 +48,7 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.FakeDataStore;
+import org.teiid.query.processor.HardcodedDataManager;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.processor.TestProcessor;
@@ -73,7 +74,7 @@
return getProcedurePlan(userQuery, metadata, /*capabilitiesFinder*/null);
}
- public static ProcessorPlan getProcedurePlan(String userQuery, FakeMetadataFacade metadata, CapabilitiesFinder capabilitiesFinder) throws Exception {
+ public static ProcessorPlan getProcedurePlan(String userQuery, QueryMetadataInterface metadata, CapabilitiesFinder capabilitiesFinder) throws Exception {
Command userCommand = QueryParser.getQueryParser().parseCommand(userQuery);
QueryResolver.resolveCommand(userCommand, metadata);
ValidatorReport report = Validator.validate(userCommand, metadata);
@@ -2636,5 +2637,16 @@
helpTestProcess(plan, expected, dataMgr, metadata);
}
+ @Test public void testUnambiguousVirtualProc() throws Exception {
+ String userQuery = "EXEC MMSP6('1')"; //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList( "1" ),
+ };
+ helpTestProcess(plan, expected, new HardcodedDataManager(), metadata);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -96,6 +96,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.ErrorMessageKeys;
@@ -3023,4 +3024,11 @@
helpResolveUpdateProcedure(procedure, userUpdateStr);
}
+ //return should be first, then out
+ @Test public void testParamOrder() {
+ Query resolvedQuery = (Query)helpResolve("SELECT * FROM (exec pm4.spRetOut()) as a", RealMetadataFactory.exampleBQTCached(), null); //$NON-NLS-1$
+
+ assertEquals("A.ret", resolvedQuery.getProjectedSymbols().get(0).getName());
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -2661,119 +2661,6 @@
return facade;
}
- public static VDBMetaData exampleXQueryTransformationsVDB() {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("exampleXQueryTransformations");
- vdb.setVersion(1);
- vdb.addModel(createModel("m", true));
- return vdb;
- }
-
- public static FakeMetadataFacade exampleXQueryTransformations() {
- FakeMetadataObject model = FakeMetadataFactory.createPhysicalModel("m");//$NON-NLS-1$
-
- // Simple xquery view - no inputs, calls out to source docs
- FakeMetadataObject xmlrs = FakeMetadataFactory.createResultSet("m.xprocrs", model, new String[] { "xml" }, new String[] { DataTypeManager.DefaultDataTypes.XML }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject xml1out = FakeMetadataFactory.createParameter("rs", 1, ParameterInfo.RESULT_SET, null, xmlrs); //$NON-NLS-1$
- QueryNode xproct1 = new QueryNode("m.xproc1", "<test></test>"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject xproc1 = FakeMetadataFactory.createVirtualProcedure("m.xproc1", model, Arrays.asList(new FakeMetadataObject[] { xml1out }), xproct1); //$NON-NLS-1$
-
- // XQuery view: call out to proc returning xml
- QueryNode xproct2 = new QueryNode("m.xproc2", "doc(\"EXEC m.xproc1()\")"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject xproc2 = FakeMetadataFactory.createVirtualProcedure("m.xproc2", model, Arrays.asList(new FakeMetadataObject[] { xml1out }), xproct2); //$NON-NLS-1$
-
- // XQuery view with xml input arg
- FakeMetadataObject xml3in = FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct3 = new QueryNode("m.xproc3", //$NON-NLS-1$
- "declare variable $INPUT as node() external; " + //$NON-NLS-1$
- "<wrap>{ $INPUT }</wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc3 = FakeMetadataFactory.createVirtualProcedure("m.xproc3", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml3in }), xproct3); //$NON-NLS-1$
-
- // XQuery view with scalar input args
- FakeMetadataObject xml4in = FakeMetadataFactory.createParameter("in1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml4in2 = FakeMetadataFactory.createParameter("in2", 3, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- QueryNode xproct4 = new QueryNode("m.xproc4", //$NON-NLS-1$
- "declare variable $in1 as xs:string external; " + //$NON-NLS-1$
- "declare variable $in2 as xs:int external; " + //$NON-NLS-1$
- "<wrap><a>{ $in1 }</a><b>{ $in2 }</b></wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc4 = FakeMetadataFactory.createVirtualProcedure("m.xproc4", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml4in, xml4in2 }), xproct4); //$NON-NLS-1$
-
- // XQuery view calling doc() function with non-literal
- FakeMetadataObject xml5in = FakeMetadataFactory.createParameter("procName", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct5 = new QueryNode("m.xproc5", //$NON-NLS-1$
- "declare variable $procName as xs:string external; " + //$NON-NLS-1$
- "let $sql := concat('EXEC ', $procName, '()') " + //$NON-NLS-1$
- "return <wrap>{doc($sql)}</wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc5 = FakeMetadataFactory.createVirtualProcedure("m.xproc5", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml5in }), xproct5); //$NON-NLS-1$
-
- // XQuery view to create dynamic element
- FakeMetadataObject xml6in = FakeMetadataFactory.createParameter("tag", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml6in2 = FakeMetadataFactory.createParameter("value", 3, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct6 = new QueryNode("m.maketag", //$NON-NLS-1$
- "declare variable $tag as xs:string external; " + //$NON-NLS-1$
- "declare variable $value as xs:string external; " + //$NON-NLS-1$
- "element { $tag } { $value }"); //$NON-NLS-1$
- FakeMetadataObject xproc6 = FakeMetadataFactory.createVirtualProcedure("m.maketag", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml6in, xml6in2 }), xproct6); //$NON-NLS-1$
-
- // XQuery view calling multiple doc() functions with non-literal
- FakeMetadataObject xml7in = FakeMetadataFactory.createParameter("wrapperTag", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in2 = FakeMetadataFactory.createParameter("tag1", 3, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in3 = FakeMetadataFactory.createParameter("val1", 4, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in4 = FakeMetadataFactory.createParameter("tag2", 5, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in5 = FakeMetadataFactory.createParameter("val2", 6, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct7 = new QueryNode("m.combinetags", //$NON-NLS-1$
- "declare variable $wrapperTag as xs:string external; " + //$NON-NLS-1$
- "declare variable $tag1 as xs:string external; " + //$NON-NLS-1$
- "declare variable $val1 as xs:string external; " + //$NON-NLS-1$
- "declare variable $tag2 as xs:string external; " + //$NON-NLS-1$
- "declare variable $val2 as xs:string external; " + //$NON-NLS-1$
- "let $t1 := concat(\"EXEC m.maketag('\", $tag1, \"','\", $val1, \"')\") " + //$NON-NLS-1$
- "let $t2 := concat(\"EXEC m.maketag('\", $tag2, \"','\", $val2, \"')\") " + //$NON-NLS-1$
- "return element { $wrapperTag } { doc($t1), doc($t2) }"); //$NON-NLS-1$
- FakeMetadataObject xproc7 = FakeMetadataFactory.createVirtualProcedure("m.combinetags", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml7in, xml7in2, xml7in3, xml7in4, xml7in5 }), xproct7); //$NON-NLS-1$
-
- // XQuery web service view: takes xml in, yields xml out
- // Expects doc like: <in><tag>tag</tag><value></value></in>
- FakeMetadataObject xml8in = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct8 = new QueryNode("m.svc8", //$NON-NLS-1$
- "declare variable $in as node() external; " + //$NON-NLS-1$
- "element { $in//tag/text() } { $in//value/text() }"); //$NON-NLS-1$
- FakeMetadataObject xproc8 = FakeMetadataFactory.createVirtualProcedure("m.svc8", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml8in }), xproct8); //$NON-NLS-1$
-
- // Chaining together XQuery web service views
- // Expects doc like: <in><tag>tag</tag><values><value>val1</value><value>val2</value>...</values></in>
- FakeMetadataObject xml9in = FakeMetadataFactory.createParameter("in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct9 = new QueryNode("m.svc9", //$NON-NLS-1$
- "declare variable $in as node() external; " + //$NON-NLS-1$
- "<results> {" + //$NON-NLS-1$
- " for $value in $in//value " + //$NON-NLS-1$
- " let $tag := $in//tag " + //$NON-NLS-1$
- " return doc(" + //$NON-NLS-1$
- " concat(\"EXEC m.svc8('<in><tag>\", $tag, \"</tag><value>\", $value, \"</value></in>')\"))" + //$NON-NLS-1$
- "} </results>"); //$NON-NLS-1$
- FakeMetadataObject xproc9 = FakeMetadataFactory.createVirtualProcedure("m.svc9", model, Arrays.asList(new FakeMetadataObject[] { xml1out, xml9in }), xproct9); //$NON-NLS-1$
-
- // XQuery service with only a doc expression in it
- QueryNode xproct10 = new QueryNode("m.xproc10", //$NON-NLS-1$
- "doc('EXEC m.xproc1()')"); //$NON-NLS-1$
- FakeMetadataObject xproc10 = FakeMetadataFactory.createVirtualProcedure("m.xproc10", model, Arrays.asList(new FakeMetadataObject[] { xml1out }), xproct10); //$NON-NLS-1$
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(model);
- store.addObject(xproc1);
- store.addObject(xproc2);
- store.addObject(xproc3);
- store.addObject(xproc4);
- store.addObject(xproc5);
- store.addObject(xproc6);
- store.addObject(xproc7);
- store.addObject(xproc8);
- store.addObject(xproc9);
- store.addObject(xproc10);
-
- return new FakeMetadataFacade(store);
- }
/**
* Create a physical model with default settings.
* @param name Name of model
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -250,9 +250,12 @@
ColumnSet<Procedure> vsprs6 = createResultSet("mmspTest1.vsprs1", new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
ProcedureParameter vsp6p1 = createParameter("p1", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$
- QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT p1 as StringKey; END"); //$NON-NLS-1$ //$NON-NLS-2$
Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1, Arrays.asList(vsp6p1), vspqn6); //$NON-NLS-1$
vsp6.setResultSet(vsprs6);
+
+ createStoredProcedure("spRetOut", pm4, Arrays.asList(createParameter("ret", ParameterInfo.RETURN_VALUE, DataTypeManager.DefaultDataTypes.INTEGER),
+ createParameter("x", ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER)), "spRetOut"); //$NON-NLS-1$ //$NON-NLS-2$
return createTransformationMetadata(metadataStore, "bqt");
}
@@ -343,6 +346,7 @@
new String[] { "x" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ //covering index
QueryNode vTrans3 = new QueryNode("VGroup3", "SELECT x, 'z' || substring(x, 2) as y FROM matsrc"); //$NON-NLS-1$ //$NON-NLS-2$
Table vGroup3 = createVirtualGroup("VGroup3", virtModel, vTrans3); //$NON-NLS-1$
vGroup3.setMaterialized(true);
@@ -350,7 +354,8 @@
new String[] { "x", "y" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
- createKey("pk", vGroup3, vElements3.subList(0, 1));
+ createKey(KeyRecord.Type.Primary, "pk", vGroup3, vElements3.subList(0, 1));
+ createKey(KeyRecord.Type.Index, "idx", vGroup3, vElements3.subList(1, 2));
QueryNode vTrans4 = new QueryNode("VGroup4", "/*+ cache(ttl:100) */ SELECT x FROM matsrc"); //$NON-NLS-1$ //$NON-NLS-2$
Table vGroup4 = createVirtualGroup("VGroup4", virtModel, vTrans4); //$NON-NLS-1$
@@ -358,6 +363,35 @@
createElements(vGroup4,
new String[] { "x" }, //$NON-NLS-1$
new String[] { DataTypeManager.DefaultDataTypes.STRING});
+
+ //non-covering index
+ QueryNode vTrans5 = new QueryNode("VGroup5", "SELECT x, 'z' || substring(x, 2) as y, 1 as z FROM matsrc"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vGroup5 = createVirtualGroup("VGroup5", virtModel, vTrans5); //$NON-NLS-1$
+ vGroup5.setMaterialized(true);
+ List<Column> vElements5 = createElements(vGroup5,
+ new String[] { "x", "y", "z" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER});
+
+ createKey(KeyRecord.Type.Primary, "pk", vGroup5, vElements5.subList(0, 1));
+ createKey(KeyRecord.Type.Index, "idx", vGroup5, vElements5.subList(1, 2));
+
+ //no pk
+ QueryNode vTrans6 = new QueryNode("VGroup6", "SELECT x, 'z' || substring(x, 2) as y FROM matsrc"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vGroup6 = createVirtualGroup("VGroup6", virtModel, vTrans6); //$NON-NLS-1$
+ vGroup6.setMaterialized(true);
+ List<Column> vElements6 = createElements(vGroup6,
+ new String[] { "x", "y" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
+
+ createKey(KeyRecord.Type.Index, "idx", vGroup6, vElements6.subList(1, 2));
+
+ Schema sp = createVirtualModel("sp", metadataStore); //$NON-NLS-1$
+ ColumnSet<Procedure> rs = createResultSet("sp1.vsprs1", new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ ProcedureParameter param = createParameter("param1", ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+ QueryNode sp1qn = new QueryNode("sp1", "/*+ cache */ CREATE VIRTUAL PROCEDURE BEGIN SELECT x as StringKey from matsrc where x = param1; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ Procedure vsp5 = createVirtualProcedure("sp1", sp, Arrays.asList(param), sp1qn); //$NON-NLS-1$
+ vsp5.setResultSet(rs);
return createTransformationMetadata(metadataStore, "");
}
@@ -370,13 +404,22 @@
* metadata IDs)
* @return key metadata object
*/
- public static KeyRecord createKey(String name, Table group, List<Column> elements) {
- KeyRecord key = new KeyRecord(org.teiid.metadata.KeyRecord.Type.Primary);
+ public static KeyRecord createKey(KeyRecord.Type type, String name, Table group, List<Column> elements) {
+ KeyRecord key = new KeyRecord(type);
key.setName(name);
for (Column column : elements) {
key.addColumn(column);
}
- group.setPrimaryKey(key);
+ switch (type) {
+ case Primary:
+ group.setPrimaryKey(key);
+ break;
+ case Index:
+ group.getIndexes().add(key);
+ break;
+ default:
+ throw new AssertionError("TODO");
+ }
return key;
}
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/jboss-integration/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -8,7 +8,6 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-jboss-integration</artifactId>
<name>teiid-jboss-integration</name>
- <version>7.2.0.Alpha1-SNAPSHOT</version>
<description>JBoss specific integration layer for teiid</description>
<dependencies>
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -55,6 +55,7 @@
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.CacheStatistics;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
@@ -64,6 +65,7 @@
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.WorkerPoolStatistics;
import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -699,4 +701,15 @@
}
return matched;
}
+
+ @Override
+ public CacheStatistics getCacheStats(String cacheType) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getCacheStatistics", SimpleValueSupport.wrap(cacheType));//$NON-NLS-1$
+ return (CacheStatistics)MetaValueFactory.getInstance().unwrap(value, CacheStatisticsMetadata.class);
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -49,6 +49,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.DQPManagement;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -149,14 +150,14 @@
if (this.jdbcSocketConfiguration.isEnabled()) {
this.jdbcSocket = new SocketListener(this.jdbcSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC = ",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid JDBC = ",(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+(this.jdbcSocketConfiguration.getPortNumber()+offset))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "jdbc connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (this.adminSocketConfiguration.isEnabled()) {
this.adminSocket = new SocketListener(this.adminSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_enabled","Teiid Admin", (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+(this.adminSocketConfiguration.getPortNumber()+offset))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("socket_not_enabled", "admin connections")); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -164,7 +165,7 @@
if (this.odbcSocketConfiguration.isEnabled()) {
this.vdbRepository.odbcEnabled();
this.odbcSocket = new ODBCSocketListener(this.odbcSocketConfiguration, csr, this.dqpCore.getBufferManager(), offset);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=", (this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+" Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port = "+this.odbcSocketConfiguration.getPortNumber()+offset)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_enabled","Teiid ODBC - SSL=", (this.odbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"ON":"OFF")+" Host = "+this.odbcSocketConfiguration.getHostAddress().getHostName()+" Port = "+(this.odbcSocketConfiguration.getPortNumber()+offset))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("odbc_not_enabled")); //$NON-NLS-1$
}
@@ -382,6 +383,12 @@
}
@Override
+ @ManagementOperation(description="Get the cache statistics", impact=Impact.ReadOnly)
+ public CacheStatisticsMetadata getCacheStatistics(String cacheType) {
+ return this.dqpCore.getCacheStatistics(cacheType);
+ }
+
+ @Override
@ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
public Collection<SessionMetadata> getActiveSessions() throws AdminException {
try {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -82,8 +82,9 @@
List<ManagedObject> policies = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
for(ManagedObject managedPolicy:policies) {
String policyName = ManagedUtil.getSimpleValue(managedPolicy, "name", String.class); //$NON-NLS-1$
+ Boolean anyAuthenticated = ManagedUtil.getSimpleValue(managedPolicy, "anyAuthenticated", Boolean.class); //$NON-NLS-1$
DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
+ policy.setAnyAuthenticated(Boolean.TRUE.equals(anyAuthenticated));
ManagedProperty mappedRoleNames = managedPolicy.getProperty("mappedRoleNames");//$NON-NLS-1$
if (mappedRoleNames != null){
List<String> roleNames = (List<String>)MetaValueFactory.getInstance().unwrap(mappedRoleNames.getValue());
Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorAnnotationScanningDeployer.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -75,6 +75,7 @@
TranslatorMetaData data = new TranslatorMetaData();
data.setName(bean.name());
data.setExecutionFactoryClass(clazz);
+ data.setDescription(bean.description());
return data;
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -38,7 +38,6 @@
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
import org.teiid.client.util.ExceptionUtil;
-import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -123,11 +122,11 @@
}
@Override
- public ResultsFuture<?> isOpen() {
+ public boolean isOpen(long msToTest) {
if (shutdown) {
- return null;
+ return false;
}
- return ResultsFuture.NULL_FUTURE;
+ return true;
}
public void close() {
@@ -165,4 +164,9 @@
public boolean isSameInstance(ServerConnection conn) throws CommunicationException {
return (conn instanceof LocalServerConnection);
}
+
+ @Override
+ public void cleanUp() {
+
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -22,6 +22,7 @@
package org.teiid.transport;
+import java.util.Collection;
import java.util.Properties;
import javax.security.auth.login.LoginException;
@@ -41,6 +42,7 @@
import org.teiid.dqp.service.SessionServiceException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.net.CommunicationException;
import org.teiid.net.TeiidURL;
import org.teiid.security.Credentials;
@@ -107,6 +109,18 @@
LogManager.logTrace(LogConstants.CTX_SECURITY, "Ping", id); //$NON-NLS-1$
return ResultsFuture.NULL_FUTURE;
}
+
+ @Override
+ public ResultsFuture<?> ping(Collection<String> sessions)
+ throws TeiidComponentException, CommunicationException {
+ for (String string : sessions) {
+ try {
+ this.service.pingServer(string);
+ } catch (InvalidSessionException e) {
+ }
+ }
+ return ResultsFuture.NULL_FUTURE;
+ }
@Override
public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, TeiidComponentException {
Modified: trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -39,7 +39,6 @@
import org.jboss.netty.channel.ChannelDownstreamHandler;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.teiid.core.util.ReflectionHelper;
@@ -54,7 +53,6 @@
* Some parts of this code is taken from H2's implementation of ODBC
*/
@SuppressWarnings("nls")
-@ChannelPipelineCoverage("one")
public class PgBackendProtocol implements ChannelDownstreamHandler, ODBCClientRemote {
private static final int PG_TYPE_VARCHAR = 1043;
Modified: trunk/runtime/src/main/java/org/teiid/transport/PgFrontendProtocol.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/PgFrontendProtocol.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/PgFrontendProtocol.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -34,7 +34,6 @@
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -46,7 +45,6 @@
* Some parts of this code is taken from H2's implementation of ODBC
*/
@SuppressWarnings("nls")
-@ChannelPipelineCoverage("one")
public class PgFrontendProtocol extends FrameDecoder {
private int maxObjectSize;
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -42,13 +42,13 @@
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.DefaultChannelPipeline;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.netty.channel.ChannelHandler.Sharable;
import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
import org.teiid.common.buffer.StorageManager;
@@ -62,7 +62,7 @@
* Main class for creating Netty Nio Channels
*/
-(a)ChannelPipelineCoverage(ChannelPipelineCoverage.ALL)
+@Sharable
public class SSLAwareChannelHandler extends SimpleChannelHandler implements ChannelPipelineFactory {
public class ObjectChannelImpl implements ObjectChannel {
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -94,7 +94,6 @@
public void onConnection() throws CommunicationException {
Handshake handshake = new Handshake();
- handshake.setVersion(SocketListener.getVersionInfo());
if (usingEncryption) {
keyGen = new DhKeyGenerator();
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -33,8 +33,6 @@
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class SocketConfiguration {
- private static final String ANY = "0.0.0.0"; //$NON-NLS-1$
- private static final String JBOSS_SERVER_BIND_ADDRESS = "jboss.bind.address";
private int outputBufferSize;
private int inputBufferSize;
@@ -72,13 +70,8 @@
private void resolveHostName() {
try {
- // if host name not specified try to get it from the JBoss configuration
- if (this.hostName == null) {
- this.hostName = System.getProperty(JBOSS_SERVER_BIND_ADDRESS);
- }
-
// if not defined then see if can bind to local address; if supplied resolve it by name
- if (this.hostName == null || ANY.equals(this.hostName)) {
+ if (this.hostName == null) {
this.hostName = InetAddress.getLocalHost().getHostName();
}
} catch (UnknownHostException e) {
@@ -117,6 +110,7 @@
public InetAddress getHostAddress() {
resolveHostName();
+
if (this.hostAddress != null) {
return hostAddress;
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -31,7 +31,6 @@
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.teiid.common.buffer.StorageManager;
-import org.teiid.core.util.ApplicationInfo;
import org.teiid.core.util.NamedThreadFactory;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -99,10 +98,6 @@
return ((InetSocketAddress)this.serverChanel.getLocalAddress()).getPort();
}
- static String getVersionInfo() {
- return ApplicationInfo.getInstance().getMajorReleaseNumber();
- }
-
public void stop() {
this.serverChanel.close();
this.nettyPool.shutdownNow();
Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -48,6 +48,7 @@
tm.setExecutionFactoryClass(ExecutionFactory.class);
tm.setName("Oracle");
+ tm.setDescription("desc");
tm.addProperty("ExtensionTranslationClassName", "org.teiid.translator.jdbc.oracle.OracleSQLTranslator");
JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {TranslatorMetaDataGroup.class});
@@ -65,6 +66,7 @@
tm = group.getTranslators().get(0);
assertEquals("Oracle", tm.getName());
+ assertEquals("desc", tm.getDescription());
assertEquals(ExecutionFactory.class.getName(), tm.getPropertyValue(Translator.EXECUTION_FACTORY_CLASS));
assertEquals("org.teiid.translator.jdbc.oracle.OracleSQLTranslator", tm.getPropertyValue("ExtensionTranslationClassName"));
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -35,10 +35,14 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
import org.teiid.core.crypto.NullCryptor;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.dqp.service.SessionService;
@@ -69,19 +73,14 @@
}
}
- @Test public void testFailedConnect() throws Exception {
+ @Test(expected=CommunicationException.class) public void testFailedConnect() throws Exception {
SSLConfiguration config = new SSLConfiguration();
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),1024, 1024, 1, config, null, BufferManagerFactory.getStandaloneBufferManager());
- try {
- Properties p = new Properties();
- String url = new TeiidURL(addr.getHostName(), listener.getPort() - 1, false).getAppServerURL();
- p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url); //wrong port
- SocketServerConnectionFactory.getInstance().getConnection(p);
- fail("exception expected"); //$NON-NLS-1$
- } catch (CommunicationException e) {
-
- }
+ Properties p = new Properties();
+ String url = new TeiidURL(addr.getHostName(), listener.getPort() - 1, false).getAppServerURL();
+ p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url); //wrong port
+ SocketServerConnectionFactory.getInstance().getConnection(p);
}
@Test public void testConnectWithoutPooling() throws Exception {
@@ -157,8 +156,20 @@
@Override
public LogonResult logon(Properties connProps)
throws LogonException, ComponentNotFoundException {
- return new LogonResult();
+ return new LogonResult(new SessionToken("dummy"), "x", 1, "z");
}
+
+ @Override
+ public ResultsFuture<?> ping() throws InvalidSessionException,
+ TeiidComponentException {
+ return ResultsFuture.NULL_FUTURE;
+ }
+
+ @Override
+ public void assertIdentity(SessionToken checkSession)
+ throws InvalidSessionException, TeiidComponentException {
+ return;
+ }
}, null);
server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
@@ -210,4 +221,19 @@
helpEstablishConnection(true, config, p);
}
+ @Test public void testSelectNewInstance() throws Exception {
+ SSLConfiguration config = new SSLConfiguration();
+ Properties p = new Properties();
+ SocketServerConnection conn = helpEstablishConnection(false, config, p);
+ SocketListenerStats stats = listener.getStats();
+ assertEquals(2, stats.objectsRead); // handshake response, logon,
+ assertEquals(1, stats.sockets);
+ conn.cleanUp();
+ assertTrue(conn.isOpen(1000));
+ stats = listener.getStats();
+ assertEquals(5, stats.objectsRead); // ping (pool test), assert identity, ping (isOpen)
+ assertEquals(1, stats.sockets);
+ conn.close();
+ }
+
}
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-09-03 01:45:43 UTC (rev 2526)
@@ -29,6 +29,10 @@
import java.io.Reader;
import java.io.Serializable;
import java.io.StringReader;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -60,7 +64,7 @@
import org.teiid.net.socket.SocketServerInstanceImpl;
import org.teiid.net.socket.UrlServerDiscovery;
-
+@SuppressWarnings("nls")
public class TestSocketRemoting {
public interface FakeService {
@@ -104,15 +108,11 @@
ClientServiceRegistryImpl server;
private ResultsReceiver<Object> listener;
- public FakeClientServerInstance(ClientServiceRegistryImpl server) {
- super();
+ public FakeClientServerInstance(ClientServiceRegistryImpl server) throws UnknownHostException {
+ super(new HostInfo("foo", new InetSocketAddress(InetAddress.getLocalHost(), 1)), 1000);
this.server = server;
}
-
- public HostInfo getHostInfo() {
- return new HostInfo("fake", 1); //$NON-NLS-1$
- }
-
+
public boolean isOpen() {
return true;
}
@@ -182,6 +182,12 @@
}
@Override
+ public ResultsFuture<?> ping(Collection<String> sessions)
+ throws TeiidComponentException, CommunicationException {
+ return null;
+ }
+
+ @Override
public void assertIdentity(SessionToken sessionId)
throws InvalidSessionException,
TeiidComponentException {
@@ -226,12 +232,24 @@
SocketServerConnection connection = new SocketServerConnection(new SocketServerInstanceFactory() {
@Override
- public SocketServerInstance getServerInstance(HostInfo info,
- boolean ssl) throws CommunicationException, IOException {
+ public SocketServerInstance getServerInstance(HostInfo info)
+ throws CommunicationException, IOException {
return serverInstance;
}
- }, false, new UrlServerDiscovery(new TeiidURL("foo", 1, false)), new Properties(), null); //$NON-NLS-1$
+ @Override
+ public void connected(SocketServerInstance instance,
+ SessionToken session) {
+
+ }
+
+ @Override
+ public void disconnected(SocketServerInstance instance,
+ SessionToken session) {
+
+ }
+
+ }, false, new UrlServerDiscovery(new TeiidURL("0.0.0.0", 1, false)), new Properties()); //$NON-NLS-1$
return connection;
}
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2010-09-02 23:57:02 UTC (rev 2525)
+++ trunk/test-integration/db/pom.xml 2010-09-03 01:45:43 UTC (rev 2526)
@@ -18,9 +18,6 @@
<name>DB Dependent Integration Tests</name>
<groupId>org.jboss.teiid.teiid-test-integration</groupId>
<description>Integration tests that require external database dependencies </description>
-
- <version>7.2.0.Alpha1-SNAPSHOT</version>
-
<dependencies>
<dependency>
14 years, 3 months
teiid SVN: r2525 - branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-09-02 19:57:02 -0400 (Thu, 02 Sep 2010)
New Revision: 2525
Modified:
branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
Log:
TEIID-1231
Modified: branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-09-02 21:11:11 UTC (rev 2524)
+++ branches/7.1.x/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2010-09-02 23:57:02 UTC (rev 2525)
@@ -258,7 +258,7 @@
@Override
@ManagementProperty(description="Indicates if the role is mapped to any authenticated user.")
public boolean isAnyAuthenticated() {
- return false;
+ return this.anyAuthenticated;
}
public void setAnyAuthenticated(boolean anyAuthenticated) {
14 years, 3 months
teiid SVN: r2524 - branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 17:11:11 -0400 (Thu, 02 Sep 2010)
New Revision: 2524
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
Log:
TEIID-1240 fix to criteria not being updatable
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-09-02 20:37:25 UTC (rev 2523)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-09-02 21:11:11 UTC (rev 2524)
@@ -979,7 +979,7 @@
if (predicate.getJoinType() == JoinType.JOIN_UNION) {
predicate.setJoinType(JoinType.JOIN_FULL_OUTER);
- predicate.setJoinCriteria(Arrays.asList(new Object[] {FALSE_CRITERIA}));
+ predicate.setJoinCriteria(new ArrayList<Criteria>(Arrays.asList(FALSE_CRITERIA)));
} else if (predicate.getJoinType() == JoinType.JOIN_RIGHT_OUTER) {
predicate.setJoinType(JoinType.JOIN_LEFT_OUTER);
FromClause leftClause = predicate.getLeftClause();
14 years, 3 months
teiid SVN: r2523 - in branches/7.1.x: connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 16:37:25 -0400 (Thu, 02 Sep 2010)
New Revision: 2523
Modified:
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
Log:
TEIID-1238 TEIID-1103 adding docs on using cxf to configure the http transport and renaming ws resource adapter properties.
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 19:54:14 UTC (rev 2522)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 20:37:25 UTC (rev 2523)
@@ -71,12 +71,15 @@
<h2><a name="Configuration">Configuration Issues</a></h2>
-See the See the <a href="teiid-docs/teiid_admin_guide.pdf">Admin Guide</a> for more on configuration and installation.
+See the <a href="teiid-docs/teiid_admin_guide.pdf">Admin Guide</a> for more on configuration and installation.
<h4>from 7.1</h4>
<ul>
<li>Apache CXF is now expected to be used as the web services stack provider through JBossWS-CXF. See the Admin Guide for instructions on
- installing CXF for use with Teiid's Salesforce and web service connectors.
+ installing CXF for use with Teiid's Salesforce and web service connectors. The WS Resource Adapter's -ds.xml files should no longer use
+ WSSecurityConfigURL and WSSecurityConfigName, rather they should be ConfigFile and ConfigName respectively. The property values should no longer
+ refer to jboss-wsse-client.xml, but instead they should reference a CXF Spring configuration file and particular port configuration. See the Admin Guide
+ for more on using CXF configuration files.
<li>The default for data role checking is now "true". However only VDBs with data roles will have roles enforced.
<li>The default prepared plan cache size was increased to 512, since it is targeted by internal plans as well.
</ul>
Modified: branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02 19:54:14 UTC (rev 2522)
+++ branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02 20:37:25 UTC (rev 2523)
@@ -46,8 +46,8 @@
private String endPoint;
private String securityType = SecurityType.None.name(); // None, HTTPBasic, WS-Security
- private String wsSecurityConfigURL; // path to the "jboss-wsse-client.xml" file
- private String wsSecurityConfigName; // ws-security config name in the above file
+ private String configFile; // path to the "jbossws-cxf.xml" file
+ private String configName; // config name in the above file
private String authPassword; // httpbasic - password
private String authUserName; // httpbasic - username
@@ -57,13 +57,13 @@
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException {
- String configName = getWsSecurityConfigName();
+ String configName = getConfigName();
if (configName == null) {
configName = WSConnectionImpl.DEFAULT_LOCAL_NAME;
}
this.portQName = new QName(WSConnectionImpl.DEFAULT_NAMESPACE_URI, configName);
- if (wsSecurityConfigURL != null) {
- bus = new SpringBusFactory().createBus(wsSecurityConfigURL);
+ if (configFile != null) {
+ bus = new SpringBusFactory().createBus(configFile);
JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
Configurer configurer = bus.getExtension(Configurer.class);
if (null != configurer) {
@@ -111,20 +111,20 @@
this.securityType = securityType;
}
- public String getWsSecurityConfigURL() {
- return wsSecurityConfigURL;
+ public String getConfigFile() {
+ return configFile;
}
- public void setWsSecurityConfigURL(String wsSecurityConfigURL) {
- this.wsSecurityConfigURL = wsSecurityConfigURL;
+ public void setConfigFile(String config) {
+ this.configFile = config;
}
- public String getWsSecurityConfigName() {
- return wsSecurityConfigName;
+ public String getConfigName() {
+ return configName;
}
- public void setWsSecurityConfigName(String wsSecurityConfigName) {
- this.wsSecurityConfigName = wsSecurityConfigName;
+ public void setConfigName(String configName) {
+ this.configName = configName;
}
public Bus getBus() {
Modified: branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02 19:54:14 UTC (rev 2522)
+++ branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02 20:37:25 UTC (rev 2523)
@@ -66,14 +66,14 @@
</config-property>
<config-property>
- <description>{$display:"URL to the WS-Security Configuration File(typically jbossws-cxf.xml)",$description:"CXF client configuration File"}</description>
- <config-property-name>WsSecurityConfigURL</config-property-name>
+ <description>{$display:"CXF Configuration File",$description:"CXF client configuration File or URL"}</description>
+ <config-property-name>ConfigFile</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
<config-property>
- <description>{$display:"WS-Security Configuration Name",$description:"Local name of the QName of the port configuration to use with this connection. The port namespace URI should be http://teiid.org"}</description>
- <config-property-name>WsSecurityConfigName</config-property-name>
+ <description>{$display:"Configuration Name",$description:"Local name of the QName of the port configuration to use with this connection. The port namespace URI should be http://teiid.org"}</description>
+ <config-property-name>ConfigName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
Modified: branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 19:54:14 UTC (rev 2522)
+++ branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 20:37:25 UTC (rev 2523)
@@ -145,16 +145,25 @@
</no-tx-connection-factory>
</connection-factories>]]></programlisting></example>
<section>
- <title>WS-Security</title>
+ <title>CXF Configuration</title>
+ <para>Each web service data source may choose a particular CXF config file and port configuration.
+ The <code>ConfigFile</code> config property specifies the Spring XML configuration
+ file for the CXF Bus and port configuration to be used by connections.
+ If no config file is specified then the system default configuration will be used.</para>
- <para>To enable the use of WS-Security, the <code>SecurityType</code> should be set to WSSecurity.
- The <code>WsSecurityConfigURL</code> config property may then be used to supply the Spring XML configuration
- file for the CXF Bus and port configuration to be used by these connections. At this time however, Teiid does not expect or use
- a WSDL to describe the service being used. Thus the Spring XML configuration file is not an adjunct
- to policy information in the WSDL, it must instead contain all of the relevant policy configuration. It is also expected that only
- 1 port configuration will be used by this data source. You may explicitly set the local name of the port QName to use via the
- <code>WsSecurityConfigName</code>. The namespace URI for the QName should be http://teiid.org.</para>
+ <para>Only 1 port configuration can be used by this data source. You may explicitly set the local name of the port QName to use via the
+ <code>ConfigName</code> property. The namespace URI for the QName in your config file should be http://teiid.org.
+ See the sections on WS-Security, Logging, etc. for examples of using the CXF configuration file.</para>
+ <para>See the <ulink url="http://cxf.apache.org/docs/">CXF documentation</ulink> for all possible configuration options.</para>
+ <note><para>The CXF configuration is currently only applicable to non-binary web service calls.</para></note>
+ </section>
+ <section>
+ <title>WS-Security</title>
+ <para>To enable the use of WS-Security, the <code>SecurityType</code> should be set to WSSecurity.
+ At this time Teiid does not expect a WSDL to describe the service being used.
+ Thus a Spring XML configuration file is not only required, it must instead contain all of the relevant policy configuration.
+ And just as with the general configuration, each data source is limited to specifing only a single port configration to use.</para>
<example>
<title>Example WS-Security enabled data source</title>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
@@ -164,8 +173,8 @@
<rar-name>teiid-connector-ws.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
<config-property name="EndPoint">http://somewhere.com</config-property>
- <config-property name="WsSecurityConfigURL">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
- <config-property name="WsSecurityConfigName">port_x</config-property>
+ <config-property name="ConfigFile">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="ConfigName">port_x</config-property>
<config-property name="SecurityType">WSSecurity</config-property>
</no-tx-connection-factory>
</connection-factories>]]></programlisting>
@@ -206,10 +215,7 @@
</section>
<section>
<title>Logging</title>
- <para>Even when not using WS-Security, the <code>WsSecurityConfigURL</code> config property may then be used to supply the Spring XML configuration
- file. Logging of requests and responses may be enabled for the entire bus or for specific port configurations.
- If a specific port configuration is used, just as with WS-Security, the local name of the port
- QName should match <code>WsSecurityConfigName</code> and the namespace URI should be http://teiid.org.</para>
+ <para>The CXF config property may also be used to control the logging of requests and responses for specific or all ports. Logging, when enabled, will be performed at an INFO level to the org.apache.cxf.interceptor context.</para>
<example>
<title>Example logging data source</title>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
@@ -219,8 +225,8 @@
<rar-name>teiid-connector-ws.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
<config-property name="EndPoint">http://somewhere.com</config-property>
- <config-property name="WsSecurityConfigURL">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
- <config-property name="WsSecurityConfigName">port_y</config-property>
+ <config-property name="ConfigFile">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="ConfigName">port_y</config-property>
</no-tx-connection-factory>
</connection-factories>]]></programlisting>
<para>Corresponding xxx-jbossws-cxf.xml</para>
@@ -241,8 +247,29 @@
</beans>]]></programlisting>
</example>
- <para>Logging is then performed at an INFO level to the org.apache.cxf.interceptor context. Logging is only performed for non-binary web service calls.</para>
</section>
+ <section>
+ <title>Transport Settings</title>
+ <para>The CXF config property may also be used to control low level aspects of the HTTP transport. See the <ulink url="http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html">CXF documentation</ulink> for all possible options.</para>
+ <example>
+ <title>Example Disabling Hostname Verification</title>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <http-conf:conduit name="{http://teiid.org}port_z.http-conduit">
+ <!-- WARNING ! disableCNcheck=true should NOT be used in production -->
+ <http-conf:tlsClientParameters disableCNcheck="true" />
+
+ </http-conf:conduit>
+</beans>
+]]></programlisting>
+</example>
+ </section>
</section>
<section>
14 years, 3 months
teiid SVN: r2522 - in branches/7.1.x: connectors/translator-ws/src/main/java/org/teiid/translator/ws and 6 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 15:54:14 -0400 (Thu, 02 Sep 2010)
New Revision: 2522
Modified:
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
Log:
TEIID-1138 finish the binary webservice feature. also moved the conversion logic of datasource/source to runtime types into datatiertuplesource.
Modified: branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -98,7 +98,6 @@
try {
final URL url = new URL(endpoint);
final HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
- httpConn.setDoOutput(true);
httpConn.setRequestMethod((String) requestContext.get(MessageContext.HTTP_REQUEST_METHOD));
Map<String, List<String>> header = (Map<String, List<String>>)requestContext.get(MessageContext.HTTP_REQUEST_HEADERS);
for (Map.Entry<String, List<String>> entry : header.entrySet()) {
@@ -113,7 +112,7 @@
}
if (msg != null) {
- httpConn.setDoInput(true);
+ httpConn.setDoOutput(true);
OutputStream os = httpConn.getOutputStream();
InputStream is = msg.getInputStream();
ObjectConverterUtil.write(os, is, -1);
@@ -220,16 +219,12 @@
} else {
//TODO: cache service/port/dispatch instances?
Bus bus = BusFactory.getThreadDefaultBus();
- if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
- BusFactory.setThreadDefaultBus(mcf.getBus());
- }
+ BusFactory.setThreadDefaultBus(mcf.getBus());
Service svc;
try {
svc = Service.create(svcQname);
} finally {
- if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
- BusFactory.setThreadDefaultBus(bus);
- }
+ BusFactory.setThreadDefaultBus(bus);
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); //$NON-NLS-1$
Modified: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -114,7 +114,6 @@
@Override
public List<?> getOutputParameterValues() throws TranslatorException {
- //TODO: this blob should bet buffered
return Arrays.asList(returnValue, returnValue.getContentType());
}
Modified: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -22,12 +22,10 @@
package org.teiid.translator.ws;
-import java.sql.SQLXML;
import java.util.Collections;
import java.util.List;
import javax.resource.cci.ConnectionFactory;
-import javax.xml.transform.Source;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.SOAPBinding;
@@ -112,10 +110,6 @@
return new WSProcedureExecution(command, metadata, executionContext, this, connection);
}
- public SQLXML convertToXMLType(Source value) {
- return (SQLXML)getTypeFacility().convertToRuntimeType(value);
- }
-
@Override
public final List getSupportedFunctions() {
return Collections.EMPTY_LIST;
Modified: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -42,9 +42,6 @@
import org.teiid.core.types.XMLType;
import org.teiid.language.Argument;
import org.teiid.language.Call;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
@@ -62,7 +59,7 @@
RuntimeMetadata metadata;
ExecutionContext context;
private Call procedure;
- private SQLXML returnValue;
+ private Source returnValue;
private WSConnection conn;
private WSExecutionFactory executionFactory;
@@ -132,14 +129,7 @@
// JBoss Native DispatchImpl throws exception when the source is null
source = new StreamSource(new StringReader("<none/>")); //$NON-NLS-1$
}
- Source result = dispatch.invoke(source);
- this.returnValue = this.executionFactory.convertToXMLType(result);
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- try {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "WebService Response: " + this.returnValue.getString()); //$NON-NLS-1$
- } catch (SQLException e) {
- }
- }
+ this.returnValue = dispatch.invoke(source);
} catch (SQLException e) {
throw new TranslatorException(e);
} catch (WebServiceException e) {
@@ -153,9 +143,6 @@
if (xml == null) {
return null;
}
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " + xml.getString()); //$NON-NLS-1$
- }
return xml.getSource(StreamSource.class);
}
Modified: branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 19:54:14 UTC (rev 2522)
@@ -156,7 +156,7 @@
<code>WsSecurityConfigName</code>. The namespace URI for the QName should be http://teiid.org.</para>
<example>
- <title>Example web service based data source</title>
+ <title>Example WS-Security enabled data source</title>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<no-tx-connection-factory>
@@ -204,6 +204,45 @@
please consult the <ulink url="https://cwiki.apache.org/CXF20DOC/ws-security.html">CXF documentation</ulink> or
the <ulink url="http://community.jboss.org/wiki/JBossWS-StackCXFUserGuide#WSSecurity">JBossWS-CXF documentation</ulink>.</para>
</section>
+ <section>
+ <title>Logging</title>
+ <para>Even when not using WS-Security, the <code>WsSecurityConfigURL</code> config property may then be used to supply the Spring XML configuration
+ file. Logging of requests and responses may be enabled for the entire bus or for specific port configurations.
+ If a specific port configuration is used, just as with WS-Security, the local name of the port
+ QName should match <code>WsSecurityConfigName</code> and the namespace URI should be http://teiid.org.</para>
+ <example>
+ <title>Example logging data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ <config-property name="WsSecurityConfigURL">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="WsSecurityConfigName">port_y</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting>
+<para>Corresponding xxx-jbossws-cxf.xml</para>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="{http://teiid.org}port_y"
+ createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ </jaxws:client>
+
+</beans>]]></programlisting>
+</example>
+ <para>Logging is then performed at an INFO level to the org.apache.cxf.interceptor context. Logging is only performed for non-binary web service calls.</para>
+ </section>
</section>
<section>
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-09-02 19:54:14 UTC (rev 2522)
@@ -1036,7 +1036,7 @@
</entry>
</row><row>
<entry>
- <para>TO_BYTES(x, encoding)</para>
+ <para id="to_bytes">TO_BYTES(x, encoding)</para>
</entry>
<entry>
<para>Return a blob from the clob with the given encoding.
Modified: branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-09-02 19:54:14 UTC (rev 2522)
@@ -693,21 +693,31 @@
</tgroup>
</table>
<para>There are ws importer settings, but it does provide metadata for dynamic vdbs.</para>
-<note>
-<para>Setting the org.teiid.CONNECTOR.WS logging context to detail will show the request/response documents as part of the log.</para>
-</note>
<section><title>Usage</title>
-<para>The main procedure, invoke, allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
+<para>The WS translator exposes low level procedures for accessing web services. See also the ws-weather example in the kit.</para>
+<section>
+<title>Invoke Procedure</title>
+<para>invoke allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
<programlisting>Procedure invoke(binding in STRING, action in STRING, request in XML, endpoint in STRING) returns XML</programlisting>
</para>
<para>The binding may be one of null (to use the default) HTTP, SOAP11, or SOAP12. Action with a SOAP binding indicates the SOAPAction value. Action with a HTTP binding indicates the HTTP method (GET, POST, etc.), which defaults to POST.</para>
<para>A null value for the binding or endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.</para>
-<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invoke(binding='HTTP', action='GET')</programlisting></para>
+<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invoke(binding=>'HTTP', action=>'GET')</programlisting></para>
<para>The request XML should be a valid XML document or root element.</para>
-<para>See the ws-weather example in the kit and database metadata for a full description of invoke.</para>
</section>
+<section>
+<title>InvokeHTTP Procedure</title>
+<para>invokeHttp can return the byte contents of an HTTP(S) call.
+<programlisting>Procedure invokeHttp(action in STRING, request in OBJECT, endpoint in STRING, contentType out STRING) returns BLOB</programlisting>
+</para>
+<para>Action indicates the HTTP method (GET, POST, etc.), which defaults to POST.</para>
+<para>A null value for endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.</para>
+<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invokeHttp(action=>'GET')</programlisting></para>
+<para>The request can be one of SQLXML, STRING, BLOB, or CLOB. The request will be sent as the POST payload in byte form. For STRING/CLOB values this will default to the UTF-8 encoding. To control the byte encoding, see the <link linkend="to_bytes">to_bytes</link> function.</para>
</section>
</section>
+</section>
+</section>
<section id="dynamic_vdbs">
<title>Dynamic VDBs</title>
<para>
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -31,8 +31,6 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.TransformationException;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.message.AtomicRequestID;
@@ -49,7 +47,6 @@
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.StoredProcedure;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionFactory;
@@ -75,9 +72,7 @@
private volatile ResultSetExecution execution;
private ProcedureBatchHandler procedureBatchHandler;
private org.teiid.language.Command translatedCommand;
- private Class<?>[] schema;
- private List<Integer> convertToRuntimeType;
- private boolean[] convertToDesiredRuntimeType;
+ private int expectedColumns;
/* End state information */
private boolean lastBatch;
@@ -200,17 +195,7 @@
this.connection = this.connector.getConnection(this.connectionFactory);
// Translate the command
Command command = this.requestMsg.getCommand();
- List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
- this.schema = new Class[symbols.size()];
- this.convertToDesiredRuntimeType = new boolean[symbols.size()];
- this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
- for (int i = 0; i < schema.length; i++) {
- SingleElementSymbol symbol = symbols.get(i);
- this.schema[i] = symbol.getType();
- this.convertToDesiredRuntimeType[i] = true;
- this.convertToRuntimeType.add(i);
- }
-
+ this.expectedColumns = command.getProjectedSymbols().size();
LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
this.translatedCommand = factory.translate(command);
@@ -285,8 +270,8 @@
this.lastBatch = true;
break;
}
- if (row.size() != this.schema.length) {
- throw new AssertionError("Inproper results returned. Expected " + this.schema.length + " columns, but was " + row.size()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (row.size() != this.expectedColumns) {
+ throw new AssertionError("Inproper results returned. Expected " + this.expectedColumns + " columns, but was " + row.size()); //$NON-NLS-1$ //$NON-NLS-2$
}
this.rowCount += 1;
batchSize++;
@@ -294,7 +279,6 @@
row = this.procedureBatchHandler.padRow(row);
}
- correctTypes(row);
rows.add(row);
// Check for max result rows exceeded
if(this.requestMsg.getMaxResultRows() > -1 && this.rowCount >= this.requestMsg.getMaxResultRows()){
@@ -318,7 +302,6 @@
if (this.procedureBatchHandler != null) {
List row = this.procedureBatchHandler.getParameterRow();
if (row != null) {
- correctTypes(row);
rows.add(row);
this.rowCount++;
}
@@ -346,46 +329,6 @@
return response;
}
- private void correctTypes(List row) throws TranslatorException {
- //TODO: add a proper source schema
- for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
- int index = convertToRuntimeType.get(i);
- Object value = row.get(index);
- if (value != null) {
- Object result = DataTypeManager.convertToRuntimeType(value);
- if (DataTypeManager.isLOB(result.getClass())) {
- this.securityContext.keepExecutionAlive(true);
- }
- if (value == result && !DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[index])) {
- convertToRuntimeType.remove(i);
- continue;
- }
- row.set(index, result);
- }
- }
- //TODO: add a proper intermediate schema
- for (int i = 0; i < row.size(); i++) {
- if (convertToDesiredRuntimeType[i]) {
- Object value = row.get(i);
- if (value != null) {
- Object result;
- try {
- result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
- } catch (TransformationException e) {
- throw new TranslatorException(e);
- }
- if (value == result) {
- convertToDesiredRuntimeType[i] = false;
- continue;
- }
- row.set(i, result);
- }
- } else {
- row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
- }
- }
- }
-
public static AtomicResultsMessage createResultsMessage(List[] batch, List columnSymbols) {
String[] dataTypes = TupleBuffer.getTypeNames(columnSymbols);
return new AtomicResultsMessage(batch, dataTypes);
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -38,6 +38,7 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
@@ -398,4 +399,8 @@
requestMgr.scheduleWork(r, priority, delay);
}
+ BufferManager getBufferManager() {
+ return bufferService.getBufferManager();
+ }
+
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -22,22 +22,41 @@
package org.teiid.dqp.internal.process;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
+import javax.activation.DataSource;
+import javax.xml.transform.Source;
+
import org.teiid.client.SourceWarning;
import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.StandardXMLTranslator;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.dqp.internal.datamgr.ConnectorWork;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.query.processor.xml.XMLUtil;
+import org.teiid.query.processor.xml.XMLUtil.FileStoreInputStreamFactory;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.TranslatorException;
@@ -58,6 +77,10 @@
private final ConnectorWork cwi;
private final DataTierManagerImpl dtm;
+ private List<Integer> convertToRuntimeType;
+ private boolean[] convertToDesiredRuntimeType;
+ private Class<?>[] schema;
+
// Data state
private int index;
private int rowsProcessed;
@@ -66,6 +89,7 @@
private volatile boolean canceled;
private boolean executed;
private volatile boolean done;
+ private boolean explicitClose;
private volatile ResultsFuture<AtomicResultsMessage> futureResult;
private volatile boolean running;
@@ -75,6 +99,17 @@
this.workItem = workItem;
this.cwi = cwi;
this.dtm = dtm;
+ List<SingleElementSymbol> symbols = this.aqr.getCommand().getProjectedSymbols();
+ this.schema = new Class[symbols.size()];
+ this.convertToDesiredRuntimeType = new boolean[symbols.size()];
+ this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
+ for (int i = 0; i < symbols.size(); i++) {
+ SingleElementSymbol symbol = symbols.get(i);
+ this.schema[i] = symbol.getType();
+ this.convertToDesiredRuntimeType[i] = true;
+ this.convertToRuntimeType.add(i);
+ }
+
Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
if (!aqr.isTransactional()) {
@@ -96,10 +131,75 @@
});
}
- public List getSchema() {
- return this.aqr.getCommand().getProjectedSymbols();
- }
+ private List correctTypes(List row) throws TransformationException {
+ for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
+ int idx = convertToRuntimeType.get(i);
+ Object value = row.get(idx);
+ if (value != null) {
+ Object result = convertToRuntimeType(value, this.schema[idx]);
+ if (DataTypeManager.isLOB(result.getClass())) {
+ explicitClose = true;
+ }
+ if (value == result && !DataTypeManager.DefaultDataClasses.OBJECT.equals(this.schema[idx])) {
+ convertToRuntimeType.remove(i);
+ continue;
+ }
+ row.set(idx, result);
+ }
+ }
+ //TODO: add a proper intermediate schema
+ for (int i = 0; i < row.size(); i++) {
+ if (convertToDesiredRuntimeType[i]) {
+ Object value = row.get(i);
+ if (value != null) {
+ Object result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
+ if (value == result) {
+ convertToDesiredRuntimeType[i] = false;
+ continue;
+ }
+ row.set(i, result);
+ }
+ } else {
+ row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
+ }
+ }
+ return row;
+ }
+ private Object convertToRuntimeType(Object value, Class<?> desiredType) throws TransformationException {
+ if (value instanceof DataSource && (!(value instanceof Source) || desiredType != DataTypeManager.DefaultDataClasses.XML)) {
+ if (value instanceof InputStreamFactory) {
+ return new BlobType(new BlobImpl((InputStreamFactory)value));
+ }
+ FileStore fs = dtm.getBufferManager().createFileStore("bytes"); //$NON-NLS-1$
+ //TODO: guess at the encoding from the content type
+ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(fs, Streamable.ENCODING);
+
+ try {
+ ObjectConverterUtil.write(fsisf.getOuputStream(), ((DataSource)value).getInputStream(), -1);
+ } catch (IOException e) {
+ throw new TransformationException(e, e.getMessage());
+ }
+ return new BlobType(new BlobImpl(fsisf));
+ }
+ if (value instanceof Source) {
+ if (value instanceof InputStreamFactory) {
+ return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
+ }
+ StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value);
+ SQLXMLImpl sqlxml;
+ try {
+ sqlxml = XMLUtil.saveToBufferManager(dtm.getBufferManager(), sxt);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ return new XMLType(sqlxml);
+ }
+ return DataTypeManager.convertToRuntimeType(value);
+ }
+
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
while (true) {
if (arm == null) {
@@ -124,7 +224,7 @@
receiveResults(results);
}
if (index < arm.getResults().length) {
- return this.arm.getResults()[index++];
+ return correctTypes(this.arm.getResults()[index++]);
}
arm = null;
if (isDone()) {
@@ -247,7 +347,7 @@
* @see TupleSource#closeSource()
*/
public void closeSource() {
- if (this.arm == null || this.arm.supportsImplicitClose()) {
+ if (!explicitClose) {
fullyCloseSource();
}
}
@@ -274,6 +374,7 @@
void receiveResults(AtomicResultsMessage response) {
this.arm = response;
+ explicitClose |= !arm.supportsImplicitClose();
rowsProcessed += response.getResults().length;
index = 0;
if (response.getWarnings() != null) {
Modified: branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -24,6 +24,7 @@
import static org.junit.Assert.*;
+import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.cache.DefaultCacheFactory;
@@ -52,9 +53,13 @@
private AtomicRequestMessage request;
private Command command;
private DataTierTupleSource info;
- private AutoGenDataService connectorManager;
+ private AutoGenDataService connectorManager = new AutoGenDataService();
private RequestWorkItem workItem;
+ @Before public void setUp() {
+ connectorManager = new AutoGenDataService();
+ }
+
private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -69,7 +74,6 @@
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.exampleBQTVDB());
- connectorManager = new AutoGenDataService();
rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
rm.setBufferService(new FakeBufferService());
@@ -126,8 +130,8 @@
}
@Test public void testNoRowsException() throws Exception {
+ this.connectorManager.setRows(0);
helpSetup(3);
- this.connectorManager.setRows(0);
while (true) {
try {
assertNull(info.nextTuple());
Modified: branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-09-02 18:41:23 UTC (rev 2521)
+++ branches/7.1.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-09-02 19:54:14 UTC (rev 2522)
@@ -119,6 +119,7 @@
Class type = symbol.getType();
row.add( getValue(type) );
}
+ rows[i] = row;
}
return rows;
14 years, 3 months
teiid SVN: r2521 - in branches/7.1.x/build/kits/jboss-container/teiid-examples: jca and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-09-02 14:41:23 -0400 (Thu, 02 Sep 2010)
New Revision: 2521
Added:
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
Log:
TEIID-1236: adding sample ds files to kit
Added: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml (rev 0)
+++ branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml 2010-09-02 18:41:23 UTC (rev 2521)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>fileDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-file.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- Directory where the data files are stored -->
+ <config-property name="ParentDirectory" type="java.lang.String">directory</config-property>
+
+ <max-pool-size>20</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Property changes on: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/file-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml (rev 0)
+++ branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml 2010-09-02 18:41:23 UTC (rev 2521)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>ldapDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-file.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- LDAP Directroy URL (required)-->
+ <config-property name="LdapUrl">ldap://ldapServer:389</config-property>
+
+ <!-- Ldap Admin User DN (required)-->
+ <config-property name="LdapAdminUserDN">cn=???,ou=???,dc=???</config-property>
+
+ <!-- Ldap Admin Password (required)-->
+ <config-property name="LdapAdminUserPassword">pass</config-property>
+
+ <!-- Ldap Transaction Timeout (ms) -1 = no time out (optional) -->
+ <config-property name="LdapTxnTimeoutInMillis">-1</config-property>
+
+ <max-pool-size>20</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Property changes on: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/ldap-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt (rev 0)
+++ branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt 2010-09-02 18:41:23 UTC (rev 2521)
@@ -0,0 +1,8 @@
+This folder contains the sample "-ds.xml" files that can be created for Teiid sources.
+
+JDBC: Please check "<jboss-as>/docs/examples/jca" directory for creating a -ds.xml file for any type of relational database.
+Please note you can find samples for creating both "local" and "xa" data sources.
+
+Web Serivices with ws-security: Check out Admin guide for a sample with explanation on how to use it.
+
+All the others types of sources, please find a example in this directory.
\ No newline at end of file
Property changes on: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/readme.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml (rev 0)
+++ branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml 2010-09-02 18:41:23 UTC (rev 2521)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>salesforceDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-salesforce.rar</rar-name>
+
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- URL; the below is test; replace with actual URL you need to connect to -->
+ <config-property name="URL">https://test.salesforce.com/services/Soap/u/10.0</config-property>
+
+ <config-property name="username">user</config-property>
+ <config-property name="password">pass</config-property>
+
+ <!-- connection pool size -->
+ <max-pool-size>1</max-pool-size>
+ </no-tx-connection-factory>
+</connection-factories>
Property changes on: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/salesforce-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml (rev 0)
+++ branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml 2010-09-02 18:41:23 UTC (rev 2521)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <!-- The jndi name of the DataSource -->
+ <jndi-name>webserviceDS</jndi-name>
+
+ <!-- The resource archive file that defines JCA connection for Sales Force (do not change this) -->
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <!-- connection interface; (do not change this) -->
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+
+ <!-- End point for the web service -->
+ <config-property name="EndPoint">endpoint url</config-property>
+
+
+ <max-pool-size>1</max-pool-size>
+
+ </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file
Property changes on: branches/7.1.x/build/kits/jboss-container/teiid-examples/jca/webservices-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 3 months
teiid SVN: r2520 - in branches/7.1.x: build/kits/jboss-container and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 12:55:47 -0400 (Thu, 02 Sep 2010)
New Revision: 2520
Added:
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
Modified:
branches/7.1.x/build/assembly/jboss-container/dist.xml
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
branches/7.1.x/connectors/connector-ws/pom.xml
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
Log:
TEIID-1138 TEIID-1148 initial commit of requiring cxf and adding support for binary webservice calls
Modified: branches/7.1.x/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/7.1.x/build/assembly/jboss-container/dist.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/build/assembly/jboss-container/dist.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -18,7 +18,8 @@
<includes>
<include>**/*.sh</include>
</includes>
- <fileMode>755</fileMode>
+ <fileMode>755</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -39,6 +40,7 @@
</includes>
<outputDirectory>lib</outputDirectory>
<fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<fileSet>
@@ -47,7 +49,8 @@
<include>vdb-deployer.xsd</include>
</includes>
<outputDirectory>teiid-docs/schema</outputDirectory>
- <fileMode>0644</fileMode>
+ <fileMode>0644</fileMode>
+ <directoryMode>0755</directoryMode>
</fileSet>
<!-- We may want to do this if including multiple doc types or languages
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-02 16:55:47 UTC (rev 2520)
@@ -30,7 +30,8 @@
<LI><B>Improved Plan Caching</B> - plans used by internal materialization and stored procedure plans will be automatically cached in the prepared plan cache. Improvements were also made to reduce the memory footprint of the plans.
<LI><B>Refined Load Balancing and Fail Over</B> - clients can use use the statement "SET NEWINSTANCE TRUE" to allow their connection to select a new server instance. See the Client Developer's Guide for more information.
<LI><B>Simplified Role Usage</B> - a role can now be assigned to any authenticated user via the any-authenticated attribute on the data-role element.
- <LI><B>Materialized View Performance</B> - materialized view tables will now automatically create and use non-unique secondary indexes for unique constraints and indexes defined on the view.
+ <LI><B>Materialized View Performance</B> - materialized view tables will now automatically create and use non-unique secondary indexes for unique constraints and indexes defined on the view.
+ <LI><B>Binary Web Service Calls</B> - the ws translator now provides an invokeHttp procedure to return the blob contents and string content type of an http/https call.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -74,6 +75,8 @@
<h4>from 7.1</h4>
<ul>
+ <li>Apache CXF is now expected to be used as the web services stack provider through JBossWS-CXF. See the Admin Guide for instructions on
+ installing CXF for use with Teiid's Salesforce and web service connectors.
<li>The default for data role checking is now "true". However only VDBs with data roles will have roles enforced.
<li>The default prepared plan cache size was increased to 512, since it is targeted by internal plans as well.
</ul>
@@ -108,26 +111,6 @@
the parseTime function cannot be pushed down. This should be addressed in future releases.
</ul>
-<h4>Salesforce as Source</h4>
-Before Salesforce is used in your data integration project, the below issues need to be resolved.
-<ul>
- <li>Manually copy the following libraries from the JBOSS_HOME/client directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used:
- <ul>
- <li>jbossws-native-saaj.jar</li>
- <li>jbossws-native-jaxrpc.jar</li>
- <li>jbossws-native-jaxws.jar</li>
- <li>jbossws-native-jaxws-ext.jar</li>
- </ul>
- </li>
- <li>There is issue with invoking "https" based URL with out specifying the either a keystore or truststore properties with JBoss remoting 2.5.1. Generally you do not need to specify the truststore as a anonymous truststore will be negotiated, however if you fail to supply the following system properties there will be a error message in the log (query will execute even with out the properties). Add these to JBOSS_INSTALL/bin/run.conf file under JAVA_OPTS
- <ul>
- <li>-Djava.net.ssl.keyStore=<path-to-truststore></li>
- <li>-Djava.net.ssl.keyStoreType=<certificate-type></li>
- <li>-Djava.net.ssl.keyStorePassword=<password></li>
- </ul>
- </li>
-</ul>
-
<h2><a name="LibraryUpdates">Thirdparty Library Updates</a></h2>
The following components have been updated:
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -40,11 +40,8 @@
import java.util.Map;
import java.util.Set;
-import javax.xml.transform.Source;
-
import org.teiid.core.CorePlugin;
import org.teiid.core.ErrorMessageKeys;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.basic.AnyToObjectTransform;
import org.teiid.core.types.basic.AnyToStringTransform;
import org.teiid.core.types.basic.BooleanToNumberTransform;
@@ -733,21 +730,6 @@
return new XMLType(value);
}
});
- //Note: the default transform from non-InputStreamFactory source is a fully materialized string
- addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- try {
- return new XMLType(new SQLXMLImpl(sxt.getString()));
- } catch (Exception e) {
- throw new TeiidRuntimeException(e);
- }
- }
- });
addSourceTransform(Date.class, new SourceTransform<Date, Timestamp>() {
@Override
public Timestamp transform(Date value) {
Modified: branches/7.1.x/connectors/connector-ws/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/pom.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/pom.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -29,11 +29,29 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-core</artifactId>
- <version>3.1.1.GA</version>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>2.2.2</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>2.2.2</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified: branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -1,21 +1,41 @@
package org.teiid.resource.adapter.ws;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
+import javax.activation.DataSource;
import javax.resource.ResourceException;
import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Response;
import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
-import org.jboss.ws.core.ConfigProvider;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.DispatchImpl;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.Base64;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.StringUtil;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -28,9 +48,129 @@
* TODO: set a handler chain
*/
public class WSConnectionImpl extends BasicConnection implements WSConnection {
- private static QName svcQname = new QName("http://teiid.org", "teiid"); //$NON-NLS-1$ //$NON-NLS-2$
- private static QName portQName = new QName("http://teiid.org", "teiid");//$NON-NLS-1$ //$NON-NLS-2$
+ private static final class HttpDataSource implements DataSource {
+ private final URL url;
+ private final HttpURLConnection httpConn;
+
+ private HttpDataSource(URL url, HttpURLConnection httpConn) {
+ this.url = url;
+ this.httpConn = httpConn;
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getName() {
+ return url.getPath();
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return httpConn.getInputStream();
+ }
+
+ @Override
+ public String getContentType() {
+ return httpConn.getContentType();
+ }
+ }
+
+ /**
+ * Workaround dispatch, since neither JBossNative nor CXF 2.2.2 implement
+ * this functionality.
+ */
+ private static final class BinaryDispatch implements Dispatch<DataSource> {
+
+ HashMap<String, Object> requestContext = new HashMap<String, Object>();
+
+ private String endpoint;
+
+ public BinaryDispatch(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public DataSource invoke(DataSource msg) {
+ try {
+ final URL url = new URL(endpoint);
+ final HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
+ httpConn.setDoOutput(true);
+ httpConn.setRequestMethod((String) requestContext.get(MessageContext.HTTP_REQUEST_METHOD));
+ Map<String, List<String>> header = (Map<String, List<String>>)requestContext.get(MessageContext.HTTP_REQUEST_HEADERS);
+ for (Map.Entry<String, List<String>> entry : header.entrySet()) {
+ String value = StringUtil.join(entry.getValue(), ","); //$NON-NLS-1$
+ httpConn.setRequestProperty(entry.getKey(), value);
+ }
+ String username = (String) requestContext.get(Dispatch.USERNAME_PROPERTY);
+ String password = (String) requestContext.get(Dispatch.PASSWORD_PROPERTY);
+
+ if (username != null) {
+ httpConn.setRequestProperty("Authorization", "Basic " + Base64.encodeBytes((username + ':' + password).getBytes())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (msg != null) {
+ httpConn.setDoInput(true);
+ OutputStream os = httpConn.getOutputStream();
+ InputStream is = msg.getInputStream();
+ ObjectConverterUtil.write(os, is, -1);
+ }
+
+ return new HttpDataSource(url, httpConn);
+ } catch (IOException e) {
+ throw new WebServiceException(e);
+ }
+ }
+
+ @Override
+ public Response<DataSource> invokeAsync(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Future<?> invokeAsync(DataSource msg, AsyncHandler<DataSource> handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void invokeOneWay(DataSource msg) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Binding getBinding() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public EndpointReference getEndpointReference() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T extends EndpointReference> T getEndpointReference(
+ Class<T> clazz) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Map<String, Object> getRequestContext() {
+ return requestContext;
+ }
+
+ @Override
+ public Map<String, Object> getResponseContext() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ static final String DEFAULT_NAMESPACE_URI = "http://teiid.org"; //$NON-NLS-1$
+ static final String DEFAULT_LOCAL_NAME = "teiid"; //$NON-NLS-1$
+
+ private static QName svcQname = new QName(DEFAULT_NAMESPACE_URI, DEFAULT_LOCAL_NAME);
private WSManagedConnectionFactory mcf;
public WSConnectionImpl(WSManagedConnectionFactory mcf) {
@@ -38,7 +178,7 @@
}
public <T> Dispatch<T> createDispatch(String binding, String endpoint, Class<T> type, Mode mode) {
- Service svc = Service.create(svcQname);
+ ArgCheck.isNotNull(binding);
if (endpoint != null) {
try {
new URL(endpoint);
@@ -74,15 +214,40 @@
} else {
endpoint = mcf.getEndPoint();
}
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); //$NON-NLS-1$
+ Dispatch<T> dispatch = null;
+ if (HTTPBinding.HTTP_BINDING.equals(binding) && type == DataSource.class) {
+ dispatch = (Dispatch<T>) new BinaryDispatch(endpoint);
+ } else {
+ //TODO: cache service/port/dispatch instances?
+ Bus bus = BusFactory.getThreadDefaultBus();
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
+ BusFactory.setThreadDefaultBus(mcf.getBus());
+ }
+ Service svc;
+ try {
+ svc = Service.create(svcQname);
+ } finally {
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ }
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint); //$NON-NLS-1$
+ }
+ svc.addPort(mcf.getPortQName(), binding, endpoint);
+
+ dispatch = svc.createDispatch(mcf.getPortQName(), type, mode);
+
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity
+ && mcf.getOutInterceptors() != null) {
+ Client client = ((DispatchImpl)dispatch).getClient();
+ Endpoint ep = client.getEndpoint();
+ for (Interceptor i : mcf.getOutInterceptors()) {
+ ep.getOutInterceptors().add(i);
+ }
+ }
}
- svc.addPort(portQName, binding, endpoint);
-
- Dispatch<T> dispatch = svc.createDispatch(portQName, type, mode);
-
if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
@@ -96,10 +261,6 @@
httpHeaders.put("Content-Type", Collections.singletonList("text/xml; charset=utf-8"));//$NON-NLS-1$ //$NON-NLS-2$
httpHeaders.put("User-Agent", Collections.singletonList("Teiid Server"));//$NON-NLS-1$ //$NON-NLS-2$
dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
- } else if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
- // JBoss WS-Security
- ((ConfigProvider) dispatch).setSecurityConfig(mcf.getWsSecurityConfigURL());
- ((ConfigProvider) dispatch).setConfigName(mcf.getWsSecurityConfigName());
}
return dispatch;
}
Modified: branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -21,8 +21,16 @@
*/
package org.teiid.resource.adapter.ws;
+import java.util.List;
+
import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
import org.teiid.core.BundleUtil;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.resource.spi.BasicConnectionFactory;
@@ -43,8 +51,26 @@
private String authPassword; // httpbasic - password
private String authUserName; // httpbasic - username
+ private Bus bus;
+ private QName portQName;
+ private List<Interceptor> outInterceptors;
+
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException {
+ String configName = getWsSecurityConfigName();
+ if (configName == null) {
+ configName = WSConnectionImpl.DEFAULT_LOCAL_NAME;
+ }
+ this.portQName = new QName(WSConnectionImpl.DEFAULT_NAMESPACE_URI, configName);
+ if (wsSecurityConfigURL != null) {
+ bus = new SpringBusFactory().createBus(wsSecurityConfigURL);
+ JaxWsClientFactoryBean instance = new JaxWsClientFactoryBean();
+ Configurer configurer = bus.getExtension(Configurer.class);
+ if (null != configurer) {
+ configurer.configureBean(portQName.toString() + ".jaxws-client.proxyFactory", instance); //$NON-NLS-1$
+ }
+ outInterceptors = instance.getOutInterceptors();
+ }
return new BasicConnectionFactory() {
@Override
public BasicConnection getConnection() throws ResourceException {
@@ -101,4 +127,16 @@
this.wsSecurityConfigName = wsSecurityConfigName;
}
+ public Bus getBus() {
+ return bus;
+ }
+
+ public QName getPortQName() {
+ return portQName;
+ }
+
+ public List<Interceptor> getOutInterceptors() {
+ return outInterceptors;
+ }
+
}
Modified: branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -66,13 +66,13 @@
</config-property>
<config-property>
- <description>{$display:"URL to the WS-Security Configuration File(jboss-wsse-client.xml)",$description:"JBoss WS-Security client configuration File"}</description>
+ <description>{$display:"URL to the WS-Security Configuration File(typically jbossws-cxf.xml)",$description:"CXF client configuration File"}</description>
<config-property-name>WsSecurityConfigURL</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
<config-property>
- <description>{$display:"WS-Security Configuration Name in jboss-wsse-client.xml",$description:"JBoss WS-Security client configuration name to use"}</description>
+ <description>{$display:"WS-Security Configuration Name",$description:"Local name of the QName of the port configuration to use with this connection. The port namespace URI should be http://teiid.org"}</description>
<config-property-name>WsSecurityConfigName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
Added: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java (rev 0)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.ws;
+
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.sql.rowset.serial.SerialClob;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.WSConnection;
+
+/**
+ * http handler
+ */
+public class BinaryWSProcedureExecution implements ProcedureExecution {
+
+ RuntimeMetadata metadata;
+ ExecutionContext context;
+ private Call procedure;
+ private DataSource returnValue;
+ private WSConnection conn;
+ WSExecutionFactory executionFactory;
+
+ /**
+ * @param env
+ */
+ public BinaryWSProcedureExecution(Call procedure, RuntimeMetadata metadata, ExecutionContext context, WSExecutionFactory executionFactory, WSConnection conn) {
+ this.metadata = metadata;
+ this.context = context;
+ this.procedure = procedure;
+ this.conn = conn;
+ this.executionFactory = executionFactory;
+ }
+
+ public void execute() throws TranslatorException {
+ List<Argument> arguments = this.procedure.getArguments();
+
+ String method = (String)arguments.get(0).getArgumentValue().getValue();
+ Object payload = arguments.get(1).getArgumentValue().getValue();
+ String endpoint = (String)arguments.get(2).getArgumentValue().getValue();
+ try {
+ Dispatch<DataSource> dispatch = conn.createDispatch(HTTPBinding.HTTP_BINDING, endpoint, DataSource.class, Mode.MESSAGE);
+
+ if (method == null) {
+ method = "POST"; //$NON-NLS-1$
+ }
+
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, method);
+ if (payload != null && !"POST".equalsIgnoreCase(method)) { //$NON-NLS-1$
+ throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
+ }
+
+ DataSource ds = null;
+ if (payload instanceof String) {
+ ds = new InputStreamFactory.ClobInputStreamFactory(new SerialClob(((String)payload).toCharArray()));
+ } else if (payload instanceof SQLXML) {
+ ds = new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML)payload);
+ } else if (payload instanceof Clob) {
+ ds = new InputStreamFactory.ClobInputStreamFactory((Clob)payload);
+ } else if (payload instanceof Blob) {
+ ds = new InputStreamFactory.BlobInputStreamFactory((Blob)payload);
+ }
+
+ returnValue = dispatch.invoke(ds);
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ } catch (WebServiceException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ //TODO: this blob should bet buffered
+ return Arrays.asList(returnValue, returnValue.getContentType());
+ }
+
+ public void close() {
+
+ }
+
+ public void cancel() throws TranslatorException {
+ // no-op
+ }
+}
Property changes on: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/BinaryWSProcedureExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -52,6 +52,8 @@
@Translator(name="ws", description="A translator for making Web Service calls")
public class WSExecutionFactory extends ExecutionFactory<ConnectionFactory, WSConnection> {
+ private static final String INVOKE_HTTP = "invokeHttp"; //$NON-NLS-1$
+
public enum Binding {
HTTP(HTTPBinding.HTTP_BINDING),
SOAP11(SOAPBinding.SOAP11HTTP_BINDING),
@@ -104,6 +106,9 @@
@Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, WSConnection connection)
throws TranslatorException {
+ if (command.getProcedureName().equalsIgnoreCase(INVOKE_HTTP)) {
+ return new BinaryWSProcedureExecution(command, metadata, executionContext, this, connection);
+ }
return new WSProcedureExecution(command, metadata, executionContext, this, connection);
}
@@ -140,11 +145,11 @@
param.setNullType(NullType.Nullable);
metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
- /*
+
p = metadataFactory.addProcedure(INVOKE_HTTP);
p.setAnnotation("Invokes a webservice that returns an binary result"); //$NON-NLS-1$
- param = metadataFactory.addProcedureParameter("method", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param = metadataFactory.addProcedureParameter("action", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
param.setAnnotation("Sets the HTTP Method (GET, POST - default, etc.)."); //$NON-NLS-1$
param.setNullType(NullType.Nullable);
@@ -159,7 +164,6 @@
metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.BLOB, Type.ReturnValue, p); //$NON-NLS-1$
metadataFactory.addProcedureParameter("contentType", TypeFacility.RUNTIME_NAMES.STRING, Type.Out, p); //$NON-NLS-1$
- */
}
}
Modified: branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
===================================================================
--- branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -83,7 +83,7 @@
String style = (String)arguments.get(0).getArgumentValue().getValue();
String action = (String)arguments.get(1).getArgumentValue().getValue();
XMLType docObject = (XMLType)arguments.get(2).getArgumentValue().getValue();
- Source source = null;
+ StreamSource source = null;
try {
source = convertToSource(docObject);
String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
@@ -99,7 +99,7 @@
}
}
- Dispatch<Source> dispatch = conn.createDispatch(style, endpoint, Source.class, executionFactory.getDefaultServiceMode());
+ Dispatch<StreamSource> dispatch = conn.createDispatch(style, endpoint, StreamSource.class, executionFactory.getDefaultServiceMode());
if (Binding.HTTP.getBindingId().equals(style)) {
if (action == null) {
Modified: branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -47,6 +47,35 @@
</orderedlist>
</section>
<section>
+ <title>CXF Installation</title>
+ <para>The usage of CXF is expected for utilizing Salesforce and Web Services connectivity through Teiid. If you do not plan on integrating either of these features, then you may leave JBoss AS with the default "native" web services stack.</para>
+ <orderedlist>
+ <listitem>
+ <para>Download <ulink url="http://www.jboss.org/jbossws/downloads/">JBossWS-CXF 3.1.2</ulink> and unzip to a temporary location.</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, save the ant.properties.example file as ant.properties and change the values for jboss510.home, jbossws.integration.target, jboss.server.instance, jboss.bind.address accordingly:
+ <programlisting>
+...
+jboss510.home=<jboss-install>
+
+# The JBoss server under test. This can be [jboss500|jboss501|jboss510|jboss600]
+jbossws.integration.target=jboss510
+
+# The JBoss settings
+jboss.server.instance=<profile>
+jboss.bind.address=<bind address>
+</programlisting> The jboss-install location should be the root directory of your AS installation, profile (typically default) should indicate the profile selected for your Teiid installation, and the bind address should be the bind address used when launching JBoss AS (use the value localhost if you do not set the bind address when launching JBoss AS).</para>
+ </listitem>
+ <listitem>
+ <para>From the jbossws-cxf-bin-dist directory, install JBossWS-CXF by running the ANT build script: <programlisting>$ant deploy-jboss510</programlisting></para>
+ </listitem>
+ <listitem>
+ <para>Optionally run tests to verify that there are no errors with the installation: <programlisting>$ant tests</programlisting></para>
+ </listitem>
+ </orderedlist>
+ </section>
+ <section>
<title>Directory Structure Explained</title>
<example>
<title>Directory Structure</title>
Modified: branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-09-02 16:55:47 UTC (rev 2520)
@@ -53,21 +53,32 @@
<section>
<title>Deploying VDB Dependencies</title>
<para>Apart from deploying the VDB, the user is also responsible for providing all the necessary
- dependent libraries, configuration for creating the data sources that are needed by the Schemas (models)
- defined in "META-INF/vdb.xml" file inside your VDB. This section shows you a sample VDB configuration needed.</para>
+ dependent libraries, configuration for creating the data sources that are needed by the models (schemas)
+ defined in "META-INF/vdb.xml" file inside your VDB. For example, if you are trying to integrate Oracle and File sources in your VDB, then you are responsible for
+ providing the JDBC driver for the Oracle source and any necessary documents and configuration that are needed by the File Translator.</para>
- <para>For example, if you are trying to integrate Oracle and File sources in your VDB, then you are responsible for
- providing the JDBC driver for the Oracle source, and any necessary documents and configuration that are needed by the File Translator.</para>
+ <para>Data source instances may be used by only one VDB, or may be shared with as many VDBs or other applications as makes since for your deployments.
+ Consider sharing connections to sources that have heavy-weight and resource constrained connections.</para>
- <para>Once the VDB and its dependencies are deployed, then client applications can connect using the JDBC API. If there are any errors in the deployment, a connection attempt will not be successful and a message will be logged. You can use the
- <link linkend="admin-console">admin-console</link> tool or check the log files for errors and correct them before proceeding.</para>
+ <para>With the exception of JDBC, each of the data sources supported by has a corresponding .rar (zip format) file in <jboss-install>/server/<profile>/deploy/teiid/connectors.
+ If not using JOPR or other tooling to create your -ds.xml files, you can consult the .rar files META-INF/ra.xml for a full description of how the source can be configured.
+ </para>
+ <para>Some -ds.xml files may contain passwords or other sensitive information.
+ See the WIKI article <ulink url="http://community.jboss.org/wiki/EncryptingDataSourcePasswords">EncryptingDataSourcePasswords</ulink> to not store passwords in plain text.</para>
+
+ <para>Once the VDB and its dependencies are deployed, then client applications can connect using the JDBC API. If there are any errors in the deployment, a connection attempt will not be successful and a message will be logged.
+ You can use the <link linkend="admin-console">admin-console</link> tool or check the log files for errors and correct them before proceeding.</para>
+
<section>
- <title>Creating An Oracle Data Source</title>
+ <title>JDBC Data Sources</title>
+ <para>The following is an example highlighting configuring an Oracle data source. The process is nearly identical regardless of the vendor.
+ Typically only the client jar and the setting in the -ds.xml file change.</para>
+ <para>There are templates for all the data sources in the "<jboss-install>/docs/examples/jca" directory.</para>
<orderedlist>
<listitem> <para>Copy the Oracle JDBC JAR file into "<jboss-install>/server/<profile>/lib" directory </para> </listitem>
<listitem> <para>Create a "data source" to the Oracle instance in the JBoss container. This typically
- done by creating "xxx-ds.xml" file and copying this file to the "<jboss-install>/server/%lt;profile>/deploy"
+ done by creating "xxx-ds.xml" file and copying this file to the "<jboss-install>/server/<profile>/deploy"
directory. The following shows a "-ds.xml" file template for Oracle. You can also use admin-console to create this data source. </para>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<datasources>
@@ -99,26 +110,140 @@
</datasources>]]></programlisting>
</listitem>
</orderedlist>
- <para>There are templates for all the data sources in the "<jboss-install>/docs/examples/jca" directory.</para>
</section>
<section>
- <title>Creating A File Data Source</title>
- <para>File data source uses Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
- "<jboss-install>/server/%lt;profile>/deploy" directory.</para>
+ <title>File Data Sources</title>
+ <para>File data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
<example>
<title>Template for creating a File based data source</title>
<programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<no-tx-connection-factory>
<jndi-name>text-source</jndi-name>
- <rar-name>connector-file-{version}.rar</rar-name>
+ <rar-name>teiid-connector-file.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
- <config-property name="ParentDirectory" type="java.lang.String">path-to-the-directory-of-data-file</config-property>
- <max-pool-size>1</max-pool-size>
- </no-tx-connection-factory>
+ <config-property name="ParentDirectory">path-to-the-directory-of-data-file</config-property>
+ </no-tx-connection-factory>
</connection-factories>]]></programlisting></example>
</section>
+
+ <section>
+ <title>Web Service Data Sources</title>
+ <para>Web service data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating a web service based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ <section>
+ <title>WS-Security</title>
+
+ <para>To enable the use of WS-Security, the <code>SecurityType</code> should be set to WSSecurity.
+ The <code>WsSecurityConfigURL</code> config property may then be used to supply the Spring XML configuration
+ file for the CXF Bus and port configuration to be used by these connections. At this time however, Teiid does not expect or use
+ a WSDL to describe the service being used. Thus the Spring XML configuration file is not an adjunct
+ to policy information in the WSDL, it must instead contain all of the relevant policy configuration. It is also expected that only
+ 1 port configuration will be used by this data source. You may explicitly set the local name of the port QName to use via the
+ <code>WsSecurityConfigName</code>. The namespace URI for the QName should be http://teiid.org.</para>
+
+ <example>
+ <title>Example web service based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>somewhere-ws-source</jndi-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="EndPoint">http://somewhere.com</config-property>
+ <config-property name="WsSecurityConfigURL">${jboss.server.home.dir}/server/default/conf/xxx-jbossws-cxf.xml</config-property>
+ <config-property name="WsSecurityConfigName">port_x</config-property>
+ <config-property name="SecurityType">WSSecurity</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting>
+<para>Corresponding xxx-jbossws-cxf.xml file that adds a timestamp to the SOAP header</para>
+<programlisting><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <jaxws:client name="{http://teiid.org}port_x"
+ createdFromAPI="true">
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="Timestamp_Request"/>
+ </jaxws:outInterceptors>
+ </jaxws:client>
+
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="Timestamp_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp"/>
+ <map>
+ </constructor-arg>
+ </bean>
+
+</beans>]]></programlisting>
+ <para>Note that the client port configuration is matched to the data source instance by the QName {http://teiid.org}port_x.
+ The configuration may contain other port confiruations with different local names.</para>
+</example>
+ <para>For more information on configuring CXF interceptors,
+ please consult the <ulink url="https://cwiki.apache.org/CXF20DOC/ws-security.html">CXF documentation</ulink> or
+ the <ulink url="http://community.jboss.org/wiki/JBossWS-StackCXFUserGuide#WSSecurity">JBossWS-CXF documentation</ulink>.</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Salesforce Data Sources</title>
+ <para>Salesforce data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating a Salesforce based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>sf-source</jndi-name>
+ <rar-name>teiid-connector-salesforce.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="URL">https://test.salesforce.com/services/Soap/u/10.0</config-property>
+ <config-property name="username">username</config-property>
+ <config-property name="password">password</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
+ <section>
+ <title>LDAP Data Sources</title>
+ <para>LDAP data sources use a Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/<profile>/deploy" directory.</para>
+ <example>
+ <title>Template for creating an LDAP based data source</title>
+ <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>ldap-source</jndi-name>
+ <rar-name>teiid-connector-ldap.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="LdapAdminUserDN">cn=x,ou=y,dc=z</config-property>
+ <config-property name="LdapAdminUserPassword">password</config-property>
+ <config-property name="LdapUrl">ldap://ldapServer:389</config-property>
+ </no-tx-connection-factory>
+</connection-factories>]]></programlisting></example>
+ </section>
+
</section>
<section id="vdb-versioning">
Modified: branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-02 14:38:11 UTC (rev 2519)
+++ branches/7.1.x/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-09-02 16:55:47 UTC (rev 2520)
@@ -48,8 +48,6 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import javax.xml.transform.Source;
-
import org.teiid.common.buffer.BatchManager;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.FileStore;
@@ -60,20 +58,13 @@
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BatchManager.ManagedBatch;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.SourceTransform;
-import org.teiid.core.types.StandardXMLTranslator;
-import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.processor.relational.ListNestedSortComparator;
-import org.teiid.query.processor.xml.XMLUtil;
/**
@@ -502,25 +493,7 @@
@Override
public void initialize() throws TeiidComponentException {
- //TODO: remove me - connectors should be able to do this statefully
- DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
- @Override
- public XMLType transform(Source value) {
- if (value instanceof InputStreamFactory) {
- return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
- }
- StandardXMLTranslator sxt = new StandardXMLTranslator(value);
- SQLXMLImpl sqlxml;
- try {
- sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt);
- } catch (TeiidComponentException e) {
- throw new TeiidRuntimeException(e);
- } catch (TeiidProcessingException e) {
- throw new TeiidRuntimeException(e);
- }
- return new XMLType(sqlxml);
- }
- });
+
}
@Override
14 years, 3 months
teiid SVN: r2519 - branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-09-02 10:38:11 -0400 (Thu, 02 Sep 2010)
New Revision: 2519
Modified:
branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
Log:
TEIID-1228 adding logic to handle any authenticated updates
Modified: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java 2010-09-01 21:46:44 UTC (rev 2518)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java 2010-09-02 14:38:11 UTC (rev 2519)
@@ -82,8 +82,9 @@
List<ManagedObject> policies = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
for(ManagedObject managedPolicy:policies) {
String policyName = ManagedUtil.getSimpleValue(managedPolicy, "name", String.class); //$NON-NLS-1$
+ Boolean anyAuthenticated = ManagedUtil.getSimpleValue(managedPolicy, "anyAuthenticated", Boolean.class); //$NON-NLS-1$
DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
+ policy.setAnyAuthenticated(Boolean.TRUE.equals(anyAuthenticated));
ManagedProperty mappedRoleNames = managedPolicy.getProperty("mappedRoleNames");//$NON-NLS-1$
if (mappedRoleNames != null){
List<String> roleNames = (List<String>)MetaValueFactory.getInstance().unwrap(mappedRoleNames.getValue());
14 years, 3 months