teiid SVN: r2340 - in trunk: build/kits/jboss-container and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 21:59:05 -0400 (Tue, 13 Jul 2010)
New Revision: 2340
Modified:
trunk/build/assembly/jboss-container/dist.xml
trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/marketdata-file-ds.xml
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/weather-ds.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
Log:
TEIID-1143 removing version numbers from connector rars and updating the status checker to consider if the java context is used
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/build/assembly/jboss-container/dist.xml 2010-07-14 01:59:05 UTC (rev 2340)
@@ -136,15 +136,40 @@
<includeSubModules>true</includeSubModules>
<includes>
+ <include>org.jboss.teiid.connectors:connector-file:rar</include>
+ <include>org.jboss.teiid.connectors:connector-ldap:rar</include>
+ <include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
+ <include>org.jboss.teiid.connectors:connector-ws:rar</include>
+ </includes>
+
+ <binaries>
+ <outputFileNameMapping>teiid-${module.artifactId}.rar</outputFileNameMapping>
+ <includeDependencies>true</includeDependencies>
+ <unpack>false</unpack>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>false</unpack>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </dependencySet>
+ </dependencySets>
+ <outputDirectory>deploy/teiid/connectors</outputDirectory>
+ <fileMode>0644</fileMode>
+ </binaries>
+
+ </moduleSet>
+
+ <!-- These are built in translators -->
+ <moduleSet>
+ <includeSubModules>true</includeSubModules>
+
+ <includes>
<include>org.jboss.teiid.connectors:translator-jdbc</include>
<include>org.jboss.teiid.connectors:translator-loopback</include>
<include>org.jboss.teiid.connectors:translator-file</include>
- <include>org.jboss.teiid.connectors:connector-file:rar</include>
<include>org.jboss.teiid.connectors:translator-ldap</include>
- <include>org.jboss.teiid.connectors:connector-ldap:rar</include>
<include>org.jboss.teiid.connectors:translator-salesforce</include>
- <include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
- <include>org.jboss.teiid.connectors:connector-ws:rar</include>
<include>org.jboss.teiid.connectors:translator-ws</include>
</includes>
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-07-14 01:59:05 UTC (rev 2340)
@@ -41,7 +41,7 @@
<parameter class="java.lang.String">connector-ldap</parameter>
<parameter class="java.lang.String">LDAP Connection</parameter>
</constructor>
- <property name="rarName">connector-ldap-${project.version}.rar</property>
+ <property name="rarName">teiid-connector-ldap.rar</property>
</bean>
<bean name="connector-salesforce-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
@@ -56,7 +56,7 @@
<parameter class="java.lang.String">connector-salesforce</parameter>
<parameter class="java.lang.String">Salesforce Connection</parameter>
</constructor>
- <property name="rarName">connector-salesforce-${project.version}.rar</property>
+ <property name="rarName">teiid-connector-salesforce.rar</property>
</bean>
<bean name="connector-file-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
@@ -71,7 +71,7 @@
<parameter class="java.lang.String">connector-file</parameter>
<parameter class="java.lang.String">File Connection</parameter>
</constructor>
- <property name="rarName">connector-file-${project.version}.rar</property>
+ <property name="rarName">teiid-connector-file.rar</property>
</bean>
<bean name="connector-ws-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
@@ -86,7 +86,7 @@
<parameter class="java.lang.String">connector-ws</parameter>
<parameter class="java.lang.String">WS Connection</parameter>
</constructor>
- <property name="rarName">connector-ws-${project.version}.rar</property>
+ <property name="rarName">teiid-connector-ws.rar</property>
</bean>
</deployment>
Modified: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/marketdata-file-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/marketdata-file-ds.xml 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/marketdata-file-ds.xml 2010-07-14 01:59:05 UTC (rev 2340)
@@ -4,7 +4,7 @@
<no-tx-connection-factory>
<jndi-name>marketdata-file</jndi-name>
- <rar-name>connector-file-${project.version}.rar</rar-name>
+ <rar-name>teiid-connector-file.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
<!--
All the available properties for this connector are defined inside the "ra.xml" defined inside the rar
Modified: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/weather-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/weather-ds.xml 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/weather-ds.xml 2010-07-14 01:59:05 UTC (rev 2340)
@@ -4,7 +4,7 @@
<no-tx-connection-factory>
<jndi-name>WeatherDS</jndi-name>
- <rar-name>connector-ws-${project.version}.rar</rar-name>
+ <rar-name>teiid-connector-ws.rar</rar-name>
<connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
<config-property name="EndPoint">http://www.weather.gov/forecasts/xml/sample_products/browser_interface/nd...</config-property>
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-14 01:59:05 UTC (rev 2340)
@@ -66,6 +66,10 @@
<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.
+<h4>from 7.0</h4>
+<ul>
+ <li>Rar file names no longer contain version numbers. -ds.xml files should be updated from connector-XXX-version.rar to teiid-connector-XXX.rar
+<ul>
<h4>from 6.2</h4>
<ul>
@@ -76,7 +80,7 @@
<h2><a name="Other">Other Issues</a></h2>
<ul>
- <li>For compatability with the 7.0 release if a stored procedure parameter list begins with identifier=, then it will be parsed as a named parameter invocation even if the intent was to use a comparison predicate
+ <li>For compatibility with the 7.0 release if a stored procedure parameter list begins with identifier=, then it will be parsed as a named parameter invocation even if the intent was to use a comparison predicate
as the first parameter value. The workaround is to use nesting parens, e.g. call proc((identifier=value), ...), which clarifies that this is positional value. This workaround will not be needed in later releases.
</ul>
<h4>from 7.0</h4>
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2010-07-13 21:10:14 UTC (rev 2339)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2010-07-14 01:59:05 UTC (rev 2340)
@@ -33,6 +33,7 @@
public class VDBStatusChecker {
+ private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
private VDBRepository vdbRepository;
private ConnectorManagerRepository connectorManagerRepository;
@@ -45,10 +46,16 @@
}
public void dataSourceAdded(String dataSourceName) {
+ if (dataSourceName.startsWith(JAVA_CONTEXT)) {
+ dataSourceName = dataSourceName.substring(5);
+ }
resourceAdded(dataSourceName, false);
}
public void dataSourceRemoved(String dataSourceName) {
+ if (dataSourceName.startsWith(JAVA_CONTEXT)) {
+ dataSourceName = dataSourceName.substring(5);
+ }
resourceremoved(dataSourceName, false);
}
@@ -129,12 +136,19 @@
private String getSourceName(String translatorName, ModelMetaData model, boolean translator) {
for (String sourceName:model.getSourceNames()) {
- if (translator && translatorName.equals(model.getSourceTranslatorName(sourceName))) {
- return sourceName;
+ if (translator) {
+ if (translatorName.equals(model.getSourceTranslatorName(sourceName))) {
+ return sourceName;
+ }
+ } else {
+ String jndiName = model.getSourceConnectionJndiName(sourceName);
+ if (jndiName.startsWith(JAVA_CONTEXT)) {
+ jndiName = jndiName.substring(5);
+ }
+ if (translatorName.equals(jndiName)) {
+ return sourceName;
+ }
}
- else if (translatorName.equals(model.getSourceConnectionJndiName(sourceName))) {
- return sourceName;
- }
}
return null;
}
14 years, 5 months
teiid SVN: r2339 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 17:10:14 -0400 (Tue, 13 Jul 2010)
New Revision: 2339
Modified:
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected
Log:
TEIID-1149 fix to ensure system datatypes are used and to not omit columns without a datatype.
Modified: trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-13 21:10:14 UTC (rev 2339)
@@ -11,6 +11,7 @@
<bean name="JBossLifeCycleListener" class="org.teiid.jboss.JBossLifeCycleListener"/>
<bean name="VDBParserDeployer" class="org.teiid.deployers.VDBParserDeployer">
+ <property name="vdbRepository"><inject bean="VDBRepository"/></property>
<property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
<property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
</bean>
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-07-13 18:07:49 UTC (rev 2338)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -186,12 +186,14 @@
for (Schema schema : getVisibleSchemas(vdb, metadata)) {
for (Procedure proc : schema.getProcedures().values()) {
for (ProcedureParameter param : proc.getParameters()) {
- rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(),
+ Datatype dt = param.getDatatype();
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(), param.getType().toString(), param.isOptional(),
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID(), param.getAnnotation()));
}
if (proc.getResultSet() != null) {
for (Column param : proc.getResultSet().getColumns()) {
- rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), "ResultSet", false, //$NON-NLS-1$
+ Datatype dt = param.getDatatype();
+ rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(), "ResultSet", false, //$NON-NLS-1$
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID(), param.getAnnotation()));
}
}
@@ -233,13 +235,11 @@
break;
case COLUMNS:
for (Column column : table.getColumns()) {
- if (column.getDatatype() == null) {
- continue; //some mapping classes don't set the datatype
- }
+ Datatype dt = column.getDatatype();
rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), column.getName(), column.getPosition(), column.getNameInSource(),
- column.getDatatype().getRuntimeTypeName(), column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
+ dt!=null?dt.getRuntimeTypeName():null, column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncremented(), column.getNullType().toString(), column.getMinimumValue(),
- column.getMaximumValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(),
+ column.getMaximumValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), dt!=null?dt.getJavaClassName():null, column.getPrecision(),
column.getCharOctetLength(), column.getRadix(), column.getUUID(), column.getAnnotation()));
}
break;
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -112,7 +112,7 @@
addEntriesPlusVisibilities(vdb, new VDBMetaData());
}
- public MetadataStore getMetadataStore() throws IOException {
+ public MetadataStore getMetadataStore(Collection<Datatype> systemDatatypes) throws IOException {
if (this.store == null) {
this.store = new MetadataStore();
ArrayList<Index> tmp = new ArrayList<Index>();
@@ -124,7 +124,12 @@
this.indexes = tmp.toArray(new Index[tmp.size()]);
getAnnotationCache();
getExtensionCache();
- getDatatypeCache();
+ Map<String, Datatype> datatypes = getDatatypeCache();
+ if (systemDatatypes != null) {
+ for (Datatype datatype : systemDatatypes) {
+ datatypes.put(datatype.getUUID(), datatype);
+ }
+ }
List<KeyRecord> keys = findMetadataRecords(MetadataConstants.RECORD_TYPE.PRIMARY_KEY, null, false);
for (KeyRecord keyRecord : keys) {
this.primaryKeyCache.put(keyRecord.getUUID(), keyRecord);
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -28,6 +28,7 @@
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
@SuppressWarnings("nls")
@@ -39,6 +40,10 @@
assertEquals(1, names.size());
names = tm.getGroupsForPartialName("PARTS");
assertEquals(1, names.size());
+
+ //ensure that datatypes are set
+ Table t = (Table)tm.getGroupID(names.iterator().next());
+ assertNotNull(t.getColumns().get(0).getDatatype());
}
}
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -49,6 +49,7 @@
public class VDBMetadataFactory {
public static LRUCache<URL, TransformationMetadata> VDB_CACHE = new LRUCache<URL, TransformationMetadata>(10);
+ private static MetadataStore system;
public static TransformationMetadata getVDBMetadata(String vdbFile) {
try {
@@ -58,10 +59,12 @@
}
}
- public static MetadataStore getSystemVDBMetadataStore() {
+ public static MetadataStore getSystem() {
try {
- IndexMetadataFactory imf = loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB));
- return imf.getMetadataStore();
+ if (system == null) {
+ system = loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB)).getMetadataStore(null);
+ }
+ return system;
} catch (Exception e) {
throw new TeiidRuntimeException("System VDB not found");
}
@@ -80,8 +83,8 @@
if (udfFile != null) {
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
}
- MetadataStore system = loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB)).getMetadataStore();
- vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(system, imf.getMetadataStore())), imf.getEntriesPlusVisibilities(), methods);
+
+ vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(getSystem(), imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(), methods);
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (URISyntaxException e) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -42,11 +42,11 @@
if (url == null) {
throw new TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found")); //$NON-NLS-1$
}
- this.vdbRepository.setSystemStore(new IndexMetadataFactory(url).getMetadataStore());
+ this.vdbRepository.setSystemStore(new IndexMetadataFactory(url).getMetadataStore(null));
} catch (URISyntaxException e) {
- throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("system_vdb_load_error")); //$NON-NLS-1$
} catch (IOException e) {
- throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("system_vdb_load_error")); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -61,6 +61,7 @@
*/
public class VDBParserDeployer extends BaseMultipleVFSParsingDeployer<VDBMetaData> implements ManagedObjectCreator {
private ObjectSerializer serializer;
+ private VDBRepository vdbRepository;
public VDBParserDeployer() {
super(VDBMetaData.class, getCustomMappings(), IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT, IndexMetadataFactory.class, VdbConstants.MODEL_EXT, UDFMetaData.class);
@@ -146,7 +147,7 @@
MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile, MetadataStoreGroup.class);
if (stores == null) {
stores = new MetadataStoreGroup();
- stores.addStore(imf.getMetadataStore());
+ stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
}
unit.addAttachment(MetadataStoreGroup.class, stores);
}
@@ -179,8 +180,12 @@
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
return vdb;
- }
+ }
+ public void setVdbRepository(VDBRepository vdbRepository) {
+ this.vdbRepository = vdbRepository;
+ }
+
public void setObjectSerializer(ObjectSerializer serializer) {
this.serializer = serializer;
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -109,6 +109,10 @@
throw new VirtualDatabaseException(RuntimePlugin.Util.getString("VDBService.VDB_does_not_exist._2", vdbName, latestVersion)); //$NON-NLS-1$
}
+ public MetadataStore getSystemStore() {
+ return systemStore;
+ }
+
public void setSystemStore(MetadataStore store) {
this.systemStore = store;
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -161,8 +161,8 @@
0,
CONNECTOR_METADATA_UTILITY,
"http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#timestamp", //$NON-NLS-1$
- "http://www.w3.org/2001/XMLSchema#dateTime", //$NON-NLS-1$
- "http://www.w3.org/2001/XMLSchema#dateTime"); //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string", //$NON-NLS-1$
+ "http://www.w3.org/2001/XMLSchema#string"); //$NON-NLS-1$
checkParameter((Argument)params.get(3),
"inOptional", //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -52,21 +52,17 @@
import org.teiid.transport.LocalServerConnection;
import org.teiid.transport.LogonImpl;
-
+@SuppressWarnings("nls")
public class FakeServer extends ClientServiceRegistryImpl {
SessionServiceImpl sessionService = new SessionServiceImpl();
LogonImpl logon;
DQPCore dqp = new DQPCore();
VDBRepository repo = new VDBRepository();
- MetadataStore systemStore;
public FakeServer() {
this.logon = new LogonImpl(sessionService, null);
-
- systemStore = VDBMetadataFactory.getSystemVDBMetadataStore();
- this.repo.setSystemStore(systemStore);
-
+ this.repo.setSystemStore(VDBMetadataFactory.getSystem());
this.sessionService.setVDBRepository(repo);
this.dqp.setBufferService(new FakeBufferService());
this.dqp.setTransactionService(new FakeTransactionService());
@@ -90,13 +86,13 @@
public void deployVDB(String vdbName, String vdbPath) throws Exception {
IndexMetadataFactory imf = VDBMetadataFactory.loadMetadata(new File(vdbPath).toURI().toURL());
- MetadataStore metadata = imf.getMetadataStore();
+ MetadataStore metadata = imf.getMetadataStore(repo.getSystemStore().getDatatypes());
VDBMetaData vdbMetaData = new VDBMetaData();
vdbMetaData.setName(vdbName);
vdbMetaData.setStatus(VDB.Status.ACTIVE);
- for (Schema schema : systemStore.getSchemas().values()) {
+ for (Schema schema : repo.getSystemStore().getSchemas().values()) {
ModelMetaData model = new ModelMetaData();
model.setName(schema.getName());
vdbMetaData.addModel(model);
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-07-13 21:10:14 UTC (rev 2339)
@@ -26,8 +26,8 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer;
@@ -45,14 +45,14 @@
static final String VDB = "PartsSupplier";
- @Before public void setUp() throws Exception {
+ @BeforeClass public static void setUp() throws Exception {
FakeServer server = new FakeServer();
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
connection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
dbMetadata = connection.getMetaData();
}
- @After public void tearDown() throws SQLException {
+ @AfterClass public static void tearDown() throws SQLException {
connection.close();
}
Modified: trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected 2010-07-13 18:07:49 UTC (rev 2338)
+++ trunk/test-integration/common/src/test/resources/TestMMDatabaseMetaData/testGetColumns.expected 2010-07-13 21:10:14 UTC (rev 2339)
@@ -35,6 +35,7 @@
QT_Ora9DS XQTDoc BQTDocTestDocument.MappingClasses.SingleRow ShortValue 5 short 5 <null> 0 0 1 <null> <null> <null> <null> 0 14 NO <null> <null> <null> !
<null> NO
QT_Ora9DS XQTDoc BQTDocTestDocument.MappingClasses.SingleRow BigIntegerValue 2 biginteger 19 <null> 0 0 1 <null> <null> <null> <null> 0 15 NO <null> <null> <null> !
<null> NO
QT_Ora9DS XQTDoc BQTDocTestDocument.MappingClasses.SingleRow BigDecimalValue 2 bigdecimal 20 <null> 0 0 1 <null> <null> <null> <null> 0 16 NO <null> <null> <null> !
<null> NO
+QT_Ora9DS XQTDoc BQTDocTestDocument.MappingClasses.SingleRow ObjectValue <null> <null> <null> <null> 0 0 1 <null> <null> <null> <null> 0 17 NO <null> <null> <null> !
<null> NO
QT_Ora9DS VQT Base.Agg1 StringNum 12 string 10 <null> 0 10 1 <null> <null> <null> <null> 10 1 NO <null> <null> <null> !
<null> NO
QT_Ora9DS VQT Base.Agg2 StringNum 12 string 10 <null> 0 10 1 <null> <null> <null> <null> 10 1 NO <null> <null> <null> !
<null> NO
QT_Ora9DS VQT Base.Agg3 count 4 integer 10 <null> 0 10 0 <null> <null> <null> <null> 1 1 YES <null> <null> <null> !
<null> NO
@@ -972,7 +973,7 @@
QT_Ora9DS XQT xqtFullData BigIntegerValue 2 biginteger 19 <null> 0 10 1 <null> <null> <null> <null> 28 15 NO <null> <null> <null> !
<null> NO
QT_Ora9DS XQT xqtFullData BigDecimalValue 2 bigdecimal 20 <null> 0 10 1 <null> <null> <null> <null> 126 16 NO <null> <null> <null> !
<null> NO
QT_Ora9DS XQT xqtFullData ObjectValue 2000 object 2048 <null> 0 10 1 <null> <null> <null> <null> 2048 17 NO <null> <null> <null> !
<null> NO
-Row Count : 972
+Row Count : 973
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
TABLE_CAT 12 QT_Ora9DS java.lang.String TABLE_CAT string SYS Columns 255 255 0 false false false false 0 true true false false
TABLE_SCHEM 12 QT_Ora9DS java.lang.String TABLE_SCHEM string SYS Columns 255 255 0 false true false true 1 false true true true
14 years, 5 months
teiid SVN: r2338 - in trunk: build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather and 17 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 14:07:49 -0400 (Tue, 13 Jul 2010)
New Revision: 2338
Added:
trunk/engine/src/main/java/org/teiid/query/sql/lang/ExpressionCriteria.java
Modified:
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/README.txt
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.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/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
Log:
TEIID-1050 TEIID-1055 adding the ability to support criteria as expressions. also adding alternative stored procedure syntax to remove its ambiguity with comparison criteria. minor tweaks to validity checks for generating update procedures and group by expressions
Modified: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/README.txt
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/README.txt 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-ws-weather/README.txt 2010-07-13 18:07:49 UTC (rev 2338)
@@ -26,8 +26,8 @@
to HTTP, which is the proper setting for REST.
select t.* from
- (call weather.invoke(action='GET',
- endpoint=querystring('', '38.99,-77.02 39.70,-104.80 47.6,-122.30' as listLatLon,
+ (call weather.invoke(action=>'GET',
+ endpoint=>querystring('', '38.99,-77.02 39.70,-104.80 47.6,-122.30' as listLatLon,
'time-series' as product, '2004-01-01T00:00:00' as "begin",
'2013-04-20T00:00:00' as "end", 'maxt' as maxt, 'mint' as mint)
)) w,
@@ -41,10 +41,10 @@
on the datasource.
select xmlserialize(document w.result as string) from
- (call weather.invoke(action='http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonList...',
- endpoint='http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php',
- binding='SOAP11',
- request='
+ (call weather.invoke(action=>'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonList...',
+ endpoint=>'http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php',
+ binding=>'SOAP11',
+ request=>'
<ns1:LatLonListZipCode xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl">
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 18:07:49 UTC (rev 2338)
@@ -26,11 +26,21 @@
</UL>
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
- <LI><B>SQL Support</B> - added NULLS FIST/LAST handling - including pushdown support and enhanced numeric stat aggregate functions STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP. Added support for the boolean aggregate functions ANY, SOME, EVERY.
+ <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.
+ </ul>
<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.
</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 6.2</h4>
<ul>
<li>The connector API has changed substantially. Custom connectors need to be retargeted to the new Translator API. See <a href="https://jira.jboss.org/browse/TEIID-1003">TEIID-1003</a> and the <a href="teiid-docs/teiid_developers_guide.pdf">Developer's Guide</a> for more information.
@@ -65,6 +75,10 @@
</ul>
<h2><a name="Other">Other Issues</a></h2>
+<ul>
+ <li>For compatability with the 7.0 release if a stored procedure parameter list begins with identifier=, then it will be parsed as a named parameter invocation even if the intent was to use a comparison predicate
+ as the first parameter value. The workaround is to use nesting parens, e.g. call proc((identifier=value), ...), which clarifies that this is positional value. This workaround will not be needed in later releases.
+</ul>
<h4>from 7.0</h4>
<ul>
<li>Fixed xsd type handling for SQL/XML and XML document models. xsd:date, xsd:dateTime, and xsd:time types will now all be displayed using the GMT timezone (Z). SQL types, such as timestamp, used for an XMLTABLE column will now expect their values to be in the form of the corresponding xsd type.
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2010-07-13 18:07:49 UTC (rev 2338)
@@ -511,7 +511,7 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod38" xreflabel="executeNamedParams"/>executeNamedParams</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod2">id</link> <EQ> <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> <link linkend="prod16">expression</link> )* )</para></entry></row>
+( <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod2">id</link> <EQ> ( <GT> )? <link linkend="prod16">expression</link> )* )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod9" xreflabel="insert"/>insert</para></entry>
<entry align="left" valign="top"><para>::=
@@ -667,57 +667,53 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod78" xreflabel="booleanPrimary"/>booleanPrimary</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod79">predicate</link> | ( <LPAREN> <link linkend="prod28">criteria</link> <RPAREN> ) )</para></entry></row>
+( <link linkend="prod34">translateCriteria</link> | ( <link linkend="prod79">commonValueExpression</link> ( ( <link linkend="prod80">betweenCrit</link> | <link linkend="prod81">matchCrit</link> | <link linkend="prod82">setCrit</link> | <link linkend="prod83">isNullCrit</link> | <link linkend="prod84">subqueryCompareCriteria</link> | <link linkend="prod85">compareCrit</link> ) )? ) | <link linkend="prod86">existsCriteria</link> | <link linkend="prod30">hasCriteria</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod79" xreflabel="predicate"/>predicate</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod87" xreflabel="operator"/>operator</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod34">translateCriteria</link> | ( <link linkend="prod80">commonValueExpression</link> ( <link linkend="prod81">betweenCrit</link> | <link linkend="prod82">matchCrit</link> | <link linkend="prod83">setCrit</link> | <link linkend="prod84">isNullCrit</link> | <link linkend="prod85">compareCrit</link> | <link linkend="prod86">subqueryCompareCriteria</link> ) ) | <link linkend="prod87">existsCriteria</link> | <link linkend="prod30">hasCriteria</link> )</para></entry></row>
-<row>
-<entry align="right" valign="top"><para><anchor id="prod88" xreflabel="operator"/>operator</para></entry>
-<entry align="left" valign="top"><para>::=
( <EQ> | <NE> | <NE2> | <LT> | <LE> | <GT> | <GE> )</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod85" xreflabel="compareCrit"/>compareCrit</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod88">operator</link> <link linkend="prod80">commonValueExpression</link></para></entry></row>
+<link linkend="prod87">operator</link> <link linkend="prod79">commonValueExpression</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod89" xreflabel="subquery"/>subquery</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod88" xreflabel="subquery"/>subquery</para></entry>
<entry align="left" valign="top"><para>::=
<LPAREN> ( <link linkend="prod7">queryExpression</link> | <link linkend="prod8">storedProcedure</link> ) <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod86" xreflabel="subqueryCompareCriteria"/>subqueryCompareCriteria</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod84" xreflabel="subqueryCompareCriteria"/>subqueryCompareCriteria</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod88">operator</link> ( <ANY> | <SOME> | <ALL> ) <link linkend="prod89">subquery</link></para></entry></row>
+<link linkend="prod87">operator</link> ( <ANY> | <SOME> | <ALL> ) <link linkend="prod88">subquery</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod82" xreflabel="matchCrit"/>matchCrit</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod81" xreflabel="matchCrit"/>matchCrit</para></entry>
<entry align="left" valign="top"><para>::=
-( <NOT> )? <LIKE> <link linkend="prod80">commonValueExpression</link> ( <ESCAPE> <link linkend="prod70">charVal</link> | ( <LBRACE> <ESCAPE> <link linkend="prod70">charVal</link> <RBRACE> ) )?</para></entry></row>
+( <NOT> )? <LIKE> <link linkend="prod79">commonValueExpression</link> ( <ESCAPE> <link linkend="prod70">charVal</link> | ( <LBRACE> <ESCAPE> <link linkend="prod70">charVal</link> <RBRACE> ) )?</para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod70" xreflabel="charVal"/>charVal</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod1">stringVal</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod81" xreflabel="betweenCrit"/>betweenCrit</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod80" xreflabel="betweenCrit"/>betweenCrit</para></entry>
<entry align="left" valign="top"><para>::=
-( <NOT> )? <BETWEEN> <link linkend="prod80">commonValueExpression</link> <AND> <link linkend="prod80">commonValueExpression</link></para></entry></row>
+( <NOT> )? <BETWEEN> <link linkend="prod79">commonValueExpression</link> <AND> <link linkend="prod79">commonValueExpression</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod84" xreflabel="isNullCrit"/>isNullCrit</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod83" xreflabel="isNullCrit"/>isNullCrit</para></entry>
<entry align="left" valign="top"><para>::=
<IS> ( <NOT> )? <NULL></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod83" xreflabel="setCrit"/>setCrit</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod82" xreflabel="setCrit"/>setCrit</para></entry>
<entry align="left" valign="top"><para>::=
-( <NOT> )? <IN> ( ( <link linkend="prod89">subquery</link> ) | ( <LPAREN> <link linkend="prod80">commonValueExpression</link> ( <COMMA> <link linkend="prod80">commonValueExpression</link> )* <RPAREN> ) )</para></entry></row>
+( <NOT> )? <IN> ( ( <link linkend="prod88">subquery</link> ) | ( <LPAREN> <link linkend="prod79">commonValueExpression</link> ( <COMMA> <link linkend="prod79">commonValueExpression</link> )* <RPAREN> ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod87" xreflabel="existsCriteria"/>existsCriteria</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod86" xreflabel="existsCriteria"/>existsCriteria</para></entry>
<entry align="left" valign="top"><para>::=
-<EXISTS> <link linkend="prod89">subquery</link></para></entry></row>
+<EXISTS> <link linkend="prod88">subquery</link></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod50" xreflabel="groupBy"/>groupBy</para></entry>
<entry align="left" valign="top"><para>::=
-<GROUP> <BY> ( <link linkend="prod90">groupByItem</link> ( <COMMA> <link linkend="prod90">groupByItem</link> )* )</para></entry></row>
+<GROUP> <BY> ( <link linkend="prod89">groupByItem</link> ( <COMMA> <link linkend="prod89">groupByItem</link> )* )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod90" xreflabel="groupByItem"/>groupByItem</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod89" xreflabel="groupByItem"/>groupByItem</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod16">expression</link></para></entry></row>
<row>
@@ -727,13 +723,13 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod43" xreflabel="orderby"/>orderby</para></entry>
<entry align="left" valign="top"><para>::=
-<ORDER> <BY> <link linkend="prod91">sortSpecification</link> ( <COMMA> <link linkend="prod91">sortSpecification</link> )*</para></entry></row>
+<ORDER> <BY> <link linkend="prod90">sortSpecification</link> ( <COMMA> <link linkend="prod90">sortSpecification</link> )*</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod91" xreflabel="sortSpecification"/>sortSpecification</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod90" xreflabel="sortSpecification"/>sortSpecification</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod92">sortKey</link> ( <ASC> | <DESC> )? ( <link linkend="prod58">nonReserved</link> <link linkend="prod58">nonReserved</link> )?</para></entry></row>
+<link linkend="prod91">sortKey</link> ( <ASC> | <DESC> )? ( <link linkend="prod58">nonReserved</link> <link linkend="prod58">nonReserved</link> )?</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod92" xreflabel="sortKey"/>sortKey</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod91" xreflabel="sortKey"/>sortKey</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod16">expression</link></para></entry></row>
<row>
@@ -747,73 +743,73 @@
<row>
<entry align="right" valign="top"><para><anchor id="prod16" xreflabel="expression"/>expression</para></entry>
<entry align="left" valign="top"><para>::=
-<link linkend="prod80">commonValueExpression</link></para></entry></row>
+<link linkend="prod28">criteria</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod80" xreflabel="commonValueExpression"/>commonValueExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod79" xreflabel="commonValueExpression"/>commonValueExpression</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod93">plusExpression</link> ( <CONCAT_OP> <link linkend="prod93">plusExpression</link> )* )</para></entry></row>
+( <link linkend="prod92">plusExpression</link> ( <CONCAT_OP> <link linkend="prod92">plusExpression</link> )* )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod93" xreflabel="plusExpression"/>plusExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod92" xreflabel="plusExpression"/>plusExpression</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod94">timesExpression</link> ( <link linkend="prod95">plusOperator</link> <link linkend="prod94">timesExpression</link> )* )</para></entry></row>
+( <link linkend="prod93">timesExpression</link> ( <link linkend="prod94">plusOperator</link> <link linkend="prod93">timesExpression</link> )* )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod95" xreflabel="plusOperator"/>plusOperator</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod94" xreflabel="plusOperator"/>plusOperator</para></entry>
<entry align="left" valign="top"><para>::=
( <PLUS> | <MINUS> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod94" xreflabel="timesExpression"/>timesExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod93" xreflabel="timesExpression"/>timesExpression</para></entry>
<entry align="left" valign="top"><para>::=
-( <link linkend="prod96">valueExpressionPrimary</link> ( <link linkend="prod97">timesOperator</link> <link linkend="prod96">valueExpressionPrimary</link> )* )</para></entry></row>
+( <link linkend="prod95">valueExpressionPrimary</link> ( <link linkend="prod96">timesOperator</link> <link linkend="prod95">valueExpressionPrimary</link> )* )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod97" xreflabel="timesOperator"/>timesOperator</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod96" xreflabel="timesOperator"/>timesOperator</para></entry>
<entry align="left" valign="top"><para>::=
( <STAR> | <SLASH> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod96" xreflabel="valueExpressionPrimary"/>valueExpressionPrimary</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod95" xreflabel="valueExpressionPrimary"/>valueExpressionPrimary</para></entry>
<entry align="left" valign="top"><para>::=
-( <QMARK> | <link linkend="prod98">literal</link> | ( <LBRACE> <link linkend="prod58">nonReserved</link> <link linkend="prod99">function</link> <RBRACE> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod56">xmlAgg</link> ) | ( <link linkend="prod99">function</link> ) | ( <ID> ) | ( <LPAREN> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod89">subquery</link> | <link linkend="prod100">searchedCaseExpression</link> | <link linkend="prod101">caseExpression</link> )</para></entry></row>
+( <QMARK> | <link linkend="prod97">literal</link> | ( <LBRACE> <link linkend="prod58">nonReserved</link> <link linkend="prod98">function</link> <RBRACE> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod57">aggregateSymbol</link> ) | ( <link linkend="prod56">xmlAgg</link> ) | ( <link linkend="prod98">function</link> ) | ( <ID> ) | <link linkend="prod88">subquery</link> | ( <LPAREN> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod99">searchedCaseExpression</link> | <link linkend="prod100">caseExpression</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod101" xreflabel="caseExpression"/>caseExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod100" xreflabel="caseExpression"/>caseExpression</para></entry>
<entry align="left" valign="top"><para>::=
<CASE> <link linkend="prod16">expression</link> ( <WHEN> <link linkend="prod16">expression</link> <THEN> <link linkend="prod16">expression</link> )+ ( <ELSE> <link linkend="prod16">expression</link> )? <END></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod100" xreflabel="searchedCaseExpression"/>searchedCaseExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod99" xreflabel="searchedCaseExpression"/>searchedCaseExpression</para></entry>
<entry align="left" valign="top"><para>::=
<CASE> ( <WHEN> <link linkend="prod28">criteria</link> <THEN> <link linkend="prod16">expression</link> )+ ( <ELSE> <link linkend="prod16">expression</link> )? <END></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod99" xreflabel="function"/>function</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod98" xreflabel="function"/>function</para></entry>
<entry align="left" valign="top"><para>::=
-( ( <CONVERT> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <CAST> <LPAREN> <link linkend="prod16">expression</link> <AS> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod102">stringConstant</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod103">intervalType</link> <COMMA> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod104">queryString</link> | ( ( <LEFT> | <RIGHT> | <CHAR> | <USER> | <YEAR> | <MONTH> | <HOUR> | <MINUTE> | <SECOND> | <XMLCONCAT> | <XMLCOMMENT> ) <LPAREN> ( <link linkend="prod16">expression</link> !
( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <INSERT> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <TRANSLATE> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | <link linkend="prod105">xmlParse</link> | <link linkend="prod106">xmlElement</link> | ( <XMLPI> <LPAREN> ( <ID> <link linkend="prod107">idExpression</link> | <link linkend="prod107">idExpression</link> ) ( <COMMA> <link linkend="prod16">expression</link> )? <RPAREN> ) | <link linkend="prod108">xmlForest</link> | <link linkend="prod68">xmlSerialize</link> | <link linkend="prod72">xmlQuery</link> | ( <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )*!
)? <RPAREN> ) )</para></entry></row>
+( ( <CONVERT> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <CAST> <LPAREN> <link linkend="prod16">expression</link> <AS> <link linkend="prod31">dataType</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod101">stringConstant</link> <RPAREN> ) | ( <link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod102">intervalType</link> <COMMA> <link linkend="prod16">expression</link> <COMMA> <link linkend="prod16">expression</link> <RPAREN> ) | <link linkend="prod103">queryString</link> | ( ( <LEFT> | <RIGHT> | <CHAR> | <USER> | <YEAR> | <MONTH> | <HOUR> | <MINUTE> | <SECOND> | <XMLCONCAT> | <XMLCOMMENT> ) <LPAREN> ( <link linkend="prod16">expression</link> !
( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <INSERT> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | ( ( <TRANSLATE> ) <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )* )? <RPAREN> ) | <link linkend="prod104">xmlParse</link> | <link linkend="prod105">xmlElement</link> | ( <XMLPI> <LPAREN> ( <ID> <link linkend="prod106">idExpression</link> | <link linkend="prod106">idExpression</link> ) ( <COMMA> <link linkend="prod16">expression</link> )? <RPAREN> ) | <link linkend="prod107">xmlForest</link> | <link linkend="prod68">xmlSerialize</link> | <link linkend="prod72">xmlQuery</link> | ( <link linkend="prod2">id</link> <LPAREN> ( <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod16">expression</link> )*!
)? <RPAREN> ) )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod102" xreflabel="stringConstant"/>stringConstant</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod101" xreflabel="stringConstant"/>stringConstant</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod1">stringVal</link></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod105" xreflabel="xmlParse"/>xmlParse</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod104" xreflabel="xmlParse"/>xmlParse</para></entry>
<entry align="left" valign="top"><para>::=
<XMLPARSE> <LPAREN> <link linkend="prod58">nonReserved</link> <link linkend="prod16">expression</link> ( <link linkend="prod58">nonReserved</link> )? <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod104" xreflabel="queryString"/>queryString</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod103" xreflabel="queryString"/>queryString</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod58">nonReserved</link> <LPAREN> <link linkend="prod16">expression</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod106" xreflabel="xmlElement"/>xmlElement</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod105" xreflabel="xmlElement"/>xmlElement</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLELEMENT> <LPAREN> ( <ID> <link linkend="prod2">id</link> | <link linkend="prod2">id</link> ) ( <COMMA> <link linkend="prod73">xmlNamespaces</link> )? ( <COMMA> <link linkend="prod109">xmlAttributes</link> )? ( <COMMA> <link linkend="prod16">expression</link> )* <RPAREN></para></entry></row>
+<XMLELEMENT> <LPAREN> ( <ID> <link linkend="prod2">id</link> | <link linkend="prod2">id</link> ) ( <COMMA> <link linkend="prod73">xmlNamespaces</link> )? ( <COMMA> <link linkend="prod108">xmlAttributes</link> )? ( <COMMA> <link linkend="prod16">expression</link> )* <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod109" xreflabel="xmlAttributes"/>xmlAttributes</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod108" xreflabel="xmlAttributes"/>xmlAttributes</para></entry>
<entry align="left" valign="top"><para>::=
<XMLATTRIBUTES> <LPAREN> <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod108" xreflabel="xmlForest"/>xmlForest</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod107" xreflabel="xmlForest"/>xmlForest</para></entry>
<entry align="left" valign="top"><para>::=
<XMLFOREST> <LPAREN> ( <link linkend="prod73">xmlNamespaces</link> <COMMA> )? <link linkend="prod55">derivedColumn</link> ( <COMMA> <link linkend="prod55">derivedColumn</link> )* <RPAREN></para></entry></row>
<row>
<entry align="right" valign="top"><para><anchor id="prod73" xreflabel="xmlNamespaces"/>xmlNamespaces</para></entry>
<entry align="left" valign="top"><para>::=
-<XMLNAMESPACES> <LPAREN> <link linkend="prod110">namespaceItem</link> ( <COMMA> <link linkend="prod110">namespaceItem</link> )* <RPAREN></para></entry></row>
+<XMLNAMESPACES> <LPAREN> <link linkend="prod109">namespaceItem</link> ( <COMMA> <link linkend="prod109">namespaceItem</link> )* <RPAREN></para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod110" xreflabel="namespaceItem"/>namespaceItem</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod109" xreflabel="namespaceItem"/>namespaceItem</para></entry>
<entry align="left" valign="top"><para>::=
( <link linkend="prod1">stringVal</link> <AS> <link linkend="prod2">id</link> )</para></entry></row>
<row>
@@ -825,7 +821,7 @@
<entry align="left" valign="top"><para>::=
( <DEFAULT_KEYWORD> <link linkend="prod1">stringVal</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod107" xreflabel="idExpression"/>idExpression</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod106" xreflabel="idExpression"/>idExpression</para></entry>
<entry align="left" valign="top"><para>::=
<link linkend="prod2">id</link></para></entry></row>
<row>
@@ -833,11 +829,11 @@
<entry align="left" valign="top"><para>::=
( <STRING> | <VARCHAR> | <BOOLEAN> | <BYTE> | <TINYINT> | <SHORT> | <SMALLINT> | <CHAR> | <INTEGER> | <LONG> | <BIGINT> | <BIGINTEGER> | <FLOAT> | <REAL> | <DOUBLE> | <BIGDECIMAL> | <DECIMAL> | <DATE> | <TIME> | <TIMESTAMP> | <OBJECT> | <BLOB> | <CLOB> | <XML> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod103" xreflabel="intervalType"/>intervalType</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod102" xreflabel="intervalType"/>intervalType</para></entry>
<entry align="left" valign="top"><para>::=
( <link linkend="prod58">nonReserved</link> )</para></entry></row>
<row>
-<entry align="right" valign="top"><para><anchor id="prod98" xreflabel="literal"/>literal</para></entry>
+<entry align="right" valign="top"><para><anchor id="prod97" xreflabel="literal"/>literal</para></entry>
<entry align="left" valign="top"><para>::=
( <link linkend="prod1">stringVal</link> | <INTEGERVAL> | <FLOATVAL> | <FALSE> | <TRUE> | <UNKNOWN> | <NULL> | ( ( <BOOLEANTYPE> | <TIMESTAMPTYPE> | <DATETYPE> | <TIMETYPE> ) <link linkend="prod1">stringVal</link> <RBRACE> ) )</para></entry></row>
</tbody>
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-07-13 17:56:20 UTC (rev 2337)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-07-13 18:07:49 UTC (rev 2338)
@@ -311,16 +311,20 @@
<sect1 id="criteria">
<title>Criteria</title>
<itemizedlist>
- <para>Criteria are of two basic forms:
+ <para>Criteria may be:
</para>
<listitem>
<para>Predicates that evaluate to true or false
</para>
</listitem>
<listitem>
- <para>Logical criteria that combine predicates (AND, OR, NOT)
+ <para>Logical criteria that combines criteria (AND, OR, NOT)
</para>
</listitem>
+ <listitem>
+ <para>A value expression with type boolean
+ </para>
+ </listitem>
</itemizedlist>
<itemizedlist>
<para>Syntax Rules:
@@ -358,6 +362,10 @@
</para>
</listitem>
<listitem>
+ <para>expression
+ </para>
+ </listitem>
+ <listitem>
<para>Criteria may be nested using parenthesis.
</para>
</listitem>
@@ -527,7 +535,7 @@
</para>
</listitem>
<listitem>
- <para>EXECUTE proc(name1=value1,name4=param4, ...) - named parameter syntax
+ <para>EXECUTE proc(name1=>value1,name4=>param4, ...) - named parameter syntax
</para>
</listitem>
</itemizedlist>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -449,6 +449,8 @@
return translate((SearchedCaseExpression)expr);
} else if (expr instanceof SingleElementSymbol) {
return translate((SingleElementSymbol)expr);
+ } else if (expr instanceof Criteria) {
+ return translate((Criteria)expr);
}
throw new AssertionError();
}
Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -77,6 +77,7 @@
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.DependentSetCriteria;
import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
import org.teiid.query.sql.lang.NotCriteria;
@@ -220,6 +221,8 @@
return evaluate((SubqueryCompareCriteria)criteria, tuple);
} else if(criteria instanceof ExistsCriteria) {
return Boolean.valueOf(evaluate((ExistsCriteria)criteria, tuple));
+ } else if (criteria instanceof ExpressionCriteria) {
+ return (Boolean)evaluate(((ExpressionCriteria)criteria).getExpression(), tuple);
} else {
throw new ExpressionEvaluationException(ErrorMessageKeys.PROCESSOR_0010, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0010, criteria));
}
@@ -643,6 +646,8 @@
return getContext(ref).getVariableContext().getGlobalValue(ref.getContextSymbol());
}
return internalEvaluate(ref.getExpression(), tuple);
+ } else if(expression instanceof Criteria) {
+ return evaluate((Criteria) expression, tuple);
} else if(expression instanceof ScalarSubquery) {
return evaluate((ScalarSubquery) expression, tuple);
} else if (expression instanceof Criteria) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -48,6 +48,7 @@
import org.teiid.query.sql.ProcedureReservedWords;
import org.teiid.query.sql.lang.BetweenCriteria;
import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.GroupContext;
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
@@ -362,6 +363,15 @@
handleException(new QueryResolverException(e, QueryPlugin.Util.getString("XMLQuery.resolvingError", obj))); //$NON-NLS-1$
}
}
+
+ @Override
+ public void visit(ExpressionCriteria obj) {
+ try {
+ obj.setExpression(ResolverUtil.convertExpression(obj.getExpression(), DataTypeManager.DefaultDataTypes.BOOLEAN, metadata));
+ } catch (QueryResolverException e) {
+ handleException(e);
+ }
+ }
public TeiidComponentException getComponentException() {
return this.componentException;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -80,6 +80,7 @@
import org.teiid.query.sql.lang.Delete;
import org.teiid.query.sql.lang.DependentSetCriteria;
import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.From;
import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.GroupBy;
@@ -1033,6 +1034,8 @@
rewriteSubqueryContainer((SubqueryContainer)criteria, true);
} else if (criteria instanceof DependentSetCriteria) {
criteria = rewriteDependentSetCriteria((DependentSetCriteria)criteria);
+ } else if (criteria instanceof ExpressionCriteria) {
+ return new CompareCriteria(((ExpressionCriteria) criteria).getExpression(), CompareCriteria.EQ, new Constant(Boolean.TRUE));
}
return evaluateCriteria(criteria);
@@ -1921,6 +1924,8 @@
} else {
expression = rewriteExpressionDirect(((ExpressionSymbol)expression).getExpression());
}
+ } else if (expression instanceof Criteria) {
+ expression = rewriteCriteria((Criteria)expression);
} else {
rewriteExpressions(expression);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -136,4 +136,5 @@
public void visit(XMLQuery obj) {}
public void visit(QueryString obj) {}
public void visit(XMLParse obj) {}
+ public void visit(ExpressionCriteria obj) {}
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -29,7 +29,8 @@
import java.util.LinkedList;
import java.util.List;
-import org.teiid.query.sql.LanguageObject;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -38,7 +39,7 @@
* constraints on the data values to be retrieved for each parameter in the
* select clause. <p>
*/
-public abstract class Criteria implements LanguageObject {
+public abstract class Criteria implements Expression {
/**
* Constructs a default instance of this class.
@@ -249,5 +250,15 @@
return new CompoundCriteria(!dnf?CompoundCriteria.AND:CompoundCriteria.OR, newCrits);
}
+
+ @Override
+ public Class getType() {
+ return DataTypeManager.DefaultDataClasses.BOOLEAN;
+ }
+
+ @Override
+ public boolean isResolved() {
+ return true;
+ }
} // END CLASS
Added: trunk/engine/src/main/java/org/teiid/query/sql/lang/ExpressionCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/ExpressionCriteria.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/ExpressionCriteria.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -0,0 +1,70 @@
+/*
+ * 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.sql.lang;
+
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.Expression;
+
+public class ExpressionCriteria extends Criteria {
+
+ private Expression expression;
+
+ public ExpressionCriteria(Expression expression) {
+ this.expression = expression;
+ }
+
+ public Object clone() {
+ return new ExpressionCriteria((Expression) expression.clone());
+ }
+
+ @Override
+ public void acceptVisitor(LanguageVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @Override
+ public int hashCode() {
+ return expression.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ExpressionCriteria)) {
+ return false;
+ }
+ ExpressionCriteria other = (ExpressionCriteria) obj;
+ return expression.equals(other.expression);
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/sql/lang/ExpressionCriteria.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -37,6 +37,7 @@
import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.From;
import org.teiid.query.sql.lang.GroupBy;
import org.teiid.query.sql.lang.Insert;
@@ -601,6 +602,13 @@
postVisitVisitor(obj);
}
+ @Override
+ public void visit(ExpressionCriteria obj) {
+ preVisitVisitor(obj);
+ visitNode(obj.getExpression());
+ postVisitVisitor(obj);
+ }
+
public static void doVisit(LanguageObject object, LanguageVisitor visitor, boolean order) {
PreOrPostOrderNavigator nav = new PreOrPostOrderNavigator(visitor, order);
object.acceptVisitor(nav);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -36,6 +36,7 @@
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.DependentSetCriteria;
import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.GroupBy;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.IsNullCriteria;
@@ -339,6 +340,11 @@
obj.setPath(replaceExpression(obj.getPath()));
}
+ @Override
+ public void visit(ExpressionCriteria obj) {
+ obj.setExpression(replaceExpression(obj.getExpression()));
+ }
+
/**
* The object is modified in place, so is not returned.
* @param obj Language object
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-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -50,6 +50,7 @@
import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.From;
import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.GroupBy;
@@ -989,7 +990,7 @@
if (obj.displayNamedParameters()) {
parts.add(escapeSinglePart(ElementSymbol.getShortName(param.getParameterSymbol().getOutputName())));
- parts.add(" = "); //$NON-NLS-1$
+ parts.add(" => "); //$NON-NLS-1$
}
if(param.getExpression() == null) {
@@ -999,7 +1000,14 @@
parts.add("?"); //$NON-NLS-1$
}
} else {
+ boolean addParens = !obj.displayNamedParameters() && param.getExpression() instanceof CompareCriteria;
+ if (addParens) {
+ parts.add(Tokens.LPAREN);
+ }
parts.add(registerNode(param.getExpression()));
+ if (addParens) {
+ parts.add(Tokens.RPAREN);
+ }
}
if(iter.hasNext()) {
parts.add(", "); //$NON-NLS-1$
@@ -1845,6 +1853,11 @@
}
parts.add(Tokens.RPAREN);
}
+
+ @Override
+ public void visit(ExpressionCriteria obj) {
+ obj.getExpression().acceptVisitor(this);
+ }
public static String escapeSinglePart(String part) {
if(isReservedWord(part)) {
Modified: trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -33,6 +33,7 @@
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.symbol.*;
+import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
import org.teiid.query.util.ErrorMessageKeys;
@@ -144,14 +145,11 @@
if(symbol instanceof AliasSymbol) {
symbol = ((AliasSymbol)symbol).getSymbol();
}
-
- if(symbol instanceof AggregateSymbol) {
+
+ Expression ex = SymbolMap.getExpression(symbol);
+
+ if (!(ex instanceof ElementSymbol || ex instanceof Constant)) {
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0007, symbol));
- } else if(symbol instanceof ExpressionSymbol) {
- Expression expr = ((ExpressionSymbol)symbol).getExpression();
- if(expr == null || expr instanceof Function) {
- handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0008, symbol));
- }
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -95,7 +95,6 @@
import org.teiid.query.sql.proc.IfStatement;
import org.teiid.query.sql.proc.TranslateCriteria;
import org.teiid.query.sql.proc.WhileStatement;
-import org.teiid.query.sql.symbol.AbstractCaseExpression;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.DerivedColumn;
@@ -197,8 +196,8 @@
if(symbol instanceof ExpressionSymbol) {
ExpressionSymbol exprSymbol = (ExpressionSymbol) symbol;
Expression expr = exprSymbol.getExpression();
- if(! (expr instanceof Function || expr instanceof AbstractCaseExpression)) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.Expr_in_GROUP_BY_must_be_elem_func_case", expr), expr); //$NON-NLS-1$
+ if (!ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr).isEmpty() || expr instanceof Constant || expr instanceof Reference) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.groupby_subquery", expr), expr); //$NON-NLS-1$
}
}
}
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-07-13 18:07:49 UTC (rev 2338)
@@ -1240,7 +1240,7 @@
storedProcedure.setDisplayNamedParameters(true);
}
(name=id()
- <EQ>
+ <EQ> [<GT>]
value = expression(info)
{
parameter = new SPParameter(parameterIndex++, value);
@@ -1251,7 +1251,7 @@
}
( <COMMA>
name=id()
- <EQ>
+ <EQ> [<GT>]
value = expression(info)
{
parameter = new SPParameter(parameterIndex++, value);
@@ -2344,56 +2344,43 @@
}
}
-/**
- * <p>Parses the basic atomic criteria - either a predicate criteria or
- * a criteria wrapped in ( ).</p>
- * @return Parsed primary criteria
+/**
+ * <p>Parse a boolean primary.</p>
+ * @return criteria
* @throws ParseException if parsing failed
*/
Criteria booleanPrimary(ParseInfo info) :
{
+ Expression ex = null;
Criteria crit = null;
}
{
- ( LOOKAHEAD(predicate(info)) crit = predicate(info) |
- (<LPAREN> crit=criteria(info) <RPAREN>)
- )
-
- {
- return crit;
- }
-}
-
-/**
- * <p>Parse a predicate criteria.</p>
- * @return Parsed predicate criteria
- * @throws ParseException if parsing failed
- */
-PredicateCriteria predicate(ParseInfo info) :
-{
- PredicateCriteria pdCrit = null;
- Expression ex = null;
-}
-{
(
- LOOKAHEAD(2) pdCrit = translateCriteria(info)
+ LOOKAHEAD(2) crit = translateCriteria(info)
|
(ex = commonValueExpression(info)
- (
- LOOKAHEAD(2) pdCrit=betweenCrit(info, ex) |
- LOOKAHEAD(2) pdCrit=matchCrit(info, ex) |
- pdCrit=setCrit(info, ex) |
- pdCrit = isNullCrit(info, ex) |
- LOOKAHEAD(operator() expression(info)) pdCrit=compareCrit(info, ex) |
- pdCrit=subqueryCompareCriteria(info, ex)
- )
+ {
+ if (ex instanceof Criteria) {
+ crit = (Criteria)ex;
+ } else {
+ crit = new ExpressionCriteria(ex);
+ }
+ }
+ [(
+ LOOKAHEAD(2) crit=betweenCrit(info, ex) |
+ LOOKAHEAD(2) crit=matchCrit(info, ex) |
+ crit=setCrit(info, ex) |
+ crit=isNullCrit(info, ex) |
+ LOOKAHEAD(operator() (<ANY>|<SOME>|<ALL>) subquery(info)) crit=subqueryCompareCriteria(info, ex) |
+ crit=compareCrit(info, ex)
+ )]
)
|
- pdCrit=existsCriteria(info) |
- pdCrit = hasCriteria()
+ crit=existsCriteria(info) |
+ crit = hasCriteria()
)
{
- return pdCrit;
+ return crit;
}
}
@@ -2908,8 +2895,11 @@
Expression expression = null;
}
{
- expression = commonValueExpression(info)
+ expression = criteria(info)
{
+ if (expression instanceof ExpressionCriteria) {
+ return ((ExpressionCriteria)expression).getExpression();
+ }
return expression;
}
}
@@ -3082,15 +3072,13 @@
}
)
|
- // Grouped expression
- LOOKAHEAD(<LPAREN> expression(info))
+ LOOKAHEAD(subquery(info)) subquery = subquery(info)
+ |
( <LPAREN>
expression = expression(info)
<RPAREN>
)
|
- subquery = subquery(info)
- |
// Searched CASE expressions
LOOKAHEAD(2) expression = searchedCaseExpression(info)
|
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-13 18:07:49 UTC (rev 2338)
@@ -261,8 +261,7 @@
ERR.015.012.0004 = The query defining an updatable virtual group cannot be an UPDATE
ERR.015.012.0005 = The query defining an updatable virtual group cannot be a DELETE
ERR.015.012.0006 = The query defining an updatable virtual group should not use GROUP BY or HAVING.
-ERR.015.012.0007 = The query defining an updatable virtual group cannot use an aggregate function: {0}
-ERR.015.012.0008 = The query defining an updatable virtual group cannot use functions in its SELECT clause {0}
+ERR.015.012.0007 = The query defining an updatable virtual group cannot use a non-constant, non-column reference expressions in its SELECT clause {0}.
ERR.015.012.0009 = The query defining an updatable virtual group cannot have more than one group in its FROM clause {0}
ERR.015.012.0010 = The query defining an updatable simple virtual group should select all the required elements in its FROM clause {0}
ERR.015.012.0011 = There must be exactly one projected symbol in the subcommand of an IN clause.
@@ -863,7 +862,7 @@
SimpleQueryResolver.materialized_table_not_used=The query against {0} did not use materialization table {1} 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.Expr_in_GROUP_BY_must_be_elem_func_case=Expressions used in a GROUP BY must be elements, functions, or CASE expressions: "{0}".
+ValidationVisitor.groupby_subquery=Expressions used in a GROUP BY cannot be constant and must not contain subqueries: "{0}".
ValidationVisitor.Procedure_should_have_query=Procedure must execute at least one command to define the procedure result set.
ValidationVisitor.Procedure_has_group_self_reference=Procedure cannot have a Group reference to itself.
ExpressionEvaluator.Expected_props_for_payload_function=Unable to evaluate {0}: expected Properties for command payload but got object of type {1}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -50,6 +50,7 @@
import org.teiid.query.sql.lang.Drop;
import org.teiid.query.sql.lang.DynamicCommand;
import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.ExpressionCriteria;
import org.teiid.query.sql.lang.From;
import org.teiid.query.sql.lang.FromClause;
import org.teiid.query.sql.lang.GroupBy;
@@ -2852,8 +2853,10 @@
}
/** SELECT a or b from g */
- @Test public void testFailsOrInSelect(){
- helpException("SELECT a or b from g"); //$NON-NLS-1$
+ @Test public void testOrInSelect(){
+ Query query = new Query();
+ query.setSelect(new Select(Arrays.asList(new ExpressionSymbol("foo", new CompoundCriteria(CompoundCriteria.OR, Arrays.asList(new ExpressionCriteria(new ElementSymbol("a")), new ExpressionCriteria(new ElementSymbol("b"))))))));
+ helpTest("select a or b", "SELECT (a) OR (b)", query);
}
/** SELECT a FROM g WHERE a LIKE x*/
@@ -6405,8 +6408,8 @@
parameter.setName("param1"); //$NON-NLS-1$
parameter.setParameterType(ParameterInfo.IN);
storedQuery.setParameter(parameter);
- helpTest("Exec proc1(param1 = 'paramValue1')", "EXEC proc1(param1 = 'paramValue1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest("execute proc1(param1 = 'paramValue1')", "EXEC proc1(param1 = 'paramValue1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("Exec proc1(param1 = 'paramValue1')", "EXEC proc1(param1 => 'paramValue1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("execute proc1(param1 = 'paramValue1')", "EXEC proc1(param1 => 'paramValue1')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCase3281NamedVariables() {
@@ -6421,19 +6424,17 @@
param2.setName("param2"); //$NON-NLS-1$
param2.setParameterType(ParameterInfo.IN);
storedQuery.setParameter(param2);
- helpTest("Exec proc1(param1 = 'paramValue1', param2 = 'paramValue2')", "EXEC proc1(param1 = 'paramValue1', param2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest("execute proc1(param1 = 'paramValue1', param2 = 'paramValue2')", "EXEC proc1(param1 = 'paramValue1', param2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("Exec proc1(param1 = 'paramValue1', param2 = 'paramValue2')", "EXEC proc1(param1 => 'paramValue1', param2 => 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("execute proc1(param1 = 'paramValue1', param2 = 'paramValue2')", "EXEC proc1(param1 => 'paramValue1', param2 => 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCase3281QuotedNamedVariableFails2() {
- try {
- QueryParser.getQueryParser().parseCommand("Exec proc1('param1' = 'paramValue1')"); //$NON-NLS-1$
- fail("Named parameter name cannot be quoted"); //$NON-NLS-1$
- }catch(QueryParserException e) {
- // this is expected.
- //e.printStackTrace();
- //assertEquals("Unable to parse named parameter name: 'param1'", e.getMessage()); //$NON-NLS-1$
- }
+ StoredProcedure storedQuery = new StoredProcedure();
+ storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
+ SPParameter param1 = new SPParameter(1, new CompareCriteria(new Constant("a"), CompareCriteria.EQ, new Constant("b"))); //$NON-NLS-1$
+ param1.setParameterType(ParameterInfo.IN);
+ storedQuery.setParameter(param1);
+ helpTest("Exec proc1('a' = 'b')", "EXEC proc1(('a' = 'b'))", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
/** Test what happens if the name of a parameter is a reserved word. It must be quoted (double-ticks). */
@@ -6449,8 +6450,8 @@
param2.setName("in2"); //$NON-NLS-1$
param2.setParameterType(ParameterInfo.IN);
storedQuery.setParameter(param2);
- helpTest("Exec proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", "EXEC proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest("execute proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", "EXEC proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("Exec proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", "EXEC proc1(\"in\" => 'paramValue1', in2 => 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("execute proc1(\"in\" = 'paramValue1', in2 = 'paramValue2')", "EXEC proc1(\"in\" => 'paramValue1', in2 => 'paramValue2')", storedQuery); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testExceptionMessageWithLocation() {
@@ -6831,5 +6832,15 @@
f.setTypeString("CLOB");
helpTestExpression("xmlserialize(x as CLOB)", "XMLSERIALIZE(x AS CLOB)", f);
}
+
+ @Test public void testExpressionCriteria() throws Exception {
+ SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new ExpressionCriteria(new ElementSymbol("x"))), Arrays.asList(new ElementSymbol("y")));
+ helpTestExpression("case when x then y end", "CASE WHEN x THEN y END", sce);
+ }
+
+ @Test public void testExpressionCriteria1() throws Exception {
+ SearchedCaseExpression sce = new SearchedCaseExpression(Arrays.asList(new NotCriteria(new ExpressionCriteria(new ElementSymbol("x")))), Arrays.asList(new ElementSymbol("y")));
+ helpTestExpression("case when not x then y end", "CASE WHEN NOT (x) THEN y END", sce);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -2296,5 +2296,9 @@
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteExpression(original, "'path?%26x=value&y=%20%26%20'", metadata);
}
+
+ @Test public void testRewriteExpressionCriteria() throws Exception {
+ helpTestRewriteCriteria("pm1.g1.e3", "pm1.g1.e3 = true");
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -248,22 +248,8 @@
helpTestWhenExpressions(caseExpr, 4);
helpTestThenExpressions(caseExpr, 4);
}
- try {
- caseExpr.setWhen(TestSearchedCaseExpression.getWhenCriteria(3), getThenExpressions(3));
- fail("Setting WHEN non Expression types should have failed."); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // There should be no side-effects of an illegal argument
- helpTestWhenExpressions(caseExpr, 4);
- helpTestThenExpressions(caseExpr, 4);
- }
- try {
- caseExpr.setWhen(getWhenExpressions(3), TestSearchedCaseExpression.getWhenCriteria(3));
- fail("Setting THEN non Expression types should have failed."); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // There should be no side-effects of an illegal argument
- helpTestWhenExpressions(caseExpr, 4);
- helpTestThenExpressions(caseExpr, 4);
- }
+ caseExpr.setWhen(TestSearchedCaseExpression.getWhenCriteria(3), getThenExpressions(3));
+ caseExpr.setWhen(getWhenExpressions(3), TestSearchedCaseExpression.getWhenCriteria(3));
ArrayList whens = new ArrayList();
whens.add(new Constant("abc")); //$NON-NLS-1$
whens.add(new Constant("xyz")); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -202,14 +202,7 @@
helpTestWhenCriteria(caseExpr, 4);
TestCaseExpression.helpTestThenExpressions(caseExpr, 4);
}
- try {
- caseExpr.setWhen(getWhenCriteria(3), getWhenCriteria(3));
- fail("Setting THEN non Expression types should have failed."); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // There should be no side-effects of an illegal argument
- helpTestWhenCriteria(caseExpr, 4);
- TestCaseExpression.helpTestThenExpressions(caseExpr, 4);
- }
+ caseExpr.setWhen(getWhenCriteria(3), getWhenCriteria(3));
ArrayList whens = new ArrayList();
whens.add(new CompareCriteria(new ElementSymbol("abc"), CompareCriteria.EQ, new Constant(new Integer(20000)))); //$NON-NLS-1$
whens.add(new CompareCriteria(new ElementSymbol("xyz"), CompareCriteria.EQ, new Constant(new Integer(30000)))); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -63,6 +63,7 @@
if (expectedProc == null) {
assertNull(actualProc);
} else {
+ assertNotNull(actualProc);
assertEquals("Didn't get expected generated procedure", expectedProc, actualProc.toString()); //$NON-NLS-1$
QueryParser.getQueryParser().parseCommand(actualProc.toString());
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-07-13 17:56:20 UTC (rev 2337)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-07-13 18:07:49 UTC (rev 2338)
@@ -1348,7 +1348,7 @@
SPParameter param = new SPParameter(1, new Reference(0));
param.setName("p1");//$NON-NLS-1$
proc.setParameter(param);
- helpTest(proc, "EXEC myproc(p1 = ?)"); //$NON-NLS-1$
+ helpTest(proc, "EXEC myproc(p1 => ?)"); //$NON-NLS-1$
}
public void testExecNamedParams() {
@@ -1361,7 +1361,7 @@
SPParameter param2 = new SPParameter(2, new Reference(0));
param2.setName("p2");//$NON-NLS-1$
proc.setParameter(param2);
- helpTest(proc, "EXEC myproc(p1 = ?, p2 = ?)"); //$NON-NLS-1$
+ helpTest(proc, "EXEC myproc(p1 => ?, p2 => ?)"); //$NON-NLS-1$
}
/**
@@ -1381,7 +1381,7 @@
SPParameter param2 = new SPParameter(2, new Reference(0));
param2.setName("in2");//$NON-NLS-1$
proc.setParameter(param2);
- helpTest(proc, "EXEC myproc(\"in\" = ?, in2 = ?)"); //$NON-NLS-1$
+ helpTest(proc, "EXEC myproc(\"in\" => ?, in2 => ?)"); //$NON-NLS-1$
}
// Test methods for Update Procedure Language Objects
@@ -1869,7 +1869,7 @@
public void testNullExpressionInNamedParameter() {
- String expected = "EXEC sp1(PARAM = sp1.PARAM)"; //$NON-NLS-1$
+ String expected = "EXEC sp1(PARAM => sp1.PARAM)"; //$NON-NLS-1$
StoredProcedure sp = new StoredProcedure();
sp.setDisplayNamedParameters(true);
14 years, 5 months
teiid SVN: r2337 - trunk/engine/src/test/java/org/teiid/common/queue.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 13:56:20 -0400 (Tue, 13 Jul 2010)
New Revision: 2337
Modified:
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
Log:
TEIID-1151 fixing unit test
Modified: trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2010-07-13 16:32:31 UTC (rev 2336)
+++ trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2010-07-13 17:56:20 UTC (rev 2337)
@@ -146,13 +146,13 @@
public void run() {
result.add("hello"); //$NON-NLS-1$
try {
- Thread.sleep(75);
+ Thread.sleep(70);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}, 0, 30, TimeUnit.MILLISECONDS);
- Thread.sleep(140);
+ Thread.sleep(120);
future.cancel(true);
assertEquals(2, result.size());
}
@@ -201,6 +201,7 @@
return false;
}
}, 1);
+ Thread.sleep(20); //ensure a later timestamp
FutureWork<Boolean> work4 = new FutureWork<Boolean>(new Callable<Boolean>() {
public Boolean call() throws Exception {
order.add(4);
14 years, 5 months
teiid SVN: r2336 - in trunk/test-integration/db/src: main/java/org/teiid/internal and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 12:32:31 -0400 (Tue, 13 Jul 2010)
New Revision: 2336
Added:
trunk/test-integration/db/src/main/java/org/teiid/internal/
trunk/test-integration/db/src/main/java/org/teiid/internal/core/
trunk/test-integration/db/src/main/java/org/teiid/internal/core/xml/
Removed:
trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml/
Log:
TEIID-1154 removing jdom
Copied: trunk/test-integration/db/src/main/java/org/teiid/internal/core/xml (from rev 2334, trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml)
14 years, 5 months
teiid SVN: r2335 - in trunk: common-core/src/main/resources/org/teiid/core and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-13 10:17:17 -0400 (Tue, 13 Jul 2010)
New Revision: 2335
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
trunk/connectors/translator-ws/pom.xml
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
Log:
TEIID-1154 removing jdom
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 01:29:08 UTC (rev 2334)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 14:17:17 UTC (rev 2335)
@@ -2,15 +2,15 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
- <TITLE>Teiid 7.0 Final Release Notes</TITLE>
+ <TITLE>Teiid ${project.version} Release Notes</TITLE>
<META NAME="CHANGEDBY" CONTENT="Steve Hawkins">
</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<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 7.1 Release Notes</H1>
-<P>Teiid 7.1 adds ODBC, clustering, and caching features.
+<H1>Teiid ${project.version} Release Notes</H1>
+<P>Teiid ${project.version} adds ODBC, clustering, and caching features.
<H2>Overview</H2>
<UL>
Modified: trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-07-13 01:29:08 UTC (rev 2334)
+++ trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-07-13 14:17:17 UTC (rev 2335)
@@ -173,59 +173,6 @@
SqlResourceBundle.unable_to_find_bundle=Unable to find SQL bundle with name {0} and language {1}
MetaMatrixRuntimeException.Caused_by=Caused by:
InterceptorStackImpl.Interceptor_array_cannot_be_empty_1=Interceptor array cannot be empty.
-JdomHelper.The_SAX_driver_class_name_may_not_be_null_1=The SAX driver class name may not be null
-JdomHelper.The_SAX_driver_class_name_may_not_be_zero-length_2=The SAX driver class name may not be zero-length
-JdomHelper.The_file_name_may_not_be_null_3=The file name may not be null
-JdomHelper.The_file_name_may_not_be_zero-length_4=The file name may not be zero-length
-JdomHelper.The_SAX_driver_class_name_may_not_be_null_5=The SAX driver class name may not be null
-JdomHelper.The_SAX_driver_class_name_may_not_be_zero-length_6=The SAX driver class name may not be zero-length
-JdomHelper.The_InputStream_may_not_be_null_7=The InputStream may not be null
-JdomHelper.The_SAX_driver_class_name_may_not_be_null_8=The SAX driver class name may not be null
-JdomHelper.The_SAX_driver_class_name_may_not_be_zero-length_9=The SAX driver class name may not be zero-length
-JdomHelper.The_InputStream_may_not_be_null_10=The InputStream may not be null
-JdomHelper.The_root_tag_name_may_not_be_null_11=The root tag name may not be null
-JdomHelper.The_root_tag_name_may_not_be_zero-length_12=The root tag name may not be zero-length
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_13=The JDOM Element reference may not be null
-JdomHelper.The_Namespace_reference_may_not_be_null_14=The Namespace reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_15=The JDOM Element reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_16=The JDOM Element reference may not be null
-JdomHelper.The_name_may_not_be_null_17=The name may not be null
-JdomHelper.The_name_may_not_be_zero-length_18=The name may not be zero-length
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_19=The JDOM Element reference may not be null
-JdomHelper.The_Namespace_may_not_be_null_20=The Namespace may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_21=The JDOM Element reference may not be null
-JdomHelper.The_name_may_not_be_null_22=The name may not be null
-JdomHelper.The_name_may_not_be_zero-length_23=The name may not be zero-length
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_24=The JDOM Element reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_25=The JDOM Element reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_26=The JDOM Element reference may not be null
-JdomHelper.The_name_may_not_be_null_27=The name may not be null
-JdomHelper.The_name_may_not_be_zero-length_28=The name may not be zero-length
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_29=The JDOM Element reference may not be null
-JdomHelper.The_name_may_not_be_null_30=The name may not be null
-JdomHelper.The_name_may_not_be_zero-length_31=The name may not be zero-length
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_32=The JDOM Element reference may not be null
-JdomHelper.The_name_may_not_be_null_33=The name may not be null
-JdomHelper.The_name_may_not_be_zero-length_34=The name may not be zero-length
-JdomHelper.The_Namespace_reference_may_not_be_null_35=The Namespace reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_36=The JDOM Element reference may not be null
-JdomHelper.The_XMLVisitor_reference_may_not_be_null_37=The XMLVisitor reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_38=The JDOM Element reference may not be null
-JdomHelper.The_XMLVisitor_reference_may_not_be_null_39=The XMLVisitor reference may not be null
-JdomHelper.The_JDOM_Element_reference_may_not_be_null_40=The JDOM Element reference may not be null
-JdomHelper.The_XMLVisitor_reference_may_not_be_null_41=The XMLVisitor reference may not be null
-JdomHelper.The_Document_reference_may_not_be_null_42=The Document reference may not be null
-JdomHelper.The_filename_may_not_be_null_43=The filename may not be null
-JdomHelper.The_filename_may_not_be_zero-length_44=The filename may not be zero-length
-JdomHelper.The_Document_reference_may_not_be_null_45=The Document reference may not be null
-JdomHelper.The_OutputStream_reference_may_not_be_null_46=The OutputStream reference may not be null
-JdomHelper.The_Document_reference_may_not_be_null_47=The Document reference may not be null
-JdomHelper.The_Writer_reference_may_not_be_null_48=The Writer reference may not be null
-JdomHelper.The_Document_reference_may_not_be_null_49=The Document reference may not be null
-JdomHelper.The_stream_reference_may_not_be_null_50=The stream reference may not be null
-JdomHelper.JDOM_Document_tree_51=JDOM Document tree
-JdomHelper.___52=\ \
-JdomHelper.___53=\ \
ServiceInvocation.Method_not_found_{0}.{1}=Method not found {0}.{1}
Command.Could_not_find_method=Could not find method ''{0}.{1}''.
Command.Argument_count_mis-match,_expected_{0}_but_received_{1}=Argument count mis-match, expected {0} but received {1}.
Modified: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-ws/pom.xml 2010-07-13 01:29:08 UTC (rev 2334)
+++ trunk/connectors/translator-ws/pom.xml 2010-07-13 14:17:17 UTC (rev 2335)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <name>Web ervice Translator</name>
+ <name>Web service Translator</name>
<description>This translator provides access to Web Services.</description>
<dependencies>
<dependency>
@@ -27,11 +27,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>provided</scope>
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java 2010-07-13 01:29:08 UTC (rev 2334)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java 2010-07-13 14:17:17 UTC (rev 2335)
@@ -45,9 +45,6 @@
/** XML result documents should be in String form */
public static final String STRING_RESULT = "String"; //$NON-NLS-1$
- /** XML result documents should be in JDOM document form */
- public static final String JDOM_DOCUMENT_RESULT = "JDOM Document"; //$NON-NLS-1$
-
/* Stack <ProgramState> */
private LinkedList<ProgramState> programStack = new LinkedList<ProgramState>();
14 years, 5 months
teiid SVN: r2334 - in trunk: build/kits/jboss-container and 15 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-12 21:29:08 -0400 (Mon, 12 Jul 2010)
New Revision: 2334
Added:
trunk/test-integration/db/src/test/java/org/teiid/internal/
trunk/test-integration/db/src/test/java/org/teiid/internal/core/
trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml/
Removed:
trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt
trunk/engine/src/main/java/org/teiid/internal/core/xml/
trunk/engine/src/test/java/org/teiid/internal/core/xml/
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/engine/pom.xml
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
Log:
TEIID-1154 removing jdom and fixing an issue with function metadata
Deleted: trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt
===================================================================
--- trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt 2010-07-13 01:29:08 UTC (rev 2334)
@@ -1,56 +0,0 @@
-/*--
-
- $Id: LICENSE.txt,v 1.11 2004/02/06 09:32:57 jhunter Exp $
-
- Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions, and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions, and the disclaimer that follows
- these conditions in the documentation and/or other materials
- provided with the distribution.
-
- 3. The name "JDOM" must not be used to endorse or promote products
- derived from this software without prior written permission. For
- written permission, please contact <request_AT_jdom_DOT_org>.
-
- 4. Products derived from this software may not be called "JDOM", nor
- may "JDOM" appear in their name, without prior written permission
- from the JDOM Project Management <request_AT_jdom_DOT_org>.
-
- In addition, we request (but do not require) that you include in the
- end-user documentation provided with the redistribution and/or in the
- software itself an acknowledgement equivalent to the following:
- "This product includes software developed by the
- JDOM Project (http://www.jdom.org/)."
- Alternatively, the acknowledgment may be graphical using the logos
- available at http://www.jdom.org/images/logos.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many
- individuals on behalf of the JDOM Project and was originally
- created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
- Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
- on the JDOM Project, please see <http://www.jdom.org/>.
-
- */
-
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 01:29:08 UTC (rev 2334)
@@ -27,6 +27,7 @@
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
<LI><B>SQL Support</B> - added NULLS FIST/LAST handling - including pushdown support and enhanced numeric stat aggregate functions STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP. Added support for the boolean aggregate functions ANY, SOME, EVERY.
+ <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.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -71,7 +72,6 @@
<h4>From 6.2</h4>
<ul>
<li>Start time is now significantly longer due to the container deployment. However many operations can be performed on configruation files that will trigger a redeployment without the need for a restart.
- <li>Parallel execution of source queries within a query plan has been temporarily disabled.
<li>Inversion of parse, format, and convert system functions is not used if it can be narrowing. In situations where a predicate has the form: parseTime(column, 'format') = {t 'time value'} may lead to reduced performance, since
the parseTime function cannot be pushed down. This should be addressed in future releases.
</ul>
@@ -99,6 +99,17 @@
<h2><a name="LibraryUpdates">Thirdparty Library Updates</a></h2>
The following components have been updated:
+<h4>From 7.0</h4>
+<ul>
+ <li>JDOM was removed.
+</ul>
+<h4>From 6.2</h4>
+<ul>
+ <li>Netty was upgraded to 3.1.5
+ <li>Saxon was upgraded to 9.1.0.8
+ <li>A 5.1 container's version of Arjuna is newer than what was previously included in Teiid 6.x.
+ <li>Various other dependencies have been removed as they are no longer needed or now provided by the container.
+</ul>
<h2><a name="Details">Detailed Release Notes</a></h2>
Detailed Release Notes - Teiid - Version 7.1
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -27,6 +27,8 @@
import java.io.IOException;
import java.util.Collection;
+import javax.xml.bind.JAXBException;
+
import junit.framework.Assert;
import org.mockito.Mockito;
@@ -65,6 +67,8 @@
util.setUDF(methods);
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ } catch (JAXBException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
}
return util.parseCommand(sql);
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/pom.xml 2010-07-13 01:29:08 UTC (rev 2334)
@@ -78,11 +78,6 @@
</dependency>
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- </dependency>
-
- <dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
</dependency>
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -1,126 +1,28 @@
-/*
- * 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.function.metadata;
-import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.Namespace;
-import org.teiid.internal.core.xml.JdomHelper;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * This class is reader for the UDF xmi file. This class reads a xmi file and loads the functions
- */
+@XmlType
+@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
public class FunctionMetadataReader {
-
- private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
- private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
- private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
- private static final String RETURN_PARAMETER = "returnParameter"; //$NON-NLS-1$
- private static final String TYPE = "type"; //$NON-NLS-1$
- private static final String INPUT_PARAMETERS = "inputParameters"; //$NON-NLS-1$
- private static final String DETERMINISTIC = "deterministic"; //$NON-NLS-1$
- private static final String PUSH_DOWN = "pushDown"; //$NON-NLS-1$
- private static final String INVOCATION_METHOD = "invocationMethod"; //$NON-NLS-1$
- private static final String INVOCATION_CLASS = "invocationClass"; //$NON-NLS-1$
- private static final String CATEGORY = "category"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
- private static final String SCALAR_FUNCTION = "ScalarFunction"; //$NON-NLS-1$
- private static final String NS_MMFUNCTION = "mmfunction"; //$NON-NLS-1$
- public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws IOException {
- try {
- List<FunctionMethod> methods = new ArrayList<FunctionMethod>();
-
- Document doc = JdomHelper.buildDocument(source);
- Element rootElement = doc.getRootElement();
-
- // read the xmi file and load the functions
- Namespace ns = rootElement.getNamespace(NS_MMFUNCTION);
- List<Element> functionElements = rootElement.getChildren(SCALAR_FUNCTION, ns);
- for (Element functionElement:functionElements) {
-
- String name = functionElement.getAttributeValue(NAME);
- String description = functionElement.getAttributeValue(DESCRIPTION);
- String category = functionElement.getAttributeValue(CATEGORY);
- String invocationClass = functionElement.getAttributeValue(INVOCATION_CLASS);
- String invocationMethod = functionElement.getAttributeValue(INVOCATION_METHOD);
- int pushdown= decodePushDownType(functionElement.getAttributeValue(PUSH_DOWN));
- boolean deterministic = Boolean.parseBoolean(functionElement.getAttributeValue(DETERMINISTIC));
-
- // read input parameters
- List<FunctionParameter> inParamters = new ArrayList<FunctionParameter>();
- List<Element> inputParameterElements = functionElement.getChildren(INPUT_PARAMETERS);
- for (Element inputElement:inputParameterElements) {
- inParamters.add(new FunctionParameter(inputElement.getAttributeValue(NAME), inputElement.getAttributeValue(TYPE), inputElement.getAttributeValue(DESCRIPTION)));
- }
-
- // read return for the function
- FunctionParameter returnParameter = null;
- Element returnElement = functionElement.getChild(RETURN_PARAMETER);
- if (returnElement != null) {
- returnParameter = new FunctionParameter(FunctionParameter.OUTPUT_PARAMETER_NAME,returnElement.getAttributeValue(TYPE), returnElement.getAttributeValue(DESCRIPTION));
- }
-
- FunctionMethod function = new FunctionMethod(
- name,
- description,
- category,
- pushdown,
- invocationClass,
- invocationMethod,
- inParamters.toArray(new FunctionParameter[inParamters.size()]),
- returnParameter,
- true,
- deterministic ? FunctionMethod.DETERMINISTIC: FunctionMethod.NONDETERMINISTIC);
-
- methods.add(function);
- }
- return methods;
- } catch (JDOMException e) {
- throw new IOException(e);
- }
+ @XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction", name="ScalarFunction")
+ List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
+
+ public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws JAXBException {
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {FunctionMetadataReader.class});
+ Unmarshaller marshaller = jc.createUnmarshaller();
+ FunctionMetadataReader md = (FunctionMetadataReader) marshaller.unmarshal(source);
+ return md.functionMethods;
}
-
- private static int decodePushDownType(String pushdown) {
- if (pushdown != null) {
- if (pushdown.equals(REQUIRED)) {
- return FunctionMethod.CAN_PUSHDOWN;
- } else if (pushdown.equals(ALLOWED)) {
- return FunctionMethod.MUST_PUSHDOWN;
- } else if (pushdown.equals(NOT_ALLOWED)) {
- return FunctionMethod.CANNOT_PUSHDOWN;
- }
- }
- return FunctionMethod.CAN_PUSHDOWN;
- }
-
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -25,6 +25,9 @@
import java.io.Serializable;
import java.util.Arrays;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
import org.teiid.core.util.HashCodeUtil;
@@ -53,6 +56,10 @@
* @see FunctionCategoryConstants
*/
public class FunctionMethod implements Serializable {
+
+ private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
+ private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
+ private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
public static final int CAN_PUSHDOWN = 0;
public static final int CANNOT_PUSHDOWN = 1;
@@ -188,6 +195,7 @@
* Return name of method
* @return Name
*/
+ @XmlAttribute
public String getName() {
return this.name;
}
@@ -204,6 +212,7 @@
* Get description of method
* @return Description
*/
+ @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -221,6 +230,7 @@
* @return Category
* @see FunctionCategoryConstants
*/
+ @XmlAttribute
public String getCategory() {
return this.category;
}
@@ -250,10 +260,26 @@
this.pushdown = pushdown;
}
+ @XmlAttribute
+ public void setPushDown(String pushdown) {
+ if (pushdown != null) {
+ if (pushdown.equals(REQUIRED)) {
+ this.pushdown = FunctionMethod.MUST_PUSHDOWN;
+ } else if (pushdown.equals(ALLOWED)) {
+ this.pushdown = FunctionMethod.CAN_PUSHDOWN;
+ } else if (pushdown.equals(NOT_ALLOWED)) {
+ this.pushdown = FunctionMethod.CANNOT_PUSHDOWN;
+ }
+ } else {
+ this.pushdown = FunctionMethod.CAN_PUSHDOWN;
+ }
+ }
+
/**
* Get invocation class name
* @return Invocation class name
*/
+ @XmlAttribute
public String getInvocationClass() {
return this.invocationClass;
}
@@ -270,6 +296,7 @@
* Get invocation method name
* @return Invocation method name
*/
+ @XmlAttribute
public String getInvocationMethod() {
return this.invocationMethod;
}
@@ -297,6 +324,7 @@
* Get input parameters
* @return Array of input parameters, may be null if 0 parameters
*/
+ @XmlElement
public FunctionParameter[] getInputParameters() {
return this.inputParameters;
}
@@ -313,6 +341,7 @@
* Get ouput parameter.
* @return Output parameter or return argument
*/
+ @XmlElement(name="returnParameter")
public FunctionParameter getOutputParameter() {
return this.outputParameter;
}
@@ -321,7 +350,10 @@
* Set ouput parameter.
* @param param Output Parameter
*/
- public void setOutputParameter(FunctionParameter param) {
+ public void setOutputParameter(FunctionParameter param) {
+ if (param != null) {
+ param.setName(FunctionParameter.OUTPUT_PARAMETER_NAME);
+ }
this.outputParameter = param;
}
@@ -464,7 +496,12 @@
public int getDeterministic() {
return this.deterministic;
}
-
+
+ @XmlAttribute(name="deterministic")
+ public void setDeterministicBoolean(boolean deterministic) {
+ this.deterministic = deterministic ? FunctionMethod.DETERMINISTIC : FunctionMethod.NONDETERMINISTIC;
+ }
+
public void setDeterministic(int deterministic) {
this.deterministic = deterministic;
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -24,6 +24,8 @@
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
+
/**
* A function parameter defines the name and description of an input or output
* parameter for a function. The name should not be null, but that is not
@@ -76,6 +78,7 @@
* Return name of parameter.
* @return Name
*/
+ @XmlAttribute
public String getName() {
return this.name;
}
@@ -92,6 +95,7 @@
* Get description of parameter
* @return Description
*/
+ @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -109,6 +113,7 @@
* @return Type name
* @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
+ @XmlAttribute
public String getType() {
return this.type;
}
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -22,21 +22,27 @@
package org.teiid.query.mapping.xml;
-import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.teiid.internal.core.xml.SAXBuilderHelper;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.teiid.query.QueryPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
@@ -62,26 +68,23 @@
*/
public MappingDocument loadDocument(InputStream stream) throws MappingException {
try {
- SAXBuilder builder = SAXBuilderHelper.createSAXBuilder( false ); // Do not validate XML
- Document doc = builder.build(stream);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(stream);
return loadContents(doc);
- } catch (JDOMException e) {
- throw new MappingException(e);
} catch (IOException e) {
throw new MappingException(e);
- }
+ } catch (ParserConfigurationException e) {
+ throw new MappingException(e);
+ } catch (SAXException e) {
+ throw new MappingException(e);
+ }
}
- public MappingDocument loadDocument(String fileName) throws MappingException {
- try {
- SAXBuilder builder = SAXBuilderHelper.createSAXBuilder( false ); // Do not validate XML
- Document doc = builder.build(new File(fileName) );
- return loadContents(doc);
- } catch (JDOMException e) {
- throw new MappingException(e);
- } catch (IOException e) {
- throw new MappingException(e);
- }
+ public MappingDocument loadDocument(String fileName) throws MappingException, FileNotFoundException {
+ FileInputStream fis = new FileInputStream(fileName);
+ return loadDocument(fis);
}
/**
@@ -90,10 +93,10 @@
MappingDocument loadContents(Document document) throws MappingException {
MappingDocument doc = new MappingDocument(false);
- loadDocumentProperties(doc, document.getRootElement());
+ loadDocumentProperties(doc, document.getDocumentElement());
// now load all the children
- Collection mappingChildren = document.getRootElement().getChildren(MappingNodeConstants.Tags.MAPPING_NODE_NAME);
+ Collection mappingChildren = getChildren(document.getDocumentElement(), MappingNodeConstants.Tags.MAPPING_NODE_NAME);
doc = (MappingDocument)recursiveLoadContents(mappingChildren, doc);
return doc;
}
@@ -107,11 +110,34 @@
node = processMappingNode(elem, parent);
- Collection childrenMappingNodes = elem.getChildren(MappingNodeConstants.Tags.MAPPING_NODE_NAME);
+ Collection childrenMappingNodes = getChildren(elem, MappingNodeConstants.Tags.MAPPING_NODE_NAME);
recursiveLoadContents(childrenMappingNodes, node);
}
return parent;
}
+
+ public Collection<Element> getChildren(Element elem, String name) {
+ NodeList children = elem.getChildNodes();
+ LinkedList<Element> results = new LinkedList<Element>();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName().equals(name)) {
+ results.add((Element)node);
+ }
+ }
+ return results;
+ }
+
+ public Element getChild(Element elem, String name) {
+ NodeList children = elem.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName().equals(name)) {
+ return (Element)node;
+ }
+ }
+ return null;
+ }
/**
* Load a "sequence" node from the mapping document
@@ -379,64 +405,66 @@
*/
private Namespace[] getNamespaceDeclarations(Element element) {
ArrayList namespaces = new ArrayList();
- Iterator elements = this.getElements(element, MappingNodeConstants.Tags.NAMESPACE_DECLARATION).iterator();
+ Iterator elements = getChildren(element, MappingNodeConstants.Tags.NAMESPACE_DECLARATION).iterator();
while (elements.hasNext()){
Element namespace = (Element)elements.next();
Element prefixEl = getElement(namespace, MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX);
Element uriEl = getElement(namespace, MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI);
- String prefix = (prefixEl != null ? prefixEl.getTextTrim() : MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX);
- String uri = uriEl.getTextTrim();
+ String prefix = (prefixEl != null ? getTextTrim(prefixEl) : MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX);
+ String uri = getTextTrim(uriEl);
namespaces.add(new Namespace(prefix, uri));
}
return (Namespace[])namespaces.toArray(new Namespace[namespaces.size()]);
}
+
+ static String getTextTrim(Element element) {
+ if (element == null) {
+ return null;
+ }
+ String result = element.getTextContent();
+ if (result != null) {
+ return result.trim();
+ }
+ return result;
+ }
/**
* Get a specific child element of an element.
*/
Element getElement( Element element, String childName ) {
- return element.getChild(childName);
+ return getChild(element, childName);
}
String getElementValue( Element element, String childName ) {
- Element child = element.getChild(childName);
- if (child != null) {
- return child.getTextTrim();
- }
- return null;
+ Element child = getChild(element, childName);
+ return getTextTrim(child);
}
String getElementValue( Element element, String childName , String defalt) {
- Element child = element.getChild(childName);
- if (child != null) {
- return child.getTextTrim();
+ Element child = getChild(element, childName);
+ String result = getTextTrim(child);
+ if (result == null) {
+ return defalt;
}
- return defalt;
+ return result;
}
int getIntElementValue( Element element, String childName , int defalt) {
- Element child = element.getChild(childName);
+ Element child = getChild(element, childName);
if (child != null) {
- return Integer.valueOf(child.getTextTrim()).intValue();
+ return Integer.valueOf(getTextTrim(child)).intValue();
}
return defalt;
}
boolean getBooleanElementValue( Element element, String childName , boolean defalt) {
- Element child = element.getChild(childName);
+ Element child = getChild(element, childName);
if (child != null) {
- return Boolean.valueOf(child.getTextTrim()).booleanValue();
+ return Boolean.valueOf(getTextTrim(child)).booleanValue();
}
return defalt;
}
- /**
- * Get Collection of specifically-named child element of an element.
- */
- Collection getElements( Element element, String childName ) {
- return element.getChildren(childName);
- }
-
String getName(Element element) {
return getElementValue(element, MappingNodeConstants.Tags.NAME);
}
@@ -531,10 +559,10 @@
List getStagingTableNames(Element element) {
ArrayList cacheGroups = new ArrayList();
- Collection tempGroupElements = getElements(element, MappingNodeConstants.Tags.TEMP_GROUP_NAME);
+ Collection tempGroupElements = getChildren(element, MappingNodeConstants.Tags.TEMP_GROUP_NAME);
for (Iterator i = tempGroupElements.iterator(); i.hasNext();) {
Element tempGroup = (Element)i.next();
- cacheGroups.add(tempGroup.getTextTrim());
+ cacheGroups.add(getTextTrim(tempGroup));
}
return cacheGroups;
}
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -30,11 +30,10 @@
import java.util.Map;
import java.util.Properties;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.Namespace;
-import org.jdom.output.XMLOutputter;
-import org.teiid.internal.core.xml.JdomHelper;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
import org.teiid.query.QueryPlugin;
import org.teiid.query.util.ErrorMessageKeys;
@@ -49,43 +48,36 @@
*/
public class MappingOutputter {
- private static final String NS_NAME = null;
- private static final String NS_URL = null;
private static final String ELEM_ROOT = MappingNodeConstants.Tags.MAPPING_ROOT_NAME;
private static final String ELEM_NODE = MappingNodeConstants.Tags.MAPPING_NODE_NAME;
+
+ XMLStreamWriter writer;
- /** The namespace for the XML mapping document. */
- private Namespace namespace = Namespace.getNamespace( NS_NAME, NS_URL );
-
/**
- * <p>Ouput the current JDOM <code>Document</code> to the output stream.</p>
- *
* @param stream The output stream
*
* @throws IOException if there are problems writing to the file.
*/
public void write(MappingDocument doc, PrintWriter stream) throws IOException {
- write(doc, stream,false,false);
+ try {
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ writer = xof.createXMLStreamWriter(stream);
+ writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.writeStartElement(ELEM_ROOT);
+ writeElement(MappingNodeConstants.Tags.DOCUMENT_ENCODING, doc.getDocumentEncoding());
+ writeElement(MappingNodeConstants.Tags.FORMATTED_DOCUMENT, Boolean.toString(doc.isFormatted()));
+ loadNode(doc.getRootNode());
+ writer.writeEndElement();
+ writer.writeEndDocument();
+ } catch (XMLStreamException e) {
+ throw new IOException(e);
+ }
}
-
- /**
- * <p>Ouput the current JDOM <code>Document</code> to the output stream.</p>
- *
- * @param stream The output stream
- * @param newlines true if the output should contain newline characters, or false otherwise
- * @param indent true if the output should be indented, or false otherwise.
- *
- * @throws IOException if there are problems writing to the file.
- */
- public void write(MappingDocument doc, PrintWriter stream, final boolean newlines, final boolean indent )
- throws IOException {
-
- String indentString = ""; //$NON-NLS-1$
- if (indent) {
- indentString = " "; //$NON-NLS-1$
- }
- XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(indentString, newlines));
- outputter.output( loadDocument(doc), stream );
+
+ void writeElement(String name, String content) throws XMLStreamException {
+ writer.writeStartElement(name);
+ writer.writeCharacters(content);
+ writer.writeEndElement();
}
// =========================================================================
@@ -94,112 +86,76 @@
/**
* <p>Load XML document from domain object. </p>
+ * @throws XMLStreamException
*/
- Document loadDocument(MappingDocument mappingDoc) {
- Document xmlDoc = new Document(new Element(ELEM_ROOT, namespace));
- setDocumentProperties(mappingDoc, xmlDoc.getRootElement());
-
- loadNode(mappingDoc.getRootNode(), xmlDoc.getRootElement());
- return xmlDoc;
- }
+ void loadNode( MappingNode node ) throws XMLStreamException {
+ writer.writeStartElement(ELEM_NODE);
- /**
- * Set the document spefic properties
- */
- void setDocumentProperties(MappingDocument mappingDoc, Element rootElement) {
- rootElement.addContent(new Element(MappingNodeConstants.Tags.DOCUMENT_ENCODING).setText(mappingDoc.getDocumentEncoding()));
- rootElement.addContent(new Element(MappingNodeConstants.Tags.FORMATTED_DOCUMENT).setText(Boolean.toString(mappingDoc.isFormatted())));
- }
-
- /**
- * <p>Load XML document from domain object. </p>
- */
- void loadNode( MappingNode node, Element parentElement ) {
-
- Element element = processNode( node, parentElement );
-
- Iterator children = node.getChildren().iterator();
- while ( children.hasNext() ) {
- MappingNode child = (MappingNode)children.next();
- loadNode( child, element );
- }
- }
-
- /**
- * Process a mapping node, creating an XML element for it.
- */
- Element processNode( MappingNode node, Element parentElement ) {
-
- Element element = new Element( ELEM_NODE, namespace );
- parentElement.addContent( element );
-
//namespace declarations have to be handled specially
Properties namespaces = (Properties)node.getProperty(MappingNodeConstants.Properties.NAMESPACE_DECLARATIONS);
if (namespaces != null){
- addNamespaceDeclarations(element, namespaces);
+ addNamespaceDeclarations(namespaces);
}
// Only get the property values actually stored in the MappingNode, not
// default values also
Map properties = node.getNodeProperties();
- addElementProperties( element, properties );
+ addElementProperties(properties );
- return element;
+ Iterator children = node.getChildren().iterator();
+ while ( children.hasNext() ) {
+ MappingNode child = (MappingNode)children.next();
+ loadNode( child );
+ }
+ writer.writeEndElement();
}
- private void addNamespaceDeclarations(Element element, Properties namespaces){
+ private void addNamespaceDeclarations(Properties namespaces) throws XMLStreamException{
Enumeration e = namespaces.propertyNames();
while (e.hasMoreElements()){
String prefix = (String)e.nextElement();
String uri = namespaces.getProperty(prefix);
- Element namespaceDeclaration = new Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION, namespace);
+ writer.writeStartElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION);
if (!prefix.equals(MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX)){
- namespaceDeclaration.addContent( new Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX).setText(prefix) );
+ writeElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX, prefix);
}
- namespaceDeclaration.addContent( new Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI).setText(uri) );
- element.addContent( namespaceDeclaration);
+ writeElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI, uri);
+ writer.writeEndElement();
}
}
/**
- * Utility to put a property into a map only if the value is not null.
- */
- void addProperty( Map map, String name, Object value ) {
- if ( value != null ) {
- map.put( name, value );
- }
- }
-
- /**
* Add a set of properties to an XML node.
+ * @throws XMLStreamException
*/
- void addElementProperties( Element element, Map properties ) {
+ void addElementProperties(Map properties ) throws XMLStreamException {
Iterator propNames = MappingNodeConstants.Tags.OUTPUTTER_PROPERTY_TAGS.iterator();
while ( propNames.hasNext() ) {
String propName = (String)propNames.next();
Integer propKey = MappingNodeConstants.getPropertyInteger(propName);
if ( properties.containsKey(propKey) ) {
Object value = properties.get(propKey);
- addElementProperty( element, propName, value );
+ addElementProperty( propName, value );
}
}
}
/**
* Add a single property to an XML node.
+ * @throws XMLStreamException
*/
- void addElementProperty( Element element, String name, Object value ) {
+ void addElementProperty(String name, Object value ) throws XMLStreamException {
if ( value == null ) {
throw new IllegalArgumentException( QueryPlugin.Util.getString(ErrorMessageKeys.MAPPING_0010, name) );
}
if (value instanceof Collection){
Iterator i = ((Collection)value).iterator();
while (i.hasNext()) {
- element.addContent( new Element(name,namespace).setText(getXMLText(i.next())));
+ writeElement(name, getXMLText(i.next()));
}
} else {
- element.addContent( new Element(name,namespace).setText(getXMLText(value)));
+ writeElement(name, getXMLText(value));
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -26,14 +26,13 @@
import java.io.FileInputStream;
import java.util.List;
+import junit.framework.TestCase;
+
import org.teiid.core.util.UnitTestUtil;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
-
-import junit.framework.TestCase;
-
public class TestFunctionMetadataReader extends TestCase {
public void testLoadFunctionMethods() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -29,8 +29,6 @@
import net.sf.saxon.trans.XPathException;
-import org.jdom.Attribute;
-import org.jdom.Element;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -61,43 +59,6 @@
return XMLSystemFunctions.xpathValue(xmlContent,xpath);
}
- public void helpCheckElement(final Object jdomNode, final String name, final String prefix, final String namespaceUri,
- final String textContent) {
- assertTrue("Supplied JDOM node is not an Element", jdomNode instanceof Element); //$NON-NLS-1$
- final Element element = (Element)jdomNode;
- assertEquals(name, element.getName());
- assertEquals(prefix, element.getNamespacePrefix());
- assertEquals(namespaceUri, element.getNamespaceURI());
-
- final String actualTextContent = element.getText();
- if (textContent == null) {
- assertEquals(0, actualTextContent.length());
- } else {
- assertEquals(textContent, actualTextContent);
- }
- }
-
- public void helpCheckElement(final Object jdomNode, final String name, final String prefix, final String namespaceUri) {
- assertTrue("Supplied JDOM node is not an Element", jdomNode instanceof Element); //$NON-NLS-1$
- final Element element = (Element)jdomNode;
- assertEquals(name, element.getName());
- assertEquals(prefix, element.getNamespacePrefix());
- assertEquals(namespaceUri, element.getNamespaceURI());
- }
-
- public void helpCheckAttribute(final Object jdomNode, final String name,
- final String prefix, final String namespaceUri,
- final String value ) {
- assertTrue("Supplied JDOM node is not an Attribute",jdomNode instanceof Attribute); //$NON-NLS-1$
- final Attribute attribute = (Attribute)jdomNode;
- assertEquals(name,attribute.getName());
- assertEquals(prefix,attribute.getNamespacePrefix());
- assertEquals(namespaceUri,attribute.getNamespaceURI());
-
- final String actualTextContent = attribute.getValue();
- assertEquals(value,actualTextContent);
- }
-
@Test public void testElement() throws Exception {
String doc = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>"; //$NON-NLS-1$
String xpath = "a/b/c"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -29,6 +29,8 @@
import java.io.StringWriter;
import java.util.ArrayList;
+import javax.xml.bind.JAXBException;
+
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingChoiceNode;
import org.teiid.query.mapping.xml.MappingCriteriaNode;
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -31,6 +31,8 @@
import java.util.Arrays;
import java.util.Collection;
+import javax.xml.bind.JAXBException;
+
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.FileUtils;
@@ -84,6 +86,8 @@
return vdbmetadata;
} catch (URISyntaxException e) {
throw new IOException(e);
+ } catch (JAXBException e) {
+ throw new IOException(e);
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/pom.xml 2010-07-13 01:29:08 UTC (rev 2334)
@@ -355,11 +355,6 @@
<!-- External dependencies -->
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<version>1.5</version>
Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-07-13 01:29:08 UTC (rev 2334)
@@ -26,6 +26,8 @@
import java.util.Collection;
import java.util.HashMap;
+import javax.xml.bind.JAXBException;
+
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.virtual.VirtualFile;
import org.teiid.query.function.metadata.FunctionMetadataReader;
@@ -44,7 +46,7 @@
}
- void buildFunctionModelFile(String name) throws IOException {
+ void buildFunctionModelFile(String name) throws IOException, JAXBException {
VirtualFile file = this.files.get(name);
if (file != null) {
this.methods.addAll(FunctionMetadataReader.loadFunctionMethods(file.openStream()));
Copied: trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml (from rev 2323, trunk/engine/src/main/java/org/teiid/internal/core/xml)
14 years, 5 months
teiid SVN: r2333 - in trunk: build/kits/jboss-container/deployers/teiid.deployer and 14 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-07-12 16:59:02 -0400 (Mon, 12 Jul 2010)
New Revision: 2333
Added:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java
Removed:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java
Modified:
trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.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/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1151 re-adding support for multi-threaded source queries. also fixing partial results and issameconnector check
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-07-12 20:59:02 UTC (rev 2333)
@@ -75,8 +75,10 @@
<property name="securityHelper"><inject bean="SecurityHelper"/></property>
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
- <!-- Process pool maximum thread count. (default 32) Increase this value if the system's available processors is larger than 8. -->
- <property name="maxThreads">32</property>
+ <!-- Process pool maximum thread count. (default 64) -->
+ <property name="maxThreads">64</property>
+ <!-- Max active plans (default 20). Increase this value on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts. -->
+ <property name="maxActivePlans">20</property>
<!-- Query processor time slice, in milliseconds. (default 2000) -->
<property name="timeSliceInMilli">2000</property>
<!-- Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480) -->
Modified: trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-07-12 20:59:02 UTC (rev 2333)
@@ -57,7 +57,6 @@
</bean>
<bean name="ConnectionFactoryDeployer" class="org.teiid.jboss.deployers.ConnectionFactoryDeployer">
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
<property name="VDBStatusChecker"><inject bean="VDBStatusChecker"/></property>
</bean>
Modified: trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-07-12 20:59:02 UTC (rev 2333)
@@ -328,9 +328,6 @@
Streamable.isNUll=Streamable object argument can not be null
Streamable.InvalidReference=Streamable contents are not available, use the Streaming interface to get the contents.
-WorkerPool.New_thread=Created worker thread "{0}".
-WorkerPool.uncaughtException=Uncaught exception processing work
-
FloatToBooleanTransform.Failed_transform=Failed to transform Float to Boolean. Expected 0 or 1 for {0}
NullToAnyTransform.Invalid_value=Invalid value for type {0}: {1} of type {2}
ObjectToAnyTransform.Invalid_value=Invalid conversion from type {0} with value ''{2}'' to type {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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -23,12 +23,11 @@
package org.teiid.common.buffer;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.teiid.core.TeiidComponentException;
@@ -295,7 +294,7 @@
lob.setReferenceStreamId(id);
}
if (this.lobReferences == null) {
- this.lobReferences = Collections.synchronizedMap(new HashMap<String, Streamable<?>>());
+ this.lobReferences = new ConcurrentHashMap<String, Streamable<?>>();
}
this.lobReferences.put(id, lob);
if (lob.getReference() == null) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -44,7 +44,7 @@
return convertCapabilities(srcCaps, null);
}
- public static BasicSourceCapabilities convertCapabilities(ExecutionFactory srcCaps, String connectorID) {
+ public static BasicSourceCapabilities convertCapabilities(ExecutionFactory srcCaps, Object connectorID) {
BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, srcCaps.supportsSelectExpression());
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -26,21 +26,18 @@
*/
package org.teiid.dqp.internal.datamgr.impl;
-import java.util.LinkedList;
+import java.util.Arrays;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem.PermitMode;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.service.BufferService;
@@ -69,13 +66,8 @@
private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
- public static final int DEFAULT_MAX_THREADS = 20;
-
- private static AtomicInteger ID_SEQUENCE = new AtomicInteger();
-
private String translatorName;
private String connectionName;
- private String connectorId = String.valueOf(ID_SEQUENCE.getAndIncrement());
//services acquired in start
private BufferService bufferService;
@@ -85,10 +77,6 @@
private SourceCapabilities cachedCapabilities;
- private int currentConnections;
- private int maxConnections = DEFAULT_MAX_THREADS;
- private LinkedList<ConnectorWorkItem> queuedRequests = new LinkedList<ConnectorWorkItem>();
-
private volatile boolean stopped;
private ExecutionFactory<Object, Object> executionFactory;
@@ -115,24 +103,8 @@
return sb.toString();
}
- public synchronized void acquireConnectionLock(ConnectorWorkItem item) throws BlockedException {
- switch (item.getPermitMode()) {
- case NOT_ACQUIRED:
- if (currentConnections < maxConnections) {
- currentConnections++;
- item.setPermitMode(PermitMode.ACQUIRED);
- return;
- }
- queuedRequests.add(item);
- item.setPermitMode(PermitMode.BLOCKED);
- case BLOCKED:
- throw BlockedException.INSTANCE;
- }
- }
-
public MetadataStore getMetadata(String modelName, Map<String, Datatype> datatypes, Properties importProperties) throws TranslatorException {
MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
- ExecutionFactory<Object, Object> executionFactory = getExecutionFactory();
Object connectionFactory = getConnectionFactory();
Object connection = executionFactory.getConnection(connectionFactory);
try {
@@ -143,26 +115,26 @@
return factory.getMetadataStore();
}
- public SourceCapabilities getCapabilities() throws TranslatorException {
+ public SourceCapabilities getCapabilities() throws TeiidComponentException {
if (cachedCapabilities != null) {
return cachedCapabilities;
}
checkStatus();
ExecutionFactory<Object, Object> translator = getExecutionFactory();
- BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, this.connectorId);
+ BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, Arrays.asList(translatorName, connectionName));
resultCaps.setScope(Scope.SCOPE_GLOBAL);
cachedCapabilities = resultCaps;
return resultCaps;
}
- public ConnectorWork executeRequest(AtomicRequestMessage message, AbstractWorkItem awi) throws TranslatorException {
+ public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException {
// Set the connector ID to be used; if not already set.
checkStatus();
AtomicRequestID atomicRequestId = message.getAtomicRequestID();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$
- ConnectorWorkItem item = new ConnectorWorkItem(message, awi, this);
+ ConnectorWorkItem item = new ConnectorWorkItem(message, this);
Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
return item;
}
@@ -178,17 +150,6 @@
void removeState(AtomicRequestID id) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {id, "Remove State"}); //$NON-NLS-1$
ConnectorWorkItem cwi = requestStates.remove(id);
- if (cwi != null && cwi.getPermitMode() == PermitMode.ACQUIRED) {
- synchronized (this) {
- ConnectorWorkItem next = queuedRequests.pollFirst();
- if (next == null) {
- currentConnections--;
- return;
- }
- next.setPermitMode(PermitMode.ACQUIRED);
- next.getParent().moreWork();
- }
- }
}
int size() {
@@ -257,13 +218,6 @@
* @return the <code>ExecutionFactory</code>.
*/
protected ExecutionFactory<Object, Object> getExecutionFactory() {
- if (this.executionFactory == null) {
- try {
- InitialContext ic = new InitialContext();
- return (ExecutionFactory<Object, Object>)ic.lookup(this.translatorName);
- } catch (NamingException e) {
- }
- }
return this.executionFactory;
}
@@ -306,16 +260,12 @@
return null;
}
- private void checkStatus() throws TranslatorException {
+ private void checkStatus() throws TeiidComponentException {
if (stopped) {
- throw new TranslatorException(DQPPlugin.Util.getString("ConnectorManager.not_in_valid_state", this.translatorName)); //$NON-NLS-1$
+ throw new TeiidComponentException(DQPPlugin.Util.getString("ConnectorManager.not_in_valid_state", this.translatorName)); //$NON-NLS-1$
}
}
- public void setMaxConnections(int value) {
- this.maxConnections = value;
- }
-
public String getTranslatorName() {
return this.translatorName;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -43,7 +43,7 @@
}
public List<ConnectorManager> getConnectorManagers() {
- return new ArrayList(this.repo.values());
+ return new ArrayList<ConnectorManager>(this.repo.values());
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -34,12 +34,10 @@
void cancel();
- AtomicResultsMessage more() throws TranslatorException;
+ AtomicResultsMessage more() throws TranslatorException, BlockedException;
void close();
AtomicResultsMessage execute() throws TranslatorException, BlockedException;
- boolean isQueued();
-
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -37,7 +37,6 @@
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
@@ -64,18 +63,12 @@
public class ConnectorWorkItem implements ConnectorWork {
- enum PermitMode {
- BLOCKED, ACQUIRED, NOT_ACQUIRED
- }
-
/* Permanent state members */
private AtomicRequestID id;
private ConnectorManager manager;
private AtomicRequestMessage requestMsg;
private ExecutionFactory connector;
private QueryMetadataInterface queryMetadata;
- private PermitMode permitMode = PermitMode.NOT_ACQUIRED;
- private AbstractWorkItem awi;
/* Created on new request */
private Object connection;
@@ -95,7 +88,7 @@
private AtomicBoolean isCancelled = new AtomicBoolean();
- ConnectorWorkItem(AtomicRequestMessage message, AbstractWorkItem awi, ConnectorManager manager) {
+ ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager) {
this.id = message.getAtomicRequestID();
this.requestMsg = message;
this.manager = manager;
@@ -118,30 +111,12 @@
this.queryMetadata = vdb.getAttachment(QueryMetadataInterface.class);
this.queryMetadata = new TempMetadataAdapter(this.queryMetadata, new TempMetadataStore());
this.securityContext.setTransactional(requestMsg.isTransactional());
- this.awi = awi;
}
public AtomicRequestID getId() {
return id;
}
- public PermitMode getPermitMode() {
- return permitMode;
- }
-
- public void setPermitMode(PermitMode permitMode) {
- this.permitMode = permitMode;
- }
-
- public AbstractWorkItem getParent() {
- return awi;
- }
-
- @Override
- public boolean isQueued() {
- return this.permitMode == PermitMode.BLOCKED;
- }
-
public void cancel() {
try {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing CANCEL request"}); //$NON-NLS-1$
@@ -189,8 +164,6 @@
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
}
}
-
-
private TranslatorException handleError(Throwable t) {
if (t instanceof DataNotAvailableException) {
@@ -224,10 +197,6 @@
throw new TranslatorException("Request canceled"); //$NON-NLS-1$
}
- if (!this.securityContext.isTransactional()) {
- this.manager.acquireConnectionLock(this);
- }
-
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$
try {
this.connectionFactory = this.manager.getConnectionFactory();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -37,8 +37,9 @@
static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
static final int DEFAULT_QUERY_THRESHOLD = 600;
static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
- public static final int DEFAULT_MAX_PROCESS_WORKERS = 32;
+ public static final int DEFAULT_MAX_PROCESS_WORKERS = 64;
public static final int DEFAULT_MAX_SOURCE_ROWS = -1;
+ public static final int DEFAULT_MAX_ACTIVE_PLANS = 20;
private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
@@ -55,8 +56,18 @@
private int queryThresholdInSecs = DEFAULT_QUERY_THRESHOLD;
private boolean exceptionOnMaxSourceRows = true;
private int maxSourceRows = -1;
+ private int maxActivePlans = DEFAULT_MAX_ACTIVE_PLANS;
+
+ @ManagementProperty(description="Max active plans (default 20). Increase this value, and max threads, on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts.")
+ public int getMaxActivePlans() {
+ return maxActivePlans;
+ }
- @ManagementProperty(description="Process pool maximum thread count. (default 32) Increase this value if the system's available processors is larger than 8")
+ public void setMaxActivePlans(int maxActivePlans) {
+ this.maxActivePlans = maxActivePlans;
+ }
+
+ @ManagementProperty(description="Process pool maximum thread count. (default 64)")
public int getMaxThreads() {
return maxThreads;
}
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -35,9 +35,7 @@
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
import org.teiid.adminapi.Admin;
@@ -58,12 +56,11 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.Streamable;
-import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.BufferService;
@@ -84,15 +81,17 @@
*/
public class DQPCore implements DQP {
- public final static class FutureWork<T> implements Work, WorkListener {
+ //TODO: replace with FutureTask
+ public final static class FutureWork<T> implements Work, WorkListener, PrioritizedRunnable {
private final Callable<T> toCall;
- private DQPWorkContext workContext;
private ResultsFuture<T> result = new ResultsFuture<T>();
private ResultsReceiver<T> receiver = result.getResultsReceiver();
+ private int priority;
+ private long creationTime = System.currentTimeMillis();
- public FutureWork(Callable<T> processor) {
- this.workContext = DQPWorkContext.getWorkContext();
+ public FutureWork(Callable<T> processor, int priority) {
this.toCall = processor;
+ this.priority = priority;
}
public ResultsFuture<T> getResult() {
@@ -102,7 +101,7 @@
@Override
public void run() {
try {
- receiver.receiveResults(workContext.runInContext(toCall));
+ receiver.receiveResults(toCall.call());
} catch (Throwable t) {
receiver.exceptionOccurred(t);
}
@@ -132,6 +131,16 @@
public void workStarted(WorkEvent arg0) {
}
+
+ @Override
+ public int getPriority() {
+ return priority;
+ }
+
+ @Override
+ public long getCreationTime() {
+ return creationTime;
+ }
}
static class ClientState {
@@ -164,8 +173,7 @@
}
- private WorkManager workManager;
- private StatsCapturingWorkManager processWorkerPool;
+ private ThreadReuseExecutor processWorkerPool;
// System properties for Code Table
private int maxCodeTableRecords = DQPConfiguration.DEFAULT_MAX_CODE_TABLE_RECORDS;
@@ -197,6 +205,11 @@
private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
private DQPContextCache contextCache;
private boolean useEntitlements = false;
+
+ private int maxActivePlans = DQPConfiguration.DEFAULT_MAX_ACTIVE_PLANS;
+ private int currentlyActivePlans;
+ private LinkedList<RequestWorkItem> waitingPlans = new LinkedList<RequestWorkItem>();
+
/**
* perform a full shutdown and wait for 10 seconds for all threads to finish
*/
@@ -330,8 +343,13 @@
RequestWorkItem workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
logMMCommand(workItem, Event.NEW, null);
addRequest(requestID, workItem, state);
-
- this.addWork(workItem);
+ synchronized (waitingPlans) {
+ if (currentlyActivePlans < maxActivePlans) {
+ startActivePlan(workItem);
+ } else {
+ waitingPlans.add(workItem);
+ }
+ }
return resultsFuture;
}
@@ -351,8 +369,28 @@
this.requests.put(requestID, workItem);
state.addRequest(requestID);
}
+
+ private void startActivePlan(RequestWorkItem workItem) {
+ workItem.active = true;
+ this.addWork(workItem);
+ this.currentlyActivePlans++;
+ }
+
+ void finishProcessing(final RequestWorkItem workItem) {
+ synchronized (waitingPlans) {
+ if (!workItem.active) {
+ return;
+ }
+ workItem.active = false;
+ currentlyActivePlans--;
+ if (!waitingPlans.isEmpty()) {
+ startActivePlan(waitingPlans.remove());
+ }
+ }
+ }
void removeRequest(final RequestWorkItem workItem) {
+ finishProcessing(workItem);
this.requests.remove(workItem.requestID);
ClientState state = getClientState(workItem.getDqpWorkContext().getSessionId(), false);
if (state != null) {
@@ -361,38 +399,20 @@
contextCache.removeRequestScopedCache(workItem.requestID.toString());
}
- void addWork(Work work) {
- try {
- this.processWorkerPool.scheduleWork(work);
- } catch (WorkException e) {
- //TODO: cancel? close?
- throw new TeiidRuntimeException(e);
- }
+ void addWork(Runnable work) {
+ this.processWorkerPool.execute(work);
}
- void scheduleWork(final RequestWorkItem work, long delay) {
- try {
- this.processWorkerPool.scheduleWork(new Work() {
-
- @Override
- public void run() {
- work.moreWork();
- }
-
- @Override
- public void release() {
-
- }
- }, null, delay);
- } catch (WorkException e) {
- throw new TeiidRuntimeException(e);
- }
+ void scheduleWork(final Runnable r, int priority, long delay) {
+ this.processWorkerPool.schedule(new FutureWork<Void>(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ r.run();
+ return null;
+ }
+ }, priority), delay, TimeUnit.MILLISECONDS);
}
- public void setWorkManager(WorkManager mgr) {
- this.workManager = mgr;
- }
-
public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
long requestId, String streamId)
throws TeiidProcessingException {
@@ -446,13 +466,8 @@
return this.requests.get(processorID);
}
- /**
- * Returns a list of QueueStats objects that represent the queues in
- * this service.
- * If there are no queues, an empty Collection is returned.
- */
public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
- return processWorkerPool.getStats();
+ return this.processWorkerPool.getStats();
}
public void terminateSession(String sessionId) {
@@ -627,9 +642,6 @@
}
public void start(DQPConfiguration config) {
-
- Assertion.isNotNull(this.workManager);
-
this.processorTimeslice = config.getTimeSliceInMilli();
this.maxFetchSize = config.getMaxRowsFetchSize();
this.processorDebugAllowed = config.isProcessDebugAllowed();
@@ -658,7 +670,7 @@
this.bufferManager = bufferService.getBufferManager();
this.contextCache = bufferService.getContextCache();
- this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads(), this.workManager);
+ this.processWorkerPool = new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
dataTierMgr = new DataTierManagerImpl(this,
this.connectorManagerRepository,
@@ -706,7 +718,7 @@
return null;
}
};
- return addWork(processor);
+ return addWork(processor, 0);
}
// local txn
@@ -719,7 +731,7 @@
return null;
}
};
- return addWork(processor);
+ return addWork(processor, 0);
}
// global txn
@@ -732,7 +744,7 @@
return null;
}
};
- return addWork(processor);
+ return addWork(processor, 0);
}
// global txn
public ResultsFuture<?> end(XidImpl xid, int flags) throws XATransactionException {
@@ -756,16 +768,12 @@
return getTransactionService().prepare(workContext.getSessionId(),xid, workContext.getSession().isEmbedded());
}
};
- return addWork(processor);
+ return addWork(processor, 10);
}
- private <T> ResultsFuture<T> addWork(Callable<T> processor) {
- FutureWork<T> work = new FutureWork<T>(processor);
- try {
- this.workManager.scheduleWork(work);
- } catch (WorkException e) {
- throw new TeiidRuntimeException(e);
- }
+ <T> ResultsFuture<T> addWork(Callable<T> processor, int priority) {
+ FutureWork<T> work = new FutureWork<T>(processor, priority);
+ this.addWork(work);
return work.getResult();
}
@@ -786,7 +794,7 @@
return null;
}
};
- return addWork(processor);
+ return addWork(processor, 0);
}
// global txn
public ResultsFuture<?> start(final XidImpl xid, final int flags, final int timeout)
@@ -799,7 +807,7 @@
return null;
}
};
- return addWork(processor);
+ return addWork(processor, 100);
}
public MetadataResult getMetadata(long requestID)
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -32,6 +32,8 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
import javax.security.auth.Subject;
@@ -166,14 +168,24 @@
return session.getVdb();
}
- public <V> V runInContext(Callable<V> callable) throws Exception {
+ public <V> V runInContext(Callable<V> callable) throws Throwable {
+ FutureTask<V> task = new FutureTask<V>(callable);
+ runInContext(task);
+ try {
+ return task.get();
+ } catch (ExecutionException e) {
+ throw e.getCause();
+ }
+ }
+
+ public void runInContext(final Runnable runnable) {
DQPWorkContext.setWorkContext(this);
boolean associated = false;
if (securityHelper != null && this.getSubject() != null) {
associated = securityHelper.assosiateSecurityContext(this.getSecurityDomain(), this.getSecurityContext());
}
try {
- return callable.call();
+ runnable.run();
} finally {
if (associated) {
securityHelper.clearSecurityContext(this.getSecurityDomain());
@@ -181,19 +193,6 @@
DQPWorkContext.releaseWorkContext();
}
}
-
- public void runInContext(final Runnable runnable) {
- try {
- runInContext(new Callable<Void>() {
- @Override
- public Void call() {
- runnable.run();
- return null;
- }
- });
- } catch (Exception e) {
- }
- }
public HashMap<String, DataPolicy> getAllowedDataPolicies() {
if (this.policies == null) {
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -30,10 +30,12 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.RequestMessage;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleSource;
@@ -77,9 +79,11 @@
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.TranslatorException;
-
+/**
+ * Full {@link ProcessorDataManager} implementation that
+ * controls access to {@link ConnectorManager}s and handles system queries.
+ */
public class DataTierManagerImpl implements ProcessorDataManager {
private enum SystemTables {
@@ -130,7 +134,8 @@
}
AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
- return new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorName(), workItem);
+ ConnectorWork work = getCM(aqr.getConnectorName()).registerRequest(aqr);
+ return new DataTierTupleSource(aqr, workItem, work, this);
}
/**
@@ -348,10 +353,6 @@
return aqr;
}
- ConnectorWork executeRequest(AtomicRequestMessage aqr, AbstractWorkItem awi, String connectorName) throws TranslatorException {
- return getCM(connectorName).executeRequest(aqr, awi);
- }
-
/**
* Notify each waiting request that the code table data is now available.
* @param requests
@@ -421,4 +422,12 @@
this.codeTableCache.clearAll();
}
+ <T> ResultsFuture<T> addWork(Callable<T> callable, int priority) {
+ return requestMgr.addWork(callable, priority);
+ }
+
+ void scheduleWork(Runnable r, int priority, long delay) {
+ requestMgr.scheduleWork(r, priority, delay);
+ }
+
}
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -24,105 +24,178 @@
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import org.teiid.client.SourceWarning;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.common.buffer.BlockedException;
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.util.Assertion;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.TranslatorException;
/**
* This tuple source impl can only be used once; once it is closed, it
* cannot be reopened and reused.
+ *
+ * TODO: the handling of DataNotAvailable is awkward.
+ * In the multi-threaded case we'd like to not even
+ * notify the parent plan and just schedule the next poll.
*/
public class DataTierTupleSource implements TupleSource {
// Construction state
- private final List schema;
private final AtomicRequestMessage aqr;
- private final DataTierManagerImpl dataMgr;
- private final String connectorName;
private final RequestWorkItem workItem;
+ private final ConnectorWork cwi;
+ private final DataTierManagerImpl dtm;
// Data state
- private ConnectorWork cwi;
private int index;
private int rowsProcessed;
private volatile AtomicResultsMessage arm;
private boolean closed;
private volatile boolean canceled;
+ private boolean executed;
+ private volatile ResultsFuture<AtomicResultsMessage> futureResult;
private volatile boolean running;
- /**
- * Constructor for DataTierTupleSource.
- */
- public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, String connectorName, RequestWorkItem workItem) {
- this.schema = schema;
+ public DataTierTupleSource(AtomicRequestMessage aqr, RequestWorkItem workItem, ConnectorWork cwi, DataTierManagerImpl dtm) {
this.aqr = aqr;
- this.dataMgr = dataMgr;
- this.connectorName = connectorName;
this.workItem = workItem;
+ this.cwi = cwi;
+ this.dtm = dtm;
+ Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
+ workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
+ if (!aqr.isTransactional()) {
+ addWork();
+ }
}
- /**
- * @see TupleSource#getSchema()
- */
+ private void addWork() {
+ futureResult = dtm.addWork(new Callable<AtomicResultsMessage>() {
+ @Override
+ public AtomicResultsMessage call() throws Exception {
+ return getResults();
+ }
+ }, 100);
+ futureResult.addCompletionListener(new ResultsFuture.CompletionListener<AtomicResultsMessage>() {
+ public void onCompletion(ResultsFuture<AtomicResultsMessage> future) {
+ workItem.moreWork();
+ }
+ });
+ }
+
public List getSchema() {
- return this.schema;
+ return this.aqr.getCommand().getProjectedSymbols();
}
- public List nextTuple() throws TeiidComponentException, TeiidProcessingException {
- if (this.arm == null) {
- open();
- }
+ public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
while (true) {
+ if (arm == null) {
+ AtomicResultsMessage results = null;
+ try {
+ if (futureResult != null || !aqr.isTransactional()) {
+ results = asynchGet();
+ } else {
+ results = getResults();
+ }
+ } catch (TranslatorException e) {
+ exceptionOccurred(e, true);
+ } catch (DataNotAvailableException e) {
+ dtm.scheduleWork(new Runnable() {
+ @Override
+ public void run() {
+ workItem.moreWork();
+ }
+ }, 10, e.getRetryDelay());
+ throw BlockedException.INSTANCE;
+ }
+ receiveResults(results);
+ }
if (index < arm.getResults().length) {
return this.arm.getResults()[index++];
}
+ arm = null;
if (isDone()) {
return null;
}
- try {
- running = true;
- receiveResults(this.cwi.more());
- } catch (TranslatorException e) {
- exceptionOccurred(e, true);
- } finally {
- running = false;
- }
}
}
+
+ private AtomicResultsMessage asynchGet()
+ throws BlockedException, TeiidProcessingException,
+ TeiidComponentException, TranslatorException {
+ if (futureResult == null) {
+ addWork();
+ }
+ if (!futureResult.isDone()) {
+ throw BlockedException.INSTANCE;
+ }
+ ResultsFuture<AtomicResultsMessage> currentResults = futureResult;
+ futureResult = null;
+ AtomicResultsMessage results = null;
+ try {
+ results = currentResults.get();
+ addWork();
+ } catch (InterruptedException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)e.getCause();
+ }
+ if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
+ }
+ if (e.getCause() instanceof TranslatorException) {
+ throw (TranslatorException)e.getCause();
+ }
+ if (e.getCause() instanceof RuntimeException) {
+ throw (RuntimeException)e.getCause();
+ }
+ //shouldn't happen
+ throw new RuntimeException(e);
+ }
+ return results;
+ }
+
+ private AtomicResultsMessage getResults()
+ throws BlockedException, TeiidComponentException,
+ TranslatorException {
+ AtomicResultsMessage results = null;
+ try {
+ running = true;
+ if (!executed) {
+ results = cwi.execute();
+ executed = true;
+ } else {
+ results = cwi.more();
+ }
+ } finally {
+ running = false;
+ }
+ return results;
+ }
public boolean isQueued() {
- return this.cwi != null && this.cwi.isQueued();
+ ResultsFuture<AtomicResultsMessage> future = futureResult;
+ return !running && future != null && !future.isDone();
}
public boolean isDone() {
- return this.arm != null && this.arm.getFinalRow() >= 0;
+ AtomicResultsMessage results = this.arm;
+ return results != null && results.getFinalRow() >= 0;
}
- void open() throws TeiidComponentException, TeiidProcessingException {
- try {
- if (this.cwi == null) {
- this.cwi = this.dataMgr.executeRequest(aqr, this.workItem, this.connectorName);
- Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
- workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
- }
- running = true;
- receiveResults(this.cwi.execute());
- } catch (TranslatorException e) {
- exceptionOccurred(e, true);
- } finally {
- running = false;
- }
- }
-
public boolean isRunning() {
return running;
}
@@ -131,7 +204,27 @@
if (!closed) {
if (cwi != null) {
workItem.closeAtomicRequest(this.aqr.getAtomicRequestID());
- this.cwi.close();
+ if (!aqr.isTransactional()) {
+ if (futureResult != null && !futureResult.isDone()) {
+ futureResult.addCompletionListener(new ResultsFuture.CompletionListener<AtomicResultsMessage>() {
+ @Override
+ public void onCompletion(
+ ResultsFuture<AtomicResultsMessage> future) {
+ cwi.close(); // there is a small chance that this will be done in the processing thread
+ }
+ });
+ } else {
+ dtm.addWork(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ cwi.close();
+ return null;
+ }
+ }, 0);
+ }
+ } else {
+ this.cwi.close();
+ }
}
closed = true;
}
@@ -165,7 +258,7 @@
AtomicResultsMessage emptyResults = new AtomicResultsMessage(new List[0], null);
emptyResults.setWarnings(Arrays.asList((Exception)exception));
emptyResults.setFinalRow(this.rowsProcessed);
- receiveResults(arm);
+ receiveResults(emptyResults);
} else {
if (exception.getCause() instanceof TeiidComponentException) {
throw (TeiidComponentException)exception.getCause();
@@ -194,14 +287,11 @@
}
public String getConnectorName() {
- return this.connectorName;
+ return this.aqr.getConnectorName();
}
public boolean isTransactional() {
- if (this.arm == null) {
- return false;
- }
- return this.arm.isTransactional();
+ return this.aqr.isTransactional();
}
@Override
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -47,6 +47,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable;
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.TransactionContext;
@@ -64,10 +65,8 @@
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.translator.DataNotAvailableException;
-
-public class RequestWorkItem extends AbstractWorkItem {
+public class RequestWorkItem extends AbstractWorkItem implements PrioritizedRunnable {
private enum ProcessingState {NEW, PROCESSING, CLOSE}
private ProcessingState state = ProcessingState.NEW;
@@ -86,6 +85,7 @@
private CacheID cid;
private final TransactionService transactionService;
private final DQPWorkContext dqpWorkContext;
+ boolean active;
/*
* obtained during new
@@ -105,16 +105,17 @@
private Map<AtomicRequestID, DataTierTupleSource> connectorInfo = new ConcurrentHashMap<AtomicRequestID, DataTierTupleSource>(4);
// This exception contains details of all the atomic requests that failed when query is run in partial results mode.
private List<TeiidException> warnings = new LinkedList<TeiidException>();
- private boolean doneProducingBatches;
+ private volatile boolean doneProducingBatches;
private volatile boolean isClosed;
private volatile boolean isCanceled;
private volatile boolean closeRequested;
+
//results request
private ResultsReceiver<ResultsMessage> resultsReceiver;
private int begin;
private int end;
private TupleBatch savedBatch;
- private Map<Integer, LobWorkItem> lobStreams = new ConcurrentHashMap<Integer, LobWorkItem>(4);
+ private Map<Integer, LobWorkItem> lobStreams = new ConcurrentHashMap<Integer, LobWorkItem>(4);
/**The time when command begins processing on the server.*/
private long processingTimestamp = System.currentTimeMillis();
@@ -155,7 +156,11 @@
@Override
protected void resumeProcessing() {
- dqpCore.addWork(this);
+ if (doneProducingBatches && !closeRequested && !isCanceled) {
+ this.run(); // just run in the IO thread
+ } else {
+ dqpCore.addWork(this);
+ }
}
@Override
@@ -184,9 +189,6 @@
} catch (QueryProcessor.ExpiredTimeSliceException e) {
LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "- time slice expired"); //$NON-NLS-1$ //$NON-NLS-2$
this.moreWork();
- } catch (DataNotAvailableException e) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "- data not available"); //$NON-NLS-1$ //$NON-NLS-2$
- this.dqpCore.scheduleWork(this, e.getRetryDelay());
} catch (Throwable e) {
LogManager.logDetail(LogConstants.CTX_DQP, e, "Request Thread", requestID, "- error occurred"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -227,7 +229,6 @@
private void resume() throws XATransactionException {
if (this.transactionState == TransactionState.ACTIVE && this.transactionContext.getTransaction() != null) {
- //there's no need to do this for xa transactions, as that is done by the workmanager
this.transactionService.resume(this.transactionContext);
}
}
@@ -339,7 +340,7 @@
this.resultsBuffer = cr.getResults();
this.analysisRecord = cr.getAnalysisRecord();
this.originalCommand = cr.getCommand();
- this.doneProducingBatches = true;
+ this.doneProducingBatches();
return;
}
}
@@ -357,7 +358,9 @@
super.flushBatchDirect(batch, add);
added = true;
}
- doneProducingBatches = batch.getTerminationFlag();
+ if (batch.getTerminationFlag()) {
+ doneProducingBatches();
+ }
if (doneProducingBatches && cid != null) {
boolean sessionScope = processor.getContext().isSessionFunctionEvaluated();
CachedResults cr = new CachedResults();
@@ -381,7 +384,7 @@
this.transactionState = TransactionState.ACTIVE;
}
if (requestMsg.isNoExec()) {
- doneProducingBatches = true;
+ doneProducingBatches();
resultsBuffer.close();
this.cid = null;
}
@@ -608,7 +611,9 @@
}
}
this.closeRequested = true;
- this.requestCancel(); //pending work should be canceled for fastest clean up
+ if (!this.doneProducingBatches) {
+ this.requestCancel(); //pending work should be canceled for fastest clean up
+ }
this.moreWork();
}
@@ -692,5 +697,20 @@
LogManager.logWarning(LogConstants.CTX_DQP, e, "Failed to cancel " + requestID); //$NON-NLS-1$
}
}
+
+ private void doneProducingBatches() {
+ this.doneProducingBatches = true;
+ dqpCore.finishProcessing(this);
+ }
+ @Override
+ public int getPriority() {
+ return (closeRequested || isCanceled) ? 0 : 1000;
+ }
+
+ @Override
+ public long getCreationTime() {
+ return processingTimestamp;
+ }
+
}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -1,294 +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 java.util.Collections;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.ExecutionContext;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkListener;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.core.util.NamedThreadFactory;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
-import org.teiid.query.QueryPlugin;
-
-
-/**
- * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to
- * capture statistics and implement an unbounded queue of work.
- */
-public class StatsCapturingWorkManager {
-
- private static class WorkContext {
- ExecutionContext context;
- long startTimeout;
- long submitted = System.currentTimeMillis();
-
- public WorkContext(ExecutionContext context, long startTimeout) {
- this.context = context;
- this.startTimeout = startTimeout;
- }
-
- long getStartTimeout() {
- if (startTimeout == 0) {
- return 0;
- }
- return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
- }
-
- }
-
- private final class WorkWrapper implements Work {
- private final Work work;
- private final WorkContext workContext;
- private final DQPWorkContext dqpWorkContext;
-
- private WorkWrapper(Work work, WorkContext workContext, DQPWorkContext dqpWorkContext) {
- this.work = work;
- this.workContext = workContext;
- this.dqpWorkContext = dqpWorkContext;
- }
-
- @Override
- public void run() {
- Thread t = Thread.currentThread();
- synchronized (poolLock) {
- threads.add(t);
- }
- String name = t.getName();
- t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.TRACE)) {
- LogManager.logTrace(LogConstants.CTX_RUNTIME, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
- }
- boolean success = false;
- try {
- dqpWorkContext.runInContext(work);
- success = true;
- } finally {
- synchronized (poolLock) {
- WorkWrapper next = null;
- if (success) {
- completedCount++;
- next = queue.poll();
- }
- threads.remove(t);
- if (next == null) {
- activeCount--;
- if (activeCount == 0 && terminated) {
- poolLock.notifyAll();
- }
- } else {
- try {
- if (next.workContext == null) {
- delegate.scheduleWork(next);
- } else {
- delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
- }
- } catch (WorkException e) {
- handleException(next.work, e);
- }
- }
- }
- t.setName(name);
- }
- }
-
- @Override
- public void release() {
- this.work.release();
- }
- }
-
- private static void handleException(Work work, WorkException e) {
- if (work instanceof WorkListener) {
- ((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
- } else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_RUNTIME, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$
- }
- }
-
- private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
-
- private volatile int activeCount;
- private volatile int highestActiveCount;
- private volatile int highestQueueSize;
- private volatile boolean terminated;
- private volatile int submittedCount;
- private volatile int completedCount;
-
- private Object poolLock = new Object();
- private AtomicInteger threadCounter = new AtomicInteger();
-
- private String poolName;
- private int maximumPoolSize;
- private WorkManager delegate;
-
- private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
- private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
- private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
- private int idCounter;
-
- public StatsCapturingWorkManager(String name, int maximumPoolSize, WorkManager delegate) {
- this.maximumPoolSize = maximumPoolSize;
- this.poolName = name;
- this.delegate = delegate;
- }
-
- public void scheduleWork(final Work arg0) throws WorkException {
- scheduleWork(arg0, (WorkContext)null, DQPWorkContext.getWorkContext());
- }
-
- private void scheduleWork(final Work work, WorkContext workContext, DQPWorkContext dqpWorkContext)
- throws WorkRejectedException, WorkException {
- boolean atMaxThreads = false;
- boolean newMaxQueueSize = false;
- synchronized (poolLock) {
- checkForTermination();
- submittedCount++;
- atMaxThreads = activeCount == maximumPoolSize;
- if (atMaxThreads) {
- queue.add(new WorkWrapper(work, workContext, dqpWorkContext));
- int queueSize = queue.size();
- if (queueSize > highestQueueSize) {
- newMaxQueueSize = true;
- highestQueueSize = queueSize;
- }
- } else {
- activeCount++;
- highestActiveCount = Math.max(activeCount, highestActiveCount);
- }
- }
- if (atMaxThreads) {
- if (newMaxQueueSize && maximumPoolSize > 1) {
- LogManager.logWarning(LogConstants.CTX_RUNTIME, QueryPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
- }
- return;
- }
- if (workContext == null) {
- delegate.scheduleWork(new WorkWrapper(work, null, dqpWorkContext));
- } else {
- delegate.scheduleWork(new WorkWrapper(work, null, dqpWorkContext), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
- }
- }
-
- public void scheduleWork(final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
- if (delay < 1) {
- scheduleWork(arg0, new WorkContext(arg2, WorkManager.INDEFINITE), DQPWorkContext.getWorkContext());
- } else {
- synchronized (futures) {
- final int id = idCounter++;
- final DQPWorkContext dqpWorkContext = DQPWorkContext.getWorkContext();
- ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
-
- @Override
- public void run() {
- try {
- futures.remove(id);
- scheduleWork(arg0, new WorkContext(arg2, WorkManager.INDEFINITE), dqpWorkContext);
- } catch (WorkException e) {
- handleException(arg0, e);
- }
- }
- }, delay, TimeUnit.MILLISECONDS);
- this.futures.put(id, sf);
- }
- }
- }
-
- private void checkForTermination() throws WorkRejectedException {
- if (terminated) {
- throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
- }
- }
-
- public WorkerPoolStatisticsMetadata getStats() {
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setName(poolName);
- stats.setQueued(queue.size());
- stats.setHighestQueued(highestQueueSize);
- stats.setActiveThreads(this.activeCount);
- stats.setMaxThreads(this.maximumPoolSize);
- stats.setTotalSubmitted(this.submittedCount);
- stats.setHighestActiveThreads(this.highestActiveCount);
- stats.setTotalCompleted(this.completedCount);
- return stats;
- }
-
- public void shutdown() {
- this.terminated = true;
- }
-
- public void shutdownNow() {
- this.shutdown();
- synchronized (poolLock) {
- for (Thread t : threads) {
- t.interrupt();
- }
- queue.clear();
- }
- synchronized (futures) {
- for (ScheduledFuture<?> future : futures.values()) {
- future.cancel(true);
- }
- futures.clear();
- }
- }
-
- public boolean isTerminated() {
- return terminated;
- }
-
- public boolean awaitTermination(long timeout, TimeUnit unit)
- throws InterruptedException {
- long timeoutMillis = unit.toMillis(timeout);
- long finalMillis = System.currentTimeMillis() + timeoutMillis;
- synchronized (poolLock) {
- while (this.activeCount > 0 || !terminated) {
- if (timeoutMillis < 1) {
- return false;
- }
- poolLock.wait(timeoutMillis);
- timeoutMillis = finalMillis - System.currentTimeMillis();
- }
- }
- return true;
- }
-
-}
Added: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -0,0 +1,412 @@
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.Delayed;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.core.util.NamedThreadFactory;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.query.QueryPlugin;
+
+/**
+ * An Executor that:
+ * <ol>
+ * <li>minimizes thread creation</li>
+ * <li>allows for proper timeout of idle threads</li>
+ * <li>allows for queuing</li>
+ * </ol>
+ * <br/>
+ * A non-fifo (lifo) {@link SynchronousQueue} based {@link ThreadPoolExecutor} satisfies 1 and 2, but not 3.
+ * A bounded or unbound queue based {@link ThreadPoolExecutor} allows for 3, but will tend to create
+ * up to the maximum number of threads and makes no guarantee on thread scheduling.
+ * <br/>
+ * So the approach here is to use a virtual thread pool off of a {@link SynchronousQueue}
+ * backed {@link ThreadPoolExecutor}.
+ * <br/>
+ * There is also only a single master scheduling thread with actual executions deferred.
+ *
+ * TODO: there is a race condition between retiring threads and adding work, which may create extra threads.
+ * That is a flaw with attempting to reuse, rather than create threads.
+ * TODO: bounded queuing - we never bothered bounding in the past with our worker pools, but reasonable
+ * defaults would be a good idea.
+ */
+public class ThreadReuseExecutor implements Executor {
+
+ public interface PrioritizedRunnable extends Runnable {
+
+ int getPriority();
+
+ long getCreationTime();
+
+ }
+
+ static class RunnableWrapper implements PrioritizedRunnable {
+ Runnable r;
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ long creationTime;
+ int priority;
+
+ public RunnableWrapper(Runnable r) {
+ if (r instanceof PrioritizedRunnable) {
+ PrioritizedRunnable pr = (PrioritizedRunnable)r;
+ creationTime = pr.getCreationTime();
+ priority = pr.getPriority();
+ } else {
+ creationTime = System.currentTimeMillis();
+ priority = Integer.MAX_VALUE;
+ }
+ this.r = r;
+ }
+
+ @Override
+ public long getCreationTime() {
+ return creationTime;
+ }
+
+ @Override
+ public int getPriority() {
+ return priority;
+ }
+
+ @Override
+ public void run() {
+ workContext.runInContext(r);
+ }
+
+ }
+
+ private final ThreadPoolExecutor tpe;
+
+ private ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
+ class ScheduledFutureTask extends FutureTask<Void> implements ScheduledFuture<Void>, PrioritizedRunnable {
+ private ScheduledFuture<?> scheduledFuture;
+ private boolean periodic;
+ private volatile boolean running;
+ private PrioritizedRunnable runnable;
+
+ public ScheduledFutureTask(PrioritizedRunnable runnable, boolean periodic) {
+ super(runnable, null);
+ this.periodic = periodic;
+ this.runnable = runnable;
+ }
+
+ public void setScheduledFuture(ScheduledFuture<?> scheduledFuture) {
+ scheduledTasks.add(this);
+ this.scheduledFuture = scheduledFuture;
+ }
+
+ @Override
+ public long getDelay(TimeUnit unit) {
+ return this.scheduledFuture.getDelay(unit);
+ }
+
+ @Override
+ public int compareTo(Delayed o) {
+ return this.scheduledFuture.compareTo(o);
+ }
+
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ this.scheduledFuture.cancel(false);
+ scheduledTasks.remove(this);
+ return super.cancel(mayInterruptIfRunning);
+ }
+
+ public Runnable getParent() {
+ return new Runnable() {
+ @Override
+ public void run() {
+ if (running || terminated) {
+ return;
+ }
+ running = periodic;
+ executeDirect(ScheduledFutureTask.this);
+ }
+ };
+ }
+
+ @Override
+ public void run() {
+ if (periodic) {
+ if (!this.runAndReset()) {
+ this.scheduledFuture.cancel(false);
+ scheduledTasks.remove(this);
+ }
+ running = false;
+ } else {
+ scheduledTasks.remove(this);
+ super.run();
+ }
+ }
+
+ @Override
+ public long getCreationTime() {
+ return runnable.getCreationTime();
+ }
+
+ @Override
+ public int getPriority() {
+ return runnable.getPriority();
+ }
+ }
+
+ private volatile int activeCount;
+ private volatile int highestActiveCount;
+ private volatile int highestQueueSize;
+ private volatile boolean terminated;
+ private volatile int submittedCount;
+ private volatile int completedCount;
+ private Object poolLock = new Object();
+ private AtomicInteger threadCounter = new AtomicInteger();
+ private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
+ private Set<ScheduledFutureTask> scheduledTasks = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<ScheduledFutureTask, Boolean>()));
+
+ private String poolName;
+ private int maximumPoolSize;
+ private Queue<PrioritizedRunnable> queue = new PriorityQueue<PrioritizedRunnable>(11, new Comparator<PrioritizedRunnable>() {
+ @Override
+ public int compare(PrioritizedRunnable pr1, PrioritizedRunnable pr2) {
+ int result = pr1.getPriority() - pr2.getPriority();
+ if (result == 0) {
+ return Long.signum(pr1.getCreationTime() - pr2.getCreationTime());
+ }
+ return result;
+ }
+ });
+
+ public ThreadReuseExecutor(String name, int maximumPoolSize) {
+ this.maximumPoolSize = maximumPoolSize;
+ this.poolName = name;
+
+ tpe = new ThreadPoolExecutor(0,
+ maximumPoolSize, 2, TimeUnit.MINUTES,
+ new SynchronousQueue<Runnable>(), new NamedThreadFactory("Worker")) { //$NON-NLS-1$
+ @Override
+ protected void afterExecute(Runnable r, Throwable t) {
+ if (t != null) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, t, QueryPlugin.Util.getString("WorkerPool.uncaughtException")); //$NON-NLS-1$
+ }
+ }
+
+ };
+ }
+
+ public void execute(final Runnable command) {
+ executeDirect(new RunnableWrapper(command));
+ }
+
+ private void executeDirect(final PrioritizedRunnable command) {
+ boolean atMaxThreads = false;
+ boolean newMaxQueueSize = false;
+ synchronized (poolLock) {
+ checkForTermination();
+ submittedCount++;
+ atMaxThreads = activeCount == maximumPoolSize;
+ if (atMaxThreads) {
+ queue.add(command);
+ int queueSize = queue.size();
+ if (queueSize > highestQueueSize) {
+ newMaxQueueSize = true;
+ highestQueueSize = queueSize;
+ }
+ } else {
+ activeCount++;
+ highestActiveCount = Math.max(activeCount, highestActiveCount);
+ }
+ }
+ if (atMaxThreads) {
+ if (newMaxQueueSize && maximumPoolSize > 1) {
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, QueryPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
+ }
+ return;
+ }
+ tpe.execute(new Runnable() {
+ @Override
+ public void run() {
+ Thread t = Thread.currentThread();
+ threads.add(t);
+ String name = t.getName();
+ t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$
+ }
+ Runnable r = command;
+ while (r != null) {
+ boolean success = false;
+ try {
+ r.run();
+ success = true;
+ } finally {
+ synchronized (poolLock) {
+ if (success) {
+ completedCount++;
+ r = queue.poll();
+ }
+ if (!success || r == null) {
+ threads.remove(t);
+ activeCount--;
+ if (activeCount == 0 && terminated) {
+ poolLock.notifyAll();
+ }
+ }
+ }
+ t.setName(name);
+ }
+ }
+ };
+ });
+ }
+
+ private void checkForTermination() {
+ if (terminated) {
+ throw new RejectedExecutionException();
+ }
+ }
+
+ public int getActiveCount() {
+ return activeCount;
+ }
+
+ public int getSubmittedCount() {
+ return submittedCount;
+ }
+
+ public int getCompletedCount() {
+ return completedCount;
+ }
+
+ public int getPoolSize() {
+ return activeCount;
+ }
+
+ public boolean isTerminated() {
+ return terminated;
+ }
+
+ public void shutdown() {
+ this.terminated = true;
+ synchronized (scheduledTasks) {
+ for (ScheduledFuture<?> future : new ArrayList<ScheduledFuture<?>>(scheduledTasks)) {
+ future.cancel(false);
+ }
+ scheduledTasks.clear();
+ }
+ }
+
+ public int getLargestPoolSize() {
+ return this.highestActiveCount;
+ }
+
+ public WorkerPoolStatisticsMetadata getStats() {
+ WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+ stats.setName(poolName);
+ stats.setQueued(queue.size());
+ stats.setHighestQueued(highestQueueSize);
+ stats.setActiveThreads(getActiveCount());
+ stats.setMaxThreads(this.maximumPoolSize);
+ stats.setTotalSubmitted(getSubmittedCount());
+ stats.setHighestActiveThreads(getLargestPoolSize());
+ stats.setTotalCompleted(getCompletedCount());
+ return stats;
+ }
+
+ public boolean hasWork() {
+ synchronized (poolLock) {
+ return this.getSubmittedCount() - this.getCompletedCount() > 0 && !this.isTerminated();
+ }
+ }
+
+ public List<Runnable> shutdownNow() {
+ this.shutdown();
+ synchronized (poolLock) {
+ synchronized (threads) {
+ for (Thread t : threads) {
+ t.interrupt();
+ }
+ }
+ List<Runnable> result = new ArrayList<Runnable>(queue);
+ queue.clear();
+ return result;
+ }
+ }
+
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ long timeoutMillis = unit.toMillis(timeout);
+ long finalMillis = System.currentTimeMillis() + timeoutMillis;
+ synchronized (poolLock) {
+ while (this.activeCount > 0 || !terminated) {
+ if (timeoutMillis < 1) {
+ return false;
+ }
+ poolLock.wait(timeoutMillis);
+ timeoutMillis = finalMillis - System.currentTimeMillis();
+ }
+ }
+ return true;
+ }
+
+ public ScheduledFuture<?> schedule(final Runnable command, long delay,
+ TimeUnit unit) {
+ checkForTermination();
+ ScheduledFutureTask sft = new ScheduledFutureTask(new RunnableWrapper(command), false);
+ synchronized (scheduledTasks) {
+ ScheduledFuture<?> future = stpe.schedule(sft.getParent(), delay, unit);
+ sft.setScheduledFuture(future);
+ return sft;
+ }
+ }
+
+ public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command,
+ long initialDelay, long period, TimeUnit unit) {
+ checkForTermination();
+ ScheduledFutureTask sft = new ScheduledFutureTask(new RunnableWrapper(command), true);
+ synchronized (scheduledTasks) {
+ ScheduledFuture<?> future = stpe.scheduleAtFixedRate(sft.getParent(), initialDelay, period, unit);
+ sft.setScheduledFuture(future);
+ return sft;
+ }
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ThreadReuseExecutor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -246,7 +246,7 @@
public Transaction call() throws Exception {
return transactionManager.getTransaction();
}
- });
+ }, 0);
workManager.doWork(work, WorkManager.INDEFINITE, tc, null);
tc.setTransaction(work.getResult().get());
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -31,8 +31,8 @@
import org.teiid.common.buffer.BufferManager.BufferReserveMode;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
@@ -41,9 +41,10 @@
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.processor.BatchCollector.BatchProducer;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.DataNotAvailableException;
-
+/**
+ * Driver for plan processing.
+ */
public class QueryProcessor implements BatchProducer {
public static class ExpiredTimeSliceException extends TeiidRuntimeException {
@@ -110,11 +111,6 @@
throw e;
}
continue;
- } catch (DataNotAvailableException e) {
- if (!nonBlocking) {
- throw e;
- }
- wait = e.getRetryDelay();
} catch (BlockedException e) {
if (!nonBlocking) {
throw e;
@@ -147,6 +143,9 @@
long currentTime = System.currentTimeMillis();
Assertion.assertTrue(!processorClosed);
+
+ //TODO: see if there is pending work before preempting
+
while(currentTime < context.getTimeSliceEnd()) {
if (requestCanceled) {
throw new TeiidProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", getProcessID())); //$NON-NLS-1$
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-07-12 20:59:02 UTC (rev 2333)
@@ -941,4 +941,7 @@
NewCalculateCostUtil.badCost=Unexpected format encountered for max or min value
WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}".
+WorkerPool.New_thread=Created worker thread "{0}".
+WorkerPool.uncaughtException=Uncaught exception processing work
+
XMLSystemFunctions.invalid_namespaces=Invalid namespaces supplied for XPath expression - ''{0}''
\ No newline at end of file
Deleted: trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -1,179 +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.common.queue;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkManager;
-import javax.resource.spi.work.WorkRejectedException;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.dqp.internal.process.StatsCapturingWorkManager;
-
-/**
- */
-public class TestStatsCapturingWorkManager {
-
- private WorkManager manager = new FakeWorkManager();
-
- @Test public void testQueuing() throws Exception {
- final long SINGLE_WAIT = 50;
- final int WORK_ITEMS = 10;
- final int MAX_THREADS = 5;
-
- final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS, manager); //$NON-NLS-1$
-
- for(int i=0; i<WORK_ITEMS; i++) {
- pool.scheduleWork(new FakeWorkItem(SINGLE_WAIT));
- }
-
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertTrue(pool.isTerminated());
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals(10, stats.getTotalCompleted());
- assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
- }
-
- @Ignore
- @Test public void testThreadReuse() throws Exception {
- final long SINGLE_WAIT = 50;
- final long NUM_THREADS = 5;
-
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
-
- for(int i=0; i<NUM_THREADS; i++) {
- pool.scheduleWork(new FakeWorkItem(SINGLE_WAIT));
-
- try {
- Thread.sleep(SINGLE_WAIT*2);
- } catch(InterruptedException e) {
- }
- }
-
- pool.shutdown();
-
- WorkerPoolStatisticsMetadata stats = pool.getStats();
- assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
-
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
- pool.shutdown();
- pool.scheduleWork(new FakeWorkItem(1));
- }
-
- /*@Test public void testScheduleCancel() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- }
- }, 0, 5, TimeUnit.MILLISECONDS);
- future.cancel(true);
- assertFalse(future.cancel(true));
- }*/
-
- @Test public void testSchedule() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- pool.scheduleWork(new Work() {
-
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- }
-
- @Override
- public void release() {
-
- }
- }, null, 5);
- Thread.sleep(100);
- pool.shutdown();
- pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- assertEquals(1, result.size());
- }
-
- /*(a)Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- ScheduledFuture<?> future = pool.schedule(new Runnable() {
- @Override
- public void run() {
- throw new RuntimeException();
- }
- }, 0, TimeUnit.MILLISECONDS);
- future.get();
- }*/
-
- /**
- * Here each execution exceeds the period
- */
- /*@Test public void testScheduleRepeated() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
- final ArrayList<String> result = new ArrayList<String>();
- ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- result.add("hello"); //$NON-NLS-1$
- try {
- Thread.sleep(75);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }, 0, 10, TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- future.cancel(true);
- assertEquals(2, result.size());
- }*/
-
- @Test public void testFailingWork() throws Exception {
- StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
- final AtomicInteger count = new AtomicInteger();
- pool.scheduleWork(new Work() {
- @Override
- public void run() {
- count.getAndIncrement();
- throw new RuntimeException();
- }
-
- @Override
- public void release() {
-
- }
- });
- Thread.sleep(100);
- assertEquals(1, count.get());
- }
-
-}
Copied: trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java (from rev 2323, trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/common/queue/TestThreadReuseExecutor.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -0,0 +1,226 @@
+/*
+ * 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.common.queue;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.Work;
+
+import org.junit.Test;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.dqp.internal.process.ThreadReuseExecutor;
+import org.teiid.dqp.internal.process.DQPCore.FutureWork;
+
+/**
+ */
+public class TestThreadReuseExecutor {
+
+ @Test public void testQueuing() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final int WORK_ITEMS = 10;
+ final int MAX_THREADS = 5;
+
+ final ThreadReuseExecutor pool = new ThreadReuseExecutor("test", MAX_THREADS); //$NON-NLS-1$
+
+ for(int i=0; i<WORK_ITEMS; i++) {
+ pool.execute(new FakeWorkItem(SINGLE_WAIT));
+ }
+
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertTrue(pool.isTerminated());
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals(10, stats.getTotalCompleted());
+ assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads()); //$NON-NLS-1$
+ }
+
+ @Test public void testThreadReuse() throws Exception {
+ final long SINGLE_WAIT = 50;
+ final long NUM_THREADS = 5;
+
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+
+ for(int i=0; i<NUM_THREADS; i++) {
+ pool.execute(new FakeWorkItem(SINGLE_WAIT));
+
+ try {
+ Thread.sleep(SINGLE_WAIT*2);
+ } catch(InterruptedException e) {
+ }
+ }
+
+ pool.shutdown();
+
+ WorkerPoolStatisticsMetadata stats = pool.getStats();
+ assertEquals("Expected 1 thread for serial execution", 1, stats.getHighestActiveThreads()); //$NON-NLS-1$
+
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ }
+
+ @Test(expected=RejectedExecutionException.class) public void testShutdown() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ pool.shutdown();
+ pool.execute(new FakeWorkItem(1));
+ }
+
+ @Test public void testScheduleCancel() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ }
+ }, 0, 5, TimeUnit.MILLISECONDS);
+ future.cancel(true);
+ assertFalse(future.cancel(true));
+ }
+
+ @Test public void testSchedule() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ pool.schedule(new Work() {
+
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void release() {
+
+ }
+ }, 5, TimeUnit.MILLISECONDS);
+ Thread.sleep(100);
+ pool.shutdown();
+ pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ assertEquals(1, result.size());
+ }
+
+ @Test(expected=ExecutionException.class) public void testScheduleException() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ ScheduledFuture<?> future = pool.schedule(new Runnable() {
+ @Override
+ public void run() {
+ throw new RuntimeException();
+ }
+ }, 0, TimeUnit.MILLISECONDS);
+ future.get();
+ }
+
+ /**
+ * Here each execution exceeds the period
+ */
+ @Test public void testScheduleRepeated() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ final ArrayList<String> result = new ArrayList<String>();
+ ScheduledFuture<?> future = pool.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ result.add("hello"); //$NON-NLS-1$
+ try {
+ Thread.sleep(75);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }, 0, 30, TimeUnit.MILLISECONDS);
+ Thread.sleep(140);
+ future.cancel(true);
+ assertEquals(2, result.size());
+ }
+
+ @Test public void testFailingWork() throws Exception {
+ ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
+ final AtomicInteger count = new AtomicInteger();
+ pool.execute(new Work() {
+ @Override
+ public void run() {
+ count.getAndIncrement();
+ throw new RuntimeException();
+ }
+
+ @Override
+ public void release() {
+
+ }
+ });
+ Thread.sleep(100);
+ assertEquals(1, count.get());
+ }
+
+ @Test public void testPriorities() throws Exception {
+ final ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 1); //$NON-NLS-1$
+ FutureWork<Boolean> work1 = new FutureWork<Boolean>(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ synchronized (pool) {
+ while (pool.getSubmittedCount() < 4) {
+ pool.wait();
+ }
+ }
+ return true;
+ }
+ }, 0);
+ final ConcurrentLinkedQueue<Integer> order = new ConcurrentLinkedQueue<Integer>();
+ FutureWork<Boolean> work2 = new FutureWork<Boolean>(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ order.add(2);
+ return true;
+ }
+ }, 2);
+ FutureWork<Boolean> work3 = new FutureWork<Boolean>(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ order.add(3);
+ return false;
+ }
+ }, 1);
+ FutureWork<Boolean> work4 = new FutureWork<Boolean>(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ order.add(4);
+ return false;
+ }
+ }, 2);
+ pool.execute(work1);
+ pool.execute(work2);
+ pool.execute(work3);
+ pool.execute(work4);
+ synchronized (pool) {
+ pool.notifyAll();
+ }
+ work1.getResult().get();
+ work2.getResult().get();
+ work3.getResult().get();
+ work4.getResult().get();
+ assertEquals(Integer.valueOf(3), order.remove());
+ assertEquals(Integer.valueOf(2), order.remove());
+ assertEquals(Integer.valueOf(4), order.remove());
+ }
+
+}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -28,9 +28,6 @@
import junit.framework.TestCase;
-import org.mockito.Mockito;
-import org.teiid.common.buffer.BlockedException;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.RequestID;
@@ -54,7 +51,6 @@
return c.getConnection();
}
};
- cm.setMaxConnections(1);
cm.start();
return cm;
}
@@ -74,7 +70,7 @@
}
void helpAssureOneState() throws Exception {
- csm.executeRequest(request, Mockito.mock(AbstractWorkItem.class));
+ csm.registerRequest(request);
ConnectorWork state = csm.getState(request.getAtomicRequestID());
assertEquals(state, csm.getState(request.getAtomicRequestID()));
}
@@ -106,34 +102,5 @@
assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
}
-
- public void testQueuing() throws Exception {
- ConnectorWork workItem = csm.executeRequest(request, Mockito.mock(AbstractWorkItem.class));
- workItem.execute();
-
- AbstractWorkItem awi1 = Mockito.mock(AbstractWorkItem.class);
- ConnectorWork workItem1 = csm.executeRequest(TestConnectorWorkItem.createNewAtomicRequestMessage(2, 1), awi1);
-
- AbstractWorkItem awi2 = Mockito.mock(AbstractWorkItem.class);
- ConnectorWork workItem2 = csm.executeRequest(TestConnectorWorkItem.createNewAtomicRequestMessage(3, 1), awi2);
-
- try {
- workItem1.execute();
- fail("expected exception"); //$NON-NLS-1$
- } catch (BlockedException e) {
-
- }
- workItem.close();
-
- try {
- workItem2.execute(); //ensure that another item cannot jump in the queue
- fail("expected exception"); //$NON-NLS-1$
- } catch (BlockedException e) {
-
- }
-
- Mockito.verify(awi1).moreWork();
- workItem1.execute();
- }
-
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -22,8 +22,7 @@
package org.teiid.dqp.internal.datamgr.impl;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.fail;
+import static junit.framework.Assert.*;
import java.util.Arrays;
import java.util.List;
@@ -35,7 +34,6 @@
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
@@ -49,8 +47,8 @@
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.unittest.FakeMetadataFactory;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
public class TestConnectorWorkItem {
@@ -117,8 +115,7 @@
Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
arm.setCommand(command);
- ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, Mockito.mock(AbstractWorkItem.class),
- TestConnectorManager.getConnectorManager());
+ ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager());
return synchConnectorWorkItem.execute();
}
@@ -152,7 +149,7 @@
return Mockito.mock(Xid.class);
}} );
- new ConnectorWorkItem(requestMsg, Mockito.mock(AbstractWorkItem.class), cm);
+ new ConnectorWorkItem(requestMsg, cm);
}
@Ignore
@@ -180,7 +177,7 @@
return Mockito.mock(Xid.class);
}} );
- new ConnectorWorkItem(requestMsg, Mockito.mock(AbstractWorkItem.class), cm);
+ new ConnectorWorkItem(requestMsg, cm);
}
}
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -56,7 +56,6 @@
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
core = new DQPCore();
- core.setWorkManager(new FakeWorkManager());
core.setBufferService(new FakeBufferService());
core.setConnectorManagerRepository(repo);
core.setTransactionService(new FakeTransactionService());
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -23,11 +23,13 @@
package org.teiid.dqp.internal.process;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
+import org.mockito.Mockito;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.client.RequestMessage;
import org.teiid.client.SourceWarning;
@@ -50,12 +52,12 @@
}
private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestMetadata> reqs2) {
- Set reqIDs2 = new HashSet();
+ Set<RequestID> reqIDs2 = new HashSet<RequestID>();
for (RequestMetadata requestInfo : reqs2) {
reqIDs2.add(new RequestID(requestInfo.getSessionId(), requestInfo.getExecutionId()));
}
- assertEquals("Collections of request infos are not the same: ", new HashSet(reqs1), reqIDs2); //$NON-NLS-1$
+ assertEquals("Collections of request infos are not the same: ", new HashSet<RequestID>(reqs1), reqIDs2); //$NON-NLS-1$
}
/**
@@ -63,8 +65,8 @@
*/
public void testGetRequestsSessionToken1() {
DQPCore rm = new DQPCore();
- Set reqs = new HashSet();
- Collection actualReqs = rm.getRequestsForSession(SESSION_STRING);
+ Set<RequestID> reqs = Collections.emptySet();
+ Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(SESSION_STRING);
compareReqInfos(reqs, actualReqs);
}
@@ -74,7 +76,7 @@
public void testGetRequestsSessionToken2() {
DQPCore rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
- Set reqs = new HashSet();
+ Set<RequestID> reqs = new HashSet<RequestID>();
RequestID id = addRequest(rm, SESSION_STRING, 1);
reqs.add(id);
@@ -95,13 +97,13 @@
public void testGetRequestsSessionToken3() {
DQPCore rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
- Set reqs = new HashSet();
+ Set<RequestID> reqs = new HashSet<RequestID>();
reqs.add(addRequest(rm, SESSION_STRING, 0));
reqs.add(addRequest(rm, SESSION_STRING, 1));
reqs.add(addRequest(rm, SESSION_STRING, 2));
- Collection actualReqs = rm.getRequestsForSession(SESSION_STRING);
+ Collection<RequestMetadata> actualReqs = rm.getRequestsForSession(SESSION_STRING);
compareReqInfos(reqs, actualReqs);
}
@@ -158,7 +160,7 @@
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, "connID", workItem); //$NON-NLS-1$
+ DataTierTupleSource info = Mockito.mock(DataTierTupleSource.class);
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
@@ -173,7 +175,7 @@
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null,"connID", workItem); //$NON-NLS-1$
+ DataTierTupleSource info = Mockito.mock(DataTierTupleSource.class);
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
workItem.closeAtomicRequest(atomicReq.getAtomicRequestID());
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.process;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
import org.teiid.core.TeiidException;
@@ -33,6 +34,8 @@
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.dqp.service.FakeBufferService;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.parser.QueryParser;
@@ -40,10 +43,9 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
+import org.teiid.translator.TranslatorException;
-
-
-public class TestDataTierManager extends TestCase {
+public class TestDataTierManager {
private DQPCore rm;
private DataTierManagerImpl dtm;
@@ -54,10 +56,6 @@
private AutoGenDataService connectorManager;
private RequestWorkItem workItem;
- public TestDataTierManager(String name) {
- super(name);
- }
-
private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -75,7 +73,8 @@
connectorManager = new AutoGenDataService();
rm = new DQPCore();
rm.setTransactionService(new FakeTransactionService());
-
+ rm.setBufferService(new FakeBufferService());
+ rm.start(new DQPConfiguration());
FakeBufferService bs = new FakeBufferService();
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
@@ -92,7 +91,7 @@
RequestMessage original = new RequestMessage();
original.setExecutionId(1);
-
+ original.setPartialResults(true);
RequestID requestID = workContext.getRequestID(original.getExecutionId());
context = new CommandContext();
@@ -105,11 +104,13 @@
request = new AtomicRequestMessage(original, workContext, nodeId);
request.setCommand(command);
request.setConnectorName("FakeConnectorID"); //$NON-NLS-1$
-
- info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorName(), workItem);
+ TransactionContext tc = new TransactionContext();
+ tc.setTransactionType(Scope.GLOBAL);
+ request.setTransactionContext(tc);
+ info = new DataTierTupleSource(request, workItem, connectorManager.registerRequest(request), dtm);
}
- public void testDataTierTupleSource() throws Exception {
+ @Test public void testDataTierTupleSource() throws Exception {
helpSetup(1);
info.nextTuple();
assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
@@ -117,7 +118,13 @@
assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
}
- public void testCodeTableResponseException() throws Exception {
+ @Test public void testPartialResults() throws Exception {
+ helpSetup(1);
+ info.exceptionOccurred(new TranslatorException(), true);
+ assertNull(info.nextTuple());
+ }
+
+ @Test public void testCodeTableResponseException() throws Exception {
helpSetup(3);
this.connectorManager.throwExceptionOnExecute = true;
@@ -129,13 +136,13 @@
}
}
- public void testNoRowsException() throws Exception {
+ @Test public void testNoRowsException() throws Exception {
helpSetup(3);
this.connectorManager.setRows(0);
assertNull(info.nextTuple());
}
- public void testCodeTableResponseDataNotAvailable() throws Exception {
+ @Test public void testCodeTableResponseDataNotAvailable() throws Exception {
helpSetup(3);
this.connectorManager.dataNotAvailable = 5;
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -28,11 +28,11 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -68,10 +68,10 @@
}
@Override
- public ConnectorWork executeRequest(AtomicRequestMessage message, AbstractWorkItem awi)
- throws TranslatorException {
+ public ConnectorWork registerRequest(AtomicRequestMessage message)
+ throws TeiidComponentException {
if (throwExceptionOnExecute) {
- throw new TranslatorException("Connector Exception"); //$NON-NLS-1$
+ throw new TeiidComponentException("Connector Exception"); //$NON-NLS-1$
}
List projectedSymbols = (message.getCommand()).getProjectedSymbols();
List[] results = createResults(projectedSymbols);
@@ -105,10 +105,6 @@
}
- @Override
- public boolean isQueued() {
- return false;
- }
};
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -22,46 +22,38 @@
package org.teiid.query.processor.relational;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.junit.Test;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.query.processor.relational.RelationalNode;
-import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
-import junit.framework.TestCase;
-
/**
*/
-public class TestUnionAllNode extends TestCase {
+public class TestUnionAllNode {
- /**
- * Constructor for TestUnionAllNode.
- * @param arg0
- */
- public TestUnionAllNode(String arg0) {
- super(arg0);
- }
-
public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, 2);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
-
+ FakeDataManager fdm = new FakeDataManager();
for(int i=0; i<children.length; i++) {
union.addChild(children[i]);
- children[i].initialize(context, mgr, null);
+ children[i].initialize(context, mgr, fdm);
}
- union.initialize(context, mgr, null);
+ union.initialize(context, mgr, fdm);
union.open();
@@ -90,7 +82,7 @@
assertEquals("Didn't match expected counts", expected.length, currentRow-1); //$NON-NLS-1$
}
- public void testNoRows() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testNoRows() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -151,7 +143,7 @@
helpTestUnion(nodes, union, expected);
}
- public void testBasicUnion() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testBasicUnion() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -164,7 +156,7 @@
}
- public void testBasicUnionMultipleSources() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testBasicUnionMultipleSources() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -181,7 +173,7 @@
helpTestUnionConfigs(5, -1, 2, 50, expected);
}
- public void testMultipleSourcesHalfBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testMultipleSourcesHalfBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(1) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -193,7 +185,7 @@
helpTestUnionConfigs(5, 2, 1, 50, expected);
}
- public void testMultipleSourcesAllBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testMultipleSourcesAllBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(1) }),
@@ -205,7 +197,7 @@
helpTestUnionConfigs(5, 1, 1, 50, expected);
}
- public void testMultipleSourceMultiBatchAllBlocking() throws TeiidComponentException, TeiidProcessingException {
+ @Test public void testMultipleSourceMultiBatchAllBlocking() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(1) }),
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -29,8 +29,6 @@
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
import org.teiid.deployers.VDBStatusChecker;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
/**
* This deployer listens to the data source load and unload events and manages the connectionManager status based
@@ -38,7 +36,6 @@
*/
public class ConnectionFactoryDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> {
- private ConnectorManagerRepository connectorManagerRepository;
private VDBStatusChecker vdbChecker;
public ConnectionFactoryDeployer() {
@@ -52,13 +49,6 @@
for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
this.vdbChecker.dataSourceAdded(data.getJndiName());
-
- // set the number of available connections on the cm
- for (ConnectorManager cm:this.connectorManagerRepository.getConnectorManagers()) {
- if (cm.getConnectionName().equals(data.getJndiName())) {
- cm.setMaxConnections(data.getMaxSize());
- }
- }
}
}
@@ -72,10 +62,6 @@
}
}
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- this.connectorManagerRepository = repo;
- }
-
public void setVDBStatusChecker(VDBStatusChecker checker) {
this.vdbChecker = checker;
}
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-07-08 15:38:23 UTC (rev 2332)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -210,7 +210,6 @@
}
public void setWorkManager(WorkManager mgr) {
- this.dqpCore.setWorkManager(mgr);
this.transactionServerImpl.setWorkManager(mgr);
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-08 15:38:23 UTC (rev 2332)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-07-12 20:59:02 UTC (rev 2333)
@@ -32,7 +32,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
-import org.teiid.common.queue.FakeWorkManager;
import org.teiid.deployers.MetadataStoreGroup;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
@@ -48,7 +47,6 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.services.SessionServiceImpl;
-import org.teiid.translator.TranslatorException;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
import org.teiid.transport.LocalServerConnection;
@@ -70,15 +68,13 @@
this.repo.setSystemStore(systemStore);
this.sessionService.setVDBRepository(repo);
- this.dqp.setWorkManager(new FakeWorkManager());
this.dqp.setBufferService(new FakeBufferService());
this.dqp.setTransactionService(new FakeTransactionService());
ConnectorManagerRepository cmr = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(cmr.getConnectorManager("source")).toReturn(new ConnectorManager("x", "x") {
@Override
- public SourceCapabilities getCapabilities()
- throws TranslatorException {
+ public SourceCapabilities getCapabilities() {
return new BasicSourceCapabilities();
}
});
14 years, 5 months