teiid SVN: r3316 - in branches/7.4.x: engine and 3 other directories.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2011-07-19 09:41:13 -0400 (Tue, 19 Jul 2011)
New Revision: 3316
Modified:
branches/7.4.x/engine/pom.xml
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/DocumentWrapper.java
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/NodeWrapper.java
branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java
branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
branches/7.4.x/pom.xml
Log:
SOA-3162 saxon upgrade - this is a 7.4.x update only, not for upstream at the moment
Modified: branches/7.4.x/engine/pom.xml
===================================================================
--- branches/7.4.x/engine/pom.xml 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/pom.xml 2011-07-19 13:41:13 UTC (rev 3316)
@@ -78,14 +78,8 @@
<dependency>
<groupId>net.sourceforge.saxon</groupId>
- <artifactId>saxon</artifactId>
+ <artifactId>saxonhe</artifactId>
</dependency>
-
- <dependency>
- <groupId>net.sourceforge.saxon</groupId>
- <classifier>dom</classifier>
- <artifactId>saxon</artifactId>
- </dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
@@ -106,4 +100,4 @@
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/DocumentWrapper.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/DocumentWrapper.java 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/DocumentWrapper.java 2011-07-19 13:41:13 UTC (rev 3316)
@@ -115,7 +115,7 @@
* @return the unique number identifying this document within the name pool
*/
- public int getDocumentNumber() {
+ public long getDocumentNumber() {
return documentNumber;
}
@@ -124,12 +124,16 @@
*
* @param id
* the required ID value
+ * @param getParent
+ * true if running the element-with-id() function rather than the id()
+ * function; the difference is that in the case of an element of type xs:ID,
+ * the parent of the element should be returned, not the element itself.
* @return the element with the given ID, or null if there is no such ID
* present (or if the parser has not notified attributes as being of
* type ID).
*/
- public NodeInfo selectID(String id) {
+ public NodeInfo selectID(String id, boolean getParent) {
if (idIndex == null) {
Element elem;
switch (nodeKind) {
@@ -145,7 +149,14 @@
idIndex = new HashMap(50);
buildIDIndex(elem);
}
- return (NodeInfo) idIndex.get(id);
+
+ NodeInfo result = (NodeInfo) idIndex.get(id);
+
+ if (result != null && getParent && result.isId() && result.getStringValue().equals(id)) {
+ result = result.getParent();
+ }
+
+ return result ;
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/NodeWrapper.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/NodeWrapper.java 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/NodeWrapper.java 2011-07-19 13:41:13 UTC (rev 3316)
@@ -160,6 +160,14 @@
}
/**
+ * Get the real XOM node, to implement the VirtualNode interface
+ */
+
+ public Object getRealNode() {
+ return node;
+ }
+
+ /**
* Get the name pool for this node
*
* @return the NamePool
@@ -799,7 +807,7 @@
* free-standing orphan node, just return the hashcode.
*/
- public int getDocumentNumber() {
+ public long getDocumentNumber() {
return docWrapper.getDocumentNumber();
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/xquery/saxon/StreamingUtils.java 2011-07-19 13:41:13 UTC (rev 3316)
@@ -256,6 +256,7 @@
public void close() throws XPathException {
reciever.close();
+ super.close();
}
public void comment(CharSequence content, int locationId, int properties)
@@ -265,6 +266,7 @@
public void endDocument() throws XPathException {
reciever.endDocument();
+ super.endDocument() ;
}
public void endElement() throws XPathException {
@@ -285,6 +287,7 @@
}
public void open() throws XPathException {
+ super.open();
reciever.open();
}
@@ -295,10 +298,12 @@
public void setPipelineConfiguration(PipelineConfiguration config) {
reciever.setPipelineConfiguration(config);
+ super.setPipelineConfiguration(config);
}
public void setSystemId(String systemId) {
reciever.setSystemId(systemId);
+ super.setSystemId(systemId);
}
public void setUnparsedEntity(String name, String systemID,
@@ -311,6 +316,7 @@
}
public void startDocument(int properties) throws XPathException {
+ super.startDocument(properties);
reciever.startDocument(properties);
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/function/TestFunction.java 2011-07-19 13:41:13 UTC (rev 3316)
@@ -1000,9 +1000,10 @@
}
@Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
+ // Moving to June, March fails because of DST
helpTestTimestampDiff(NonReserved.SQL_TSI_DAY,
- TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
- TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 0),
new Long(31));
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2011-07-19 13:41:13 UTC (rev 3316)
@@ -202,8 +202,8 @@
String sql = "select * from xmltable('/a/b' passing convert('<a><b>first</b><b x=\"1\">second</b></a>', xml) columns val xml path '.') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
- Arrays.asList("<b>first</b>"),
- Arrays.asList("<b x=\"1\">second</b>"),
+ Arrays.asList("<b xmlns=\"\">first</b>"),
+ Arrays.asList("<b xmlns=\"\" x=\"1\">second</b>"),
};
process(sql, expected);
@@ -286,7 +286,7 @@
String sql = "select xmlquery('/a/b' passing xmlparse(document '<a><b x=''1''/><b x=''2''/></a>') null on empty)"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
- Arrays.asList("<b x=\"1\"/><b x=\"2\"/>")
+ Arrays.asList("<b xmlns=\"\" x=\"1\"/><b xmlns=\"\" x=\"2\"/>")
};
process(sql, expected);
Modified: branches/7.4.x/pom.xml
===================================================================
--- branches/7.4.x/pom.xml 2011-07-18 14:45:50 UTC (rev 3315)
+++ branches/7.4.x/pom.xml 2011-07-19 13:41:13 UTC (rev 3316)
@@ -439,16 +439,10 @@
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
- <artifactId>saxon</artifactId>
- <version>9.1.0.8</version>
+ <artifactId>saxonhe</artifactId>
+ <version>9.2.1.5</version>
</dependency>
<dependency>
- <groupId>net.sourceforge.saxon</groupId>
- <artifactId>saxon</artifactId>
- <classifier>dom</classifier>
- <version>9.1.0.8</version>
- </dependency>
- <dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.1.Final</version>
@@ -493,4 +487,4 @@
<url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
13 years, 7 months
teiid SVN: r3315 - trunk/connectors/translator-file/src/main/java/org/teiid/translator/file.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-18 10:45:50 -0400 (Mon, 18 Jul 2011)
New Revision: 3315
Modified:
trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
Log:
removing nls warnings
Modified: trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
===================================================================
--- trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2011-07-14 20:20:44 UTC (rev 3314)
+++ trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2011-07-18 14:45:50 UTC (rev 3315)
@@ -206,24 +206,24 @@
@Override
public void getMetadata(MetadataFactory metadataFactory, FileConnection connection) throws TranslatorException {
Procedure p = metadataFactory.addProcedure(GETTEXTFILES);
- p.setAnnotation("Returns text files that match the given path and pattern as CLOBs");
+ p.setAnnotation("Returns text files that match the given path and pattern as CLOBs"); //$NON-NLS-1$
ProcedureParameter param = metadataFactory.addProcedureParameter("pathAndPattern", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
- param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path.");
+ param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path."); //$NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("file", TypeFacility.RUNTIME_NAMES.CLOB, p); //$NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("filePath", TypeFacility.RUNTIME_NAMES.STRING, p); //$NON-NLS-1$
Procedure p1 = metadataFactory.addProcedure(GETFILES);
- p1.setAnnotation("Returns text files that match the given path and pattern as BLOBs");
+ p1.setAnnotation("Returns text files that match the given path and pattern as BLOBs"); //$NON-NLS-1$
param = metadataFactory.addProcedureParameter("pathAndPattern", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p1); //$NON-NLS-1$
- param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path.");
+ param.setAnnotation("The path and pattern of what files to return. Currently the only pattern supported is *.<ext>, which returns only the files matching the given extension at the given path."); //$NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("file", TypeFacility.RUNTIME_NAMES.BLOB, p1); //$NON-NLS-1$
metadataFactory.addProcedureResultSetColumn("filePath", TypeFacility.RUNTIME_NAMES.STRING, p1); //$NON-NLS-1$
Procedure p2 = metadataFactory.addProcedure(SAVEFILE);
- p2.setAnnotation("Saves the given vale to the given path. Any existing file will be overriden.");
+ p2.setAnnotation("Saves the given vale to the given path. Any existing file will be overriden."); //$NON-NLS-1$
metadataFactory.addProcedureParameter("filePath", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p2); //$NON-NLS-1$
param = metadataFactory.addProcedureParameter("file", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p2); //$NON-NLS-1$
- param.setAnnotation("The contents to save. Can be one of CLOB, BLOB, or XML");
+ param.setAnnotation("The contents to save. Can be one of CLOB, BLOB, or XML"); //$NON-NLS-1$
}
@Override
13 years, 7 months
teiid SVN: r3314 - in trunk/engine/src: main/java/org/teiid/query/rewriter and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-14 16:20:44 -0400 (Thu, 14 Jul 2011)
New Revision: 3314
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
Log:
TEIID-1667 preliminary change to simplify expression handling
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-07-14 14:31:30 UTC (rev 3313)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-07-14 20:20:44 UTC (rev 3314)
@@ -126,9 +126,6 @@
for (ElementSymbol elementSymbol : elements) {
if (virtualGroup.equals(elementSymbol.getGroupSymbol())) {
unrelated = true;
- if (!(symbolMap.getMappedExpression(elementSymbol) instanceof ElementSymbol)) {
- return root;
- }
}
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-07-14 14:31:30 UTC (rev 3313)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-07-14 20:20:44 UTC (rev 3314)
@@ -344,7 +344,6 @@
List<OrderByItem> sortCols = ((OrderBy)parentNode.getProperty(NodeConstants.Info.SORT_ORDER)).getOrderByItems();
for (OrderByItem symbol : sortCols) {
- //TODO: this check shouldn't be necessary, since the order by is not introducing new expressions
if(! canPushSymbol(symbol.getSymbol(), true, modelID, metadata, capFinder, record)) {
return false;
}
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-07-14 14:31:30 UTC (rev 3313)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-07-14 20:20:44 UTC (rev 3314)
@@ -903,57 +903,14 @@
LinkedList<OrderByItem> unrelatedItems = new LinkedList<OrderByItem>();
- boolean hasUnrelatedExpression = rewriteOrderBy(queryCommand, orderBy,
- projectedSymbols, unrelatedItems);
+ rewriteOrderBy(queryCommand, orderBy, projectedSymbols, unrelatedItems);
- if (orderBy.getVariableCount() == 0 || !hasUnrelatedExpression) {
- return queryCommand;
- }
-
- int originalSymbolCount = select.getProjectedSymbols().size();
-
- //add unrelated to select
- for (OrderByItem orderByItem : unrelatedItems) {
- select.addSymbol(orderByItem.getSymbol());
- }
- makeSelectUnique(select, false);
-
- Query query = queryCommand.getProjectedQuery();
-
- Into into = query.getInto();
- query.setInto(null);
- Limit limit = query.getLimit();
- query.setLimit(null);
- query.setOrderBy(null);
-
- Query top = null;
-
- try {
- top = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
- Iterator<SingleElementSymbol> iter = top.getSelect().getProjectedSymbols().iterator();
- HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
- for (SingleElementSymbol symbol : select.getProjectedSymbols()) {
- SingleElementSymbol ses = iter.next();
- expressionMap.put(SymbolMap.getExpression(symbol), ses);
- expressionMap.put(new ElementSymbol(symbol.getName()), ses);
- }
- ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
- //now the order by should only contain element symbols
- } catch (TeiidException err) {
- throw new TeiidRuntimeException(err);
- }
- List symbols = top.getSelect().getSymbols();
- top.getSelect().setSymbols(symbols.subList(0, originalSymbolCount));
- top.setInto(into);
- top.setLimit(limit);
- top.setOrderBy(orderBy);
- return top;
+ return queryCommand;
}
- public static boolean rewriteOrderBy(QueryCommand queryCommand,
+ public static void rewriteOrderBy(QueryCommand queryCommand,
final OrderBy orderBy, final List projectedSymbols,
LinkedList<OrderByItem> unrelatedItems) {
- boolean hasUnrelatedExpression = false;
HashSet<Expression> previousExpressions = new HashSet<Expression>();
for (int i = 0; i < orderBy.getVariableCount(); i++) {
SingleElementSymbol querySymbol = orderBy.getVariable(i);
@@ -970,14 +927,11 @@
orderBy.removeOrderByItem(i--);
} else if (!isUnrelated) {
orderBy.getOrderByItems().get(i).setSymbol((SingleElementSymbol)querySymbol.clone());
- } else {
- hasUnrelatedExpression = true;
}
}
if (orderBy.getVariableCount() == 0) {
queryCommand.setOrderBy(null);
}
- return hasUnrelatedExpression;
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java 2011-07-14 14:31:30 UTC (rev 3313)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java 2011-07-14 20:20:44 UTC (rev 3314)
@@ -191,12 +191,4 @@
return this.positional;
}
- /**
- * Should never be called - used for an xml hack
- * @param expression
- */
- public void setExpression(ElementSymbol expression) {
- this.expression = expression;
- }
-
}
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java 2011-07-14 14:31:30 UTC (rev 3313)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java 2011-07-14 20:20:44 UTC (rev 3314)
@@ -305,11 +305,6 @@
new String[] { "pm1.g1.e1" } ); //$NON-NLS-1$
}
- @Test public void testOrderByExpression() throws Exception {
- Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY e2 || e1, e3"); //$NON-NLS-1$
- assertEquals("SELECT X.SOMEINT, X.y FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, (e2 || e1) AS EXPR1, e3 FROM pm1.g1) AS X ORDER BY X.EXPR1, X.e3", resolvedQuery.toString()); //$NON-NLS-1$
- }
-
@Test public void testRewiteOrderBy() {
helpTestRewriteCommand("SELECT 1+1 as a FROM pm1.g1 order by a", "SELECT 2 AS a FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
13 years, 8 months
teiid SVN: r3313 - in branches/7.4.x: cache-jbosscache/src/main/java/org/teiid/cache/jboss and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-07-14 10:31:30 -0400 (Thu, 14 Jul 2011)
New Revision: 3313
Modified:
branches/7.4.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
Log:
TEIID-1493: Replicate the cache contents when node joins the cluster
Modified: branches/7.4.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
===================================================================
--- branches/7.4.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-07-14 14:07:35 UTC (rev 3312)
+++ branches/7.4.x/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-07-14 14:31:30 UTC (rev 3313)
@@ -85,7 +85,7 @@
<!-- Hibernate 2LC can replicate custom types, so we use marshalling -->
<property name="useRegionBasedMarshalling">true</property>
<!-- Must match the value of "useRegionBasedMarshalling" -->
- <property name="inactiveOnStartup">true</property>
+ <property name="inactiveOnStartup">false</property>
<!-- Disable asynchronous RPC marshalling/sending -->
<property name="serializationExecutorPoolSize">0</property>
Modified: branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-07-14 14:07:35 UTC (rev 3312)
+++ branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-07-14 14:31:30 UTC (rev 3313)
@@ -59,6 +59,7 @@
if (!this.cacheStore.getCacheStatus().allowInvocations()) {
this.cacheStore.start();
+ this.cacheStore.getRegion(this.cacheStore.getRoot().getFqn(), true).activate();
}
Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
@@ -67,6 +68,7 @@
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
+ cacheRegion.activate();
JBossCache jc = null;
if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
13 years, 8 months
teiid SVN: r3312 - in branches/as7: jboss-integration/src/main/java/org/teiid/jboss and 4 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-07-14 10:07:35 -0400 (Thu, 14 Jul 2011)
New Revision: 3312
Added:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/SystemVDBService.java
Modified:
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
branches/as7/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
Added System VDB deployment
Modified: branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-07-14 14:07:35 UTC (rev 3312)
@@ -213,6 +213,7 @@
<module identifier="org.apache.aries.jmx" startlevel="2"/>
<module identifier="org.apache.felix.eventadmin" startlevel="2"/>
<module identifier="org.apache.felix.metatype" startlevel="2"/>
+ <module identifier="org.apache.felix.scr" startlevel="2"/>
<module identifier="org.apache.felix.webconsole" startlevel="2"/>
<module identifier="org.jboss.osgi.jmx" startlevel="2"/>
<module identifier="org.jboss.osgi.http" startlevel="2"/>
@@ -244,8 +245,8 @@
</subsystem>
<subsystem xmlns="urn:jboss:domain:teiid:1.0">
<query-engine>
- <thread-group-async>teiid-async</thread-group-async>
- <eventDistributorName>teiid/event-distributor</eventDistributorName>
+ <async-thread-group>teiid-async</async-thread-group>
+ <event-distributor-name>teiid/event-distributor</event-distributor-name>
<security-domain>teiid-security</security-domain>
<jdbc>
<socket-binding>teiid-jdbc</socket-binding>
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Configuration.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -37,30 +37,30 @@
public static final String TRANSLATOR = "translator"; //$NON-NLS-1$
// Query-ENGINE
- public static final String ASYNC_THREAD_GROUP = "thread-group-async";//$NON-NLS-1$
- public static final String MAX_THREADS = "maxThreads";//$NON-NLS-1$
- public static final String MAX_ACTIVE_PLANS = "maxActivePlans";//$NON-NLS-1$
+ public static final String ASYNC_THREAD_GROUP = "async-thread-group";//$NON-NLS-1$
+ public static final String MAX_THREADS = "max-threads";//$NON-NLS-1$
+ public static final String MAX_ACTIVE_PLANS = "max-active-plans";//$NON-NLS-1$
public static final String USER_REQUEST_SOURCE_CONCURRENCY = "userRequestSourceConcurrency";//$NON-NLS-1$
- public static final String TIME_SLICE_IN_MILLI = "timeSliceInMilli";//$NON-NLS-1$
- public static final String MAX_ROWS_FETCH_SIZE = "maxRowsFetchSize";//$NON-NLS-1$
- public static final String LOB_CHUNK_SIZE_IN_KB = "lobChunkSizeInKB";//$NON-NLS-1$
- public static final String USE_DATA_ROLES = "useDataRoles";//$NON-NLS-1$
- public static final String ALLOW_CREATE_TEMPORY_TABLES_BY_DEFAULT = "allowCreateTemporaryTablesByDefault";//$NON-NLS-1$
- public static final String ALLOW_FUNCTION_CALLS_BY_DEFAULT = "allowFunctionCallsByDefault";//$NON-NLS-1$
- public static final String QUERY_THRESHOLD_IN_SECS = "queryThresholdInSecs";//$NON-NLS-1$
- public static final String MAX_SOURCE_ROWS = "maxSourceRows";//$NON-NLS-1$
- public static final String EXCEPTION_ON_MAX_SOURCE_ROWS = "exceptionOnMaxSourceRows";//$NON-NLS-1$
- public static final String MAX_ODBC_LOB_SIZE_ALLOWED = "maxODBCLobSizeAllowed";//$NON-NLS-1$
- public static final String EVENT_DISTRIBUTOR_NAME = "eventDistributorName";//$NON-NLS-1$
- public static final String DETECTING_CHANGE_EVENTS = "detectingChangeEvents";//$NON-NLS-1$
+ public static final String TIME_SLICE_IN_MILLI = "time-slice-in-millseconds";//$NON-NLS-1$
+ public static final String MAX_ROWS_FETCH_SIZE = "max-row-fetch-size";//$NON-NLS-1$
+ public static final String LOB_CHUNK_SIZE_IN_KB = "lob-chunk-size-in-kb";//$NON-NLS-1$
+ public static final String USE_DATA_ROLES = "use-dataroles";//$NON-NLS-1$
+ public static final String ALLOW_CREATE_TEMPORY_TABLES_BY_DEFAULT = "allow-creation-of-temporary-tables";//$NON-NLS-1$
+ public static final String ALLOW_FUNCTION_CALLS_BY_DEFAULT = "allow-function-calls";//$NON-NLS-1$
+ public static final String QUERY_THRESHOLD_IN_SECS = "query-threshold-in-seconds";//$NON-NLS-1$
+ public static final String MAX_SOURCE_ROWS = "max-source-rows-allowed";//$NON-NLS-1$
+ public static final String EXCEPTION_ON_MAX_SOURCE_ROWS = "exception-on-max-source-rows";//$NON-NLS-1$
+ public static final String MAX_ODBC_LOB_SIZE_ALLOWED = "max-odbc-lob-size-allowed";//$NON-NLS-1$
+ public static final String EVENT_DISTRIBUTOR_NAME = "event-distributor-name";//$NON-NLS-1$
+ public static final String DETECTING_CHANGE_EVENTS = "detect-change-events";//$NON-NLS-1$
public static final String SECURITY_DOMAIN = "security-domain";//$NON-NLS-1$
public static final String MAX_SESSIONS_ALLOWED = "max-sessions-allowed";//$NON-NLS-1$
public static final String SESSION_EXPIRATION_TIME_LIMIT = "sessions-expiration-timelimit";//$NON-NLS-1$
public static final String ALLOW_ENV_FUNCTION = "allow-env-function";//$NON-NLS-1$
- public static final String USE_DISK = "useDisk";//$NON-NLS-1$
- public static final String PROCESSOR_BATCH_SIZE = "processorBatchSize";//$NON-NLS-1$
- public static final String CONNECTOR_BATCH_SIZE = "connectorBatchSize";//$NON-NLS-1$
+ public static final String USE_DISK = "use-disk";//$NON-NLS-1$
+ public static final String PROCESSOR_BATCH_SIZE = "processor-batch-size";//$NON-NLS-1$
+ public static final String CONNECTOR_BATCH_SIZE = "connector-batch-size";//$NON-NLS-1$
public static final String MAX_RESERVE_BATCH_COLUMNS = "maxReserveBatchColumns";//$NON-NLS-1$
public static final String MAX_PROCESSING_BATCH_COLUMNS = "maxProcessingBatchesColumns";//$NON-NLS-1$
public static final String MAX_FILE_SIZE = "maxFileSize";//$NON-NLS-1$
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -45,6 +45,7 @@
import org.jboss.dmr.ModelNode;
import org.jboss.msc.inject.ConcurrentMapInjector;
import org.jboss.msc.service.*;
+import org.jboss.msc.value.InjectedValue;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
import org.teiid.cache.DefaultCacheFactory;
@@ -78,6 +79,11 @@
final VDBRepository vdbRepo = buildVDBRepository(queryEngineNode);
final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
+ SystemVDBDeployer systemVDB = new SystemVDBDeployer();
+ systemVDB.setVDBRepository(vdbRepo);
+ SystemVDBService systemVDBService = new SystemVDBService(systemVDB);
+ newControllers.add(target.addService(TeiidServiceNames.SYSTEM_VDB, systemVDBService).install());
+
//FIXME *******************
final ObjectSerializer serializer = new ObjectSerializer("/tmp");
//FIXME *******************
@@ -86,7 +92,7 @@
TranslatorRepositoryService translatorService = new TranslatorRepositoryService(translatorRepo);
newControllers.add(target.addService(TeiidServiceNames.TRANSLATOR_REPO, translatorService).install());
- RelativePathService.addService(TeiidServiceNames.BUFFER_DIR, "teiid-buffer", "jboss.server.temp.dir", target); //$NON-NLS-1$ //$NON-NLS-2$
+ newControllers.add(RelativePathService.addService(TeiidServiceNames.BUFFER_DIR, "teiid-buffer", "jboss.server.temp.dir", target)); //$NON-NLS-1$ //$NON-NLS-2$
// TODO: remove verbose service by moving the buffer service from runtime project
final BufferServiceImpl bufferManager = buildBufferManager(queryEngineNode.get(Configuration.BUFFER_SERVICE));
@@ -133,7 +139,8 @@
serviceBuilder.addDependency(ServiceName.JBOSS.append("txn", "TransactionManager"), TransactionManager.class, engine.txnManagerInjector); //$NON-NLS-1$ //$NON-NLS-2$
serviceBuilder.addDependency(ServiceName.JBOSS.append("thread", "executor", asyncExecutor), Executor.class, engine.threadPoolInjector); //$NON-NLS-1$ //$NON-NLS-2$
serviceBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, engine.bufferServiceInjector);
-
+ serviceBuilder.addDependency(TeiidServiceNames.SYSTEM_VDB, SystemVDBDeployer.class, new InjectedValue<SystemVDBDeployer>());
+
if (jdbc != null) {
serviceBuilder.addDependency(ServiceName.JBOSS.append("binding", jdbc.getSocketBinding()), SocketBinding.class, engine.jdbcSocketBindingInjector); //$NON-NLS-1$
}
Added: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/SystemVDBService.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/SystemVDBService.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/SystemVDBService.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -0,0 +1,52 @@
+/*
+ * 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.jboss;
+
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.teiid.deployers.SystemVDBDeployer;
+
+public class SystemVDBService implements Service<SystemVDBDeployer> {
+ private SystemVDBDeployer deployer;
+
+ public SystemVDBService(SystemVDBDeployer deployer){
+ this.deployer = deployer;
+ }
+
+ @Override
+ public void start(StartContext context) throws StartException {
+ deployer.start();
+ }
+
+ @Override
+ public void stop(StopContext context) {
+ deployer.stop();
+ }
+
+ @Override
+ public SystemVDBDeployer getValue() throws IllegalStateException, IllegalArgumentException {
+ return deployer;
+ }
+
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/SystemVDBService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -29,6 +29,7 @@
static ServiceName TRANSLATOR_BASE = ServiceName.JBOSS.append("teiid", "translator");
public static ServiceName BUFFER_DIR = ServiceName.JBOSS.append("teiid", "buffer.dir");
public static ServiceName BUFFER_MGR = ServiceName.JBOSS.append("teiid", "buffer-mgr");
+ public static ServiceName SYSTEM_VDB = ServiceName.JBOSS.append("teiid", "system.vdb");
public static ServiceName translatorServiceName(String name) {
return TRANSLATOR_BASE.append(name);
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -45,25 +45,137 @@
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
- writer.writeStartElement(Configuration.QUERY_ENGINE);
-
ModelNode node = context.getModelNode();
- ModelNode teiidRuntime = node.require(Configuration.QUERY_ENGINE);
- //writeElement(writer, Element.batchSize, teiidRuntime.require("batch-size"));
-
- //writer.writeEndElement(); // End teiid-runtime element.
+ if (!node.isDefined()) {
+ return;
+ }
+ writer.writeStartElement(Element.QUERY_ENGINE_ELEMENT.getLocalName());
+ writeQueryEngine(writer, node);
+ writer.writeEndElement();
writer.writeEndElement(); // End of subsystem element
}
- private boolean has(ModelNode node, String name) {
+ // write the elements according to the schema defined.
+ private void writeQueryEngine( XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.ASYNC_THREAD_GROUP_ELEMENT, node);
+ writeElement(writer, Element.MAX_THREADS_ELEMENT, node);
+ writeElement(writer, Element.MAX_ACTIVE_PLANS_ELEMENT, node);
+ writeElement(writer, Element.USER_REQUEST_SOURCE_CONCURRENCY_ELEMENT, node);
+ writeElement(writer, Element.TIME_SLICE_IN_MILLI_ELEMENT, node);
+ writeElement(writer, Element.MAX_ROWS_FETCH_SIZE_ELEMENT, node);
+ writeElement(writer, Element.LOB_CHUNK_SIZE_IN_KB_ELEMENT, node);
+ writeElement(writer, Element.USE_DATA_ROLES_ELEMENT, node);
+ writeElement(writer, Element.ALLOW_CREATE_TEMPORY_TABLES_BY_DEFAULT_ELEMENT, node);
+ writeElement(writer, Element.ALLOW_FUNCTION_CALLS_BY_DEFAULT_ELEMENT, node);
+ writeElement(writer, Element.QUERY_THRESHOLD_IN_SECS_ELEMENT, node);
+ writeElement(writer, Element.MAX_SOURCE_ROWS_ELEMENT, node);
+ writeElement(writer, Element.EXCEPTION_ON_MAX_SOURCE_ROWS_ELEMENT, node);
+ writeElement(writer, Element.MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT, node);
+ writeElement(writer, Element.EVENT_DISTRIBUTOR_NAME_ELEMENT, node);
+ writeElement(writer, Element.DETECTING_CHANGE_EVENTS_ELEMENT, node);
+ writeElement(writer, Element.JDBC_SECURITY_DOMAIN_ELEMENT, node);
+ writeElement(writer, Element.MAX_SESSIONS_ALLOWED_ELEMENT, node);
+ writeElement(writer, Element.SESSION_EXPIRATION_TIME_LIMIT_ELEMENT, node);
+ writeElement(writer, Element.ALLOW_ENV_FUNCTION_ELEMENT, node);
+
+ if (has(node, Element.BUFFER_SERVICE_ELEMENT.getLocalName())){
+ writer.writeStartElement(Element.BUFFER_SERVICE_ELEMENT.getLocalName());
+ writeBufferService(writer, node.get(Element.BUFFER_SERVICE_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+
+ if (has(node, Element.CACHE_FACORY_ELEMENT.getLocalName())){
+ writer.writeStartElement(Element.CACHE_FACORY_ELEMENT.getLocalName());
+ writeCacheFactoryConfiguration(writer, node.get(Element.CACHE_FACORY_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+
+ if (has(node, Element.RESULTSET_CACHE_ELEMENT.getLocalName())){
+ writer.writeStartElement(Element.RESULTSET_CACHE_ELEMENT.getLocalName());
+ writeCacheConfiguration(writer, node.get(Element.RESULTSET_CACHE_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+
+ if (has(node, Element.PREPAREDPLAN_CACHE_ELEMENT.getLocalName())){
+ writer.writeStartElement(Element.RESULTSET_CACHE_ELEMENT.getLocalName());
+ writeCacheConfiguration(writer, node.get(Element.PREPAREDPLAN_CACHE_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+
+ //jdbc
+ if (has(node, Element.JDBC_ELEMENT.getLocalName())){
+ writer.writeStartElement(Element.JDBC_ELEMENT.getLocalName());
+ writeSocketConfiguration(writer, node.get(Element.JDBC_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+
+ //odbc
+ if (has(node, Element.ODBC_ELEMENT.getLocalName())) {
+ writer.writeStartElement(Element.ODBC_ELEMENT.getLocalName());
+ writeSocketConfiguration(writer, node.get(Element.ODBC_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+ }
+
+ private void writeSocketConfiguration(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.MAX_SOCKET_SIZE_ELEMENT, node);
+ writeElement(writer, Element.IN_BUFFER_SIZE_ELEMENT, node);
+ writeElement(writer, Element.OUT_BUFFER_SIZE_ELEMENT, node);
+ writeElement(writer, Element.SOCKET_BINDING_ELEMENT, node);
+
+ if (has(node, Element.SSL_ELEMENT.getLocalName())) {
+ writer.writeStartElement(Element.SSL_ELEMENT.getLocalName());
+ writeSSLConfiguration(writer, node.get(Element.SSL_ELEMENT.getLocalName()));
+ writer.writeEndElement();
+ }
+ }
+
+ private void writeSSLConfiguration(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.SSL_MODE_ELEMENT, node);
+ writeElement(writer, Element.KEY_STORE_FILE_ELEMENT, node);
+ writeElement(writer, Element.KEY_STORE_PASSWD_ELEMENT, node);
+ writeElement(writer, Element.KEY_STORE_TYPE_ELEMENT, node);
+ writeElement(writer, Element.SSL_PROTOCOL_ELEMENT, node);
+ writeElement(writer, Element.TRUST_FILE_ELEMENT, node);
+ writeElement(writer, Element.TRUST_PASSWD_ELEMENT, node);
+ writeElement(writer, Element.AUTH_MODE_ELEMENT, node);
+ writeElement(writer, Element.KEY_MANAGEMENT_ALG_ELEMENT, node);
+ }
+
+ private void writeBufferService(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.USE_DISK_ELEMENT, node);
+ writeElement(writer, Element.PROCESSOR_BATCH_SIZE_ELEMENT, node);
+ writeElement(writer, Element.CONNECTOR_BATCH_SIZE_ELEMENT, node);
+ writeElement(writer, Element.MAX_RESERVE_BATCH_COLUMNS_ELEMENT, node);
+ writeElement(writer, Element.MAX_PROCESSING_BATCH_COLUMNS_ELEMENT, node);
+ writeElement(writer, Element.MAX_FILE_SIZE_ELEMENT, node);
+ writeElement(writer, Element.MAX_BUFFER_SPACE_ELEMENT, node);
+ writeElement(writer, Element.MAX_OPEN_FILES_ELEMENT, node);
+ }
+
+ private void writeCacheFactoryConfiguration(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.CACHE_SERVICE_JNDI_NAME_ELEMENT, node);
+ writeElement(writer, Element.RESULTSET_CACHE_NAME_ELEMENT, node);
+ }
+
+ private void writeCacheConfiguration(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
+ writeElement(writer, Element.MAX_ENTRIES_ELEMENT, node);
+ writeElement(writer, Element.MAX_AGE_IN_SECS_ELEMENT, node);
+ writeElement(writer, Element.MAX_STALENESS_ELEMENT, node);
+ writeElement(writer, Element.CACHE_TYPE_ELEMENT, node);
+ writeElement(writer, Element.CACHE_LOCATION_ELEMENT, node);
+ }
+
+ private boolean has(ModelNode node, String name) {
return node.has(name) && node.get(name).isDefined();
}
- private void writeElement(final XMLExtendedStreamWriter writer, final Element element, final ModelNode value)
- throws XMLStreamException {
- writer.writeStartElement(element.getLocalName());
- writer.writeCharacters(value.asString());
- writer.writeEndElement();
+ private void writeElement(final XMLExtendedStreamWriter writer, final Element element, final ModelNode node) throws XMLStreamException {
+ if (has(node, element.getLocalName())) {
+ writer.writeStartElement(element.getLocalName());
+ writer.writeCharacters(node.get(element.getLocalName()).asString());
+ writer.writeEndElement();
+ }
}
@Override
@@ -88,12 +200,6 @@
switch (element) {
case QUERY_ENGINE_ELEMENT:
ModelNode node = parseQueryEngine(reader);
-// node.get(OP).set(ADD);
-// ModelNode nodeAddress = address.clone();
-// nodeAddress.add(Configuration.QUERY_ENGINE, "teiid-query-engine"); // should this be for each instance name? // //$NON-NLS-1$
-// nodeAddress.protect();
-// node.get(OP_ADDR).set(nodeAddress);
-// list.add(node);
subsystem.get(Configuration.QUERY_ENGINE).set(node);
break;
default:
Modified: branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-07-14 14:07:35 UTC (rev 3312)
@@ -1,12 +1,5 @@
{
"attributes" => {
- "jndi-name" => {
- "type" => STRING,
- "description" => "JNDI name of the Teiid Query Engine",
- "required" => true,
- "max-occurs" => 1,
- "default" => "teiid/engine-deployer"
- },
"thread-group-async" => {
"type" => STRING,
"description" => "Thread Pool to be used with Asynchronous operations in Teiid",
Modified: branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-07-14 14:07:35 UTC (rev 3312)
@@ -1,5 +1,5 @@
<subsystem xmlns="urn:jboss:domain:teiid:1.0">
- <query-engine jndi-name="teiid/engine-deployer">
+ <query-engine>
<thread-group-async>teiid-async</thread-group-async>
<maxThreads>64</maxThreads>
<maxActivePlans>20</maxActivePlans>
Modified: branches/as7/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- branches/as7/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -24,10 +24,8 @@
import java.io.IOException;
import java.net.URISyntaxException;
-import java.net.URL;
import java.util.*;
-import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -71,8 +69,7 @@
* @throws IOException
* @throws URISyntaxException
*/
- public IndexMetadataFactory(URL url) throws IOException, URISyntaxException {
- VirtualFile vdb = VFS.getChild(url.toURI());
+ public IndexMetadataFactory(VirtualFile vdb) throws IOException, URISyntaxException {
List<VirtualFile> children = vdb.getChildrenRecursively(new VirtualFileFilter() {
@Override
public boolean accepts(VirtualFile file) {
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -21,11 +21,15 @@
*/
package org.teiid.deployers;
+import java.io.Closeable;
import java.io.IOException;
-import java.net.URI;
+import java.io.InputStream;
import java.net.URISyntaxException;
-import java.net.URL;
+import org.jboss.as.server.deployment.module.TempFileProviderService;
+import org.jboss.modules.Module;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.metadata.index.IndexMetadataFactory;
@@ -35,17 +39,21 @@
public class SystemVDBDeployer {
private VDBRepository vdbRepository;
-
+ private Closeable file;
public void start() {
try {
- URL url = Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB);
- if (url == null) {
- throw new TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found")); //$NON-NLS-1$
+ VirtualFile mountPoint = VFS.getChild("content/" + CoreConstants.SYSTEM_VDB); //$NON-NLS-1$
+ if (!mountPoint.exists()) {
+ InputStream contents = Module.getCallerModule().getClassLoader().findResourceAsStream(CoreConstants.SYSTEM_VDB, false);
+ if (contents == null) {
+ throw new TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found")); //$NON-NLS-1$
+ }
+ this.file = VFS.mountZip(contents, CoreConstants.SYSTEM_VDB, mountPoint, TempFileProviderService.provider());
}
+
// uri conversion is only to remove the spaces in URL, note this only with above kind situation
- URI uri = new URI(url.getProtocol(), url.getPath(), null);
- this.vdbRepository.setSystemStore(new IndexMetadataFactory(uri.toURL()).getMetadataStore(null));
+ this.vdbRepository.setSystemStore(new IndexMetadataFactory(mountPoint).getMetadataStore(null));
} catch (URISyntaxException e) {
throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("system_vdb_load_error")); //$NON-NLS-1$
} catch (IOException e) {
@@ -57,4 +65,13 @@
this.vdbRepository = repo;
}
+ public void stop() {
+ try {
+ if (file != null) {
+ file.close();
+ }
+ } catch (IOException e) {
+ //ignore
+ }
+ }
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -261,6 +261,9 @@
@Override
public void undeploy(final DeploymentUnit deploymentUnit) {
+ if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
+ return;
+ }
VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
VirtualFile file = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
Modified: branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-13 20:34:20 UTC (rev 3311)
+++ branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-14 14:07:35 UTC (rev 3312)
@@ -22,17 +22,17 @@
package org.teiid.jdbc;
-import static org.junit.Assert.*;
+import static org.junit.Assert.fail;
import java.lang.Thread.UncaughtExceptionHandler;
import java.sql.Connection;
import java.sql.Statement;
import java.util.LinkedHashMap;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
-import org.jboss.netty.handler.timeout.TimeoutException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -62,7 +62,7 @@
static Condition waiting = lock.newCondition();
static Condition wait = lock.newCondition();
- public static int blocking() throws InterruptedException {
+ public static int blocking() throws InterruptedException, TimeoutException {
lock.lock();
try {
waiting.signal();
13 years, 8 months
teiid SVN: r3311 - in trunk/engine/src/main/java/org/teiid: query/parser and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-13 16:34:20 -0400 (Wed, 13 Jul 2011)
New Revision: 3311
Modified:
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java
trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
Log:
TEIID-1655 refining parsing error messages
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java 2011-07-13 19:58:48 UTC (rev 3310)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java 2011-07-13 20:34:20 UTC (rev 3311)
@@ -22,12 +22,16 @@
package org.teiid.api.exception.query;
+import org.teiid.query.parser.ParseException;
+
/**
* Thrown when a query cannot be parsed. This is most likely due to not
* following the Query Parser grammar, which defines how queries are parsed.
*/
public class QueryParserException extends QueryProcessingException {
+
+ private ParseException parseException;
/**
* No-arg constructor required by Externalizable semantics.
@@ -76,4 +80,12 @@
public QueryParserException( Throwable e, String code, String message ) {
super( e, code, message );
}
+
+ public ParseException getParseException() {
+ return parseException;
+ }
+
+ public void setParseException(ParseException parseException) {
+ this.parseException = parseException;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2011-07-13 19:58:48 UTC (rev 3310)
+++ trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2011-07-13 20:34:20 UTC (rev 3311)
@@ -23,6 +23,11 @@
package org.teiid.query.parser;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.query.QueryPlugin;
@@ -186,8 +191,83 @@
}
private QueryParserException convertParserException(ParseException pe) {
- return new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", pe.getMessage())); //$NON-NLS-1$
+ QueryParserException qpe = new QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError", getMessage(pe, 1, 10))); //$NON-NLS-1$
+ qpe.setParseException(pe);
+ if (pe.currentToken == null) {
+ pe.currentToken = parser.token;
+ }
+ return qpe;
}
+
+ public static String getMessage(ParseException pe, int maxTokenSequence, int maxExpansions) {
+ if (!pe.specialConstructor) {
+ return pe.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int[][] expectedTokenSequences = pe.expectedTokenSequences;
+ String[] tokenImage = pe.tokenImage;
+ String eol = pe.eol;
+ Token currentToken = pe.currentToken;
+ HashSet<List<Integer>> expansions = new HashSet<List<Integer>>();
+ Arrays.sort(expectedTokenSequences, new Comparator<int[]>() {
+ @Override
+ public int compare(int[] o1, int[] o2) {
+ return o2.length - o1.length;
+ }
+ });
+ int maxSize = expectedTokenSequences[0].length;
+ StringBuilder retval = new StringBuilder("Encountered \""); //$NON-NLS-1$
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0)
+ retval.append(" "); //$NON-NLS-1$
+ if (tok.kind == 0) {
+ retval.append(tokenImage[0]);
+ break;
+ }
+ retval.append(pe.add_escapes(tok.image));
+ tok = tok.next;
+ }
+ retval.append("\" at line " + currentToken.next.beginLine + ", column " //$NON-NLS-1$ //$NON-NLS-2$
+ + currentToken.next.beginColumn);
+ retval.append("." + eol); //$NON-NLS-1$
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ boolean truncateStart = expectedTokenSequences[i].length == maxSize && maxSize > 1 && maxSize > maxTokenSequence;
+ int start = 0;
+ if (truncateStart) {
+ start = expectedTokenSequences[i].length - maxTokenSequence;
+ }
+ List<Integer> expansion = new ArrayList<Integer>(Math.min(maxTokenSequence, expectedTokenSequences[i].length));
+ for (int j = start; j < start+maxTokenSequence; j++) {
+ expansion.add(expectedTokenSequences[i][j]);
+ }
+ if (!expansions.add(expansion) || (!truncateStart && expectedTokenSequences[i][start] == currentToken.next.kind)) {
+ continue;
+ }
+ if (expansions.size() > maxExpansions) {
+ expected.append("...").append(eol).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ if (truncateStart) {
+ expected.append("... "); //$NON-NLS-1$
+ }
+ for (int j = start; j < expectedTokenSequences[i].length && j < start+maxTokenSequence; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]])
+ .append(" "); //$NON-NLS-1$
+ }
+ if (expectedTokenSequences[i][Math.min(maxTokenSequence, expectedTokenSequences[i].length - 1)] != 0) {
+ expected.append("..."); //$NON-NLS-1$
+ }
+ expected.append(eol).append(" "); //$NON-NLS-1$
+ }
+ if (expansions.size() == 1) {
+ retval.append("Was expecting:" + eol + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ retval.append("Was expecting one of:" + eol + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ retval.append(expected.toString());
+ return retval.toString();
+ }
/**
* Takes a SQL string representing an SQL expression
13 years, 8 months
teiid SVN: r3310 - in branches/7.4.x: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-13 15:58:48 -0400 (Wed, 13 Jul 2011)
New Revision: 3310
Modified:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.4.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-1664 removing unnecessary implicit conversions and reverting teradata convert removal
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-07-13 19:58:48 UTC (rev 3310)
@@ -115,21 +115,12 @@
convert.addNumericBooleanConversions();
registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstrModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new StringOnlyModifier("LOWER", this.convert)); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new StringOnlyModifier("UPPER", this.convert)); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LENGTH, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
- target.add("character_length("); //$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- });
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("LOWER")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("UPPER")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new AliasModifier("character_length")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
@@ -151,9 +142,9 @@
registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
+ ArrayList<Object> target = new ArrayList<Object>();
target.add("TRIM(LEADING FROM ");//$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(function.getParameters().get(0));
target.add(")"); //$NON-NLS-1$
return target;
}
@@ -161,9 +152,9 @@
registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
+ ArrayList<Object> target = new ArrayList<Object>();
target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(function.getParameters().get(0));
target.add(")"); //$NON-NLS-1$
return target;
}
@@ -199,7 +190,7 @@
@Override
- public List getSupportedFunctions() {
+ public List<String> getSupportedFunctions() {
List<String> supportedFunctions = new ArrayList<String>();
supportedFunctions.addAll(super.getSupportedFunctions());
@@ -342,67 +333,31 @@
@Override
public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
+ ArrayList<Object> target = new ArrayList<Object>();
Expression expr1 = function.getParameters().get(0);
Expression expr2 = function.getParameters().get(1);
if (function.getParameters().size() > 2) {
Expression expr3 = function.getParameters().get(2);
target.add("position("); //$NON-NLS-1$
- target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add(expr1);
target.add( " in "); //$NON-NLS-1$
target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(expr2);
target.add(","); //$NON-NLS-1$
target.add(expr3);
target.add("))"); //$NON-NLS-1$
}
else {
target.add("position("); //$NON-NLS-1$
- target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add(expr1);
target.add( " in "); //$NON-NLS-1$
- target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(expr2);
target.add(")"); //$NON-NLS-1$
}
return target;
}
}
- private static List<?> expressionToString(Expression expr, ConvertModifier modifier) {
- Class tgtType = expr.getType();
- if (tgtType.equals(String.class) && ((expr instanceof Literal) || expr instanceof ColumnReference)) {
- return Arrays.asList(expr);
- }
- else if (tgtType.equals(String.class) && (expr instanceof Function)) {
-
- Function func = (Function)expr;
- while(true) {
- Expression arg1 = func.getParameters().get(0);
- if ((arg1 instanceof Function) && ((Function)arg1).getName().equals("convert")) { //$NON-NLS-1$
- func = (Function)arg1;
- }
- else {
- break;
- }
- }
- Expression arg1 = func.getParameters().get(0);
- if (arg1 instanceof ColumnReference) {
- ColumnReference ref = (ColumnReference)func.getParameters().get(0);
- if(Number.class.isAssignableFrom(ref.getType())) {
- ArrayList target = new ArrayList();
- target.add("cast("); //$NON-NLS-1$
- target.add(func.getParameters().get(0));
- target.add(" AS varchar(100))"); //$NON-NLS-1$
- return target;
- }
- else if (String.class.isAssignableFrom(ref.getType())) {
- return Arrays.asList(ref);
- }
- }
- return modifier.translate(func);
- }
- return Arrays.asList("cast(" , expr, " AS varchar(100))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
public static class ExtractModifier extends FunctionModifier {
private String type;
public ExtractModifier(String type) {
@@ -425,47 +380,6 @@
}
}
- public static class StringOnlyModifier extends FunctionModifier {
- String funcName;
- ConvertModifier convertModifier;
- public StringOnlyModifier(String name, ConvertModifier converModifier) {
- this.funcName = name;
- this.convertModifier = converModifier;
- }
- @Override
- public List<?> translate(Function function) {
- Expression expr = function.getParameters().get(0);
- ArrayList target = new ArrayList();
- target.add(this.funcName);
- target.add("("); //$NON-NLS-1$
- target.addAll(expressionToString(expr, this.convertModifier));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- }
-
- public static class SubstrModifier extends FunctionModifier {
- ConvertModifier convertModifier;
- public SubstrModifier(ConvertModifier converModifier) {
- this.convertModifier = converModifier;
- }
- @Override
- public List<?> translate(Function function) {
- Expression expr = function.getParameters().get(0);
- ArrayList target = new ArrayList();
- target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(expr, this.convertModifier));
- target.add(","); //$NON-NLS-1$
- target.add(function.getParameters().get(1));
- if (function.getParameters().size() > 2 ) {
- target.add(","); //$NON-NLS-1$
- target.add(function.getParameters().get(2));
- }
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- }
-
public static class LeftOrRightFunctionModifier extends FunctionModifier {
private LanguageFactory langFactory;
ConvertModifier convertModifier;
@@ -478,11 +392,11 @@
@Override
public List<?> translate(Function function) {
List<Expression> args = function.getParameters();
- ArrayList target = new ArrayList();
+ ArrayList<Object> target = new ArrayList<Object>();
if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
//substr(string, 1, length)
target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(args.get(0));
target.add(","); //$NON-NLS-1$
target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
target.add(","); //$NON-NLS-1$
@@ -491,10 +405,10 @@
} else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
//substr(case_size, character_length(case_size) -4)
target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(args.get(0));
target.add(",(character_length("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(args.get(0));
target.add(")-"); //$NON-NLS-1$
target.add(args.get(1));
target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
Modified: branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-07-13 19:58:48 UTC (rev 3310)
@@ -84,19 +84,19 @@
@Test public void testIntegerToString() throws Exception {
String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
- String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100))) FROM SmallA";
+ String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(4000))) FROM SmallA";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test public void testSubString() throws Exception {
String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1) = '1' ORDER BY intkey";
- String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1) = '1' ORDER BY 1";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(4000)), 1) = '1' ORDER BY 1";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test public void testSubString2() throws Exception {
String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1, 2) = '1' ORDER BY intkey";
- String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1,2) = '1' ORDER BY 1";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(4000)), 1, 2) = '1' ORDER BY 1";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@@ -108,7 +108,7 @@
@Test public void testLocate() throws Exception {
String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
- String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY 1";
+ String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(4000))) = 1 ORDER BY 1";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@@ -222,13 +222,13 @@
@Test public void testRightFunction() throws Exception {
String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2) <> 0 ORDER BY INTKEY";
- String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS varchar(100)))-2+1)) <> '0' ORDER BY 1";
+ String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(4000)),(character_length(cast(SmallA.FloatNum AS varchar(4000)))-2+1)) <> '0' ORDER BY 1";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
}
@Test public void testLocateFunction() throws Exception {
String input = "SELECT INTKEY, STRINGKEY, SHORTVALUE FROM BQT1.SmallA WHERE (LOCATE(0, STRINGKEY) = 2) OR (LOCATE(2, SHORTVALUE, 4) = 6) ORDER BY intkey";
- String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(100)),4)) = 6 ORDER BY 1";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(4000)),4)) = 6 ORDER BY 1";
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
}
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-07-13 19:58:48 UTC (rev 3310)
@@ -37,7 +37,6 @@
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.Assertion;
import org.teiid.query.QueryPlugin;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -49,17 +48,21 @@
import org.teiid.query.resolver.util.AccessPattern;
import org.teiid.query.resolver.util.ResolverUtil;
import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompoundCriteria;
import org.teiid.query.sql.lang.Criteria;
import org.teiid.query.sql.lang.GroupBy;
import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.AliasSymbol;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
@@ -124,15 +127,15 @@
}
static boolean canConvertAccessPatterns(PlanNode sourceNode) {
- List accessPatterns = (List)sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
+ List<AccessPattern> accessPatterns = (List)sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
if (accessPatterns == null) {
return true;
}
SymbolMap symbolMap = (SymbolMap)sourceNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
- for (Iterator i = accessPatterns.iterator(); i.hasNext();) {
- AccessPattern ap = (AccessPattern)i.next();
- for (Iterator elems = ap.getUnsatisfied().iterator(); elems.hasNext();) {
- ElementSymbol symbol = (ElementSymbol)elems.next();
+ for (Iterator<AccessPattern> i = accessPatterns.iterator(); i.hasNext();) {
+ AccessPattern ap = i.next();
+ for (Iterator<ElementSymbol> elems = ap.getUnsatisfied().iterator(); elems.hasNext();) {
+ ElementSymbol symbol = elems.next();
Expression mapped = convertExpression(symbol, symbolMap.asMap());
if (ElementCollectorVisitor.getElements(mapped, true).isEmpty()) {
return false;
@@ -153,15 +156,15 @@
if (accessPatterns != null) {
for (AccessPattern ap : accessPatterns) {
Set<ElementSymbol> newElements = new HashSet<ElementSymbol>();
- for (Iterator elems = ap.getUnsatisfied().iterator(); elems.hasNext();) {
- ElementSymbol symbol = (ElementSymbol)elems.next();
+ for (Iterator<ElementSymbol> elems = ap.getUnsatisfied().iterator(); elems.hasNext();) {
+ ElementSymbol symbol = elems.next();
Expression mapped = convertExpression(symbol, symbolMap);
newElements.addAll(ElementCollectorVisitor.getElements(mapped, true));
}
ap.setUnsatisfied(newElements);
Set<ElementSymbol> newHistory = new HashSet<ElementSymbol>();
- for (Iterator elems = ap.getCurrentElements().iterator(); elems.hasNext();) {
- ElementSymbol symbol = (ElementSymbol)elems.next();
+ for (Iterator<ElementSymbol> elems = ap.getCurrentElements().iterator(); elems.hasNext();) {
+ ElementSymbol symbol = elems.next();
Expression mapped = convertExpression(symbol, symbolMap);
newHistory.addAll(ElementCollectorVisitor.getElements(mapped, true));
}
@@ -228,6 +231,11 @@
List<SingleElementSymbol> projectedSymbols = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.PROJECT_COLS);
Select select = new Select(projectedSymbols);
ExpressionMappingVisitor.mapExpressions(select, symbolMap);
+ if (rewrite) {
+ for (LanguageObject expr : select.getSymbols()) {
+ rewriteSingleElementSymbol(metadata, (SingleElementSymbol) expr);
+ }
+ }
node.setProperty(NodeConstants.Info.PROJECT_COLS, select.getSymbols());
if (!singleMapping) {
GroupsUsedByElementsVisitor.getGroups(select, groups);
@@ -252,6 +260,11 @@
} else if(type == NodeConstants.Types.SORT) {
OrderBy orderBy = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
ExpressionMappingVisitor.mapExpressions(orderBy, symbolMap);
+ if (rewrite) {
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ rewriteSingleElementSymbol(metadata, item.getSymbol());
+ }
+ }
if (!singleMapping) {
GroupsUsedByElementsVisitor.getGroups(orderBy, groups);
}
@@ -269,6 +282,25 @@
convertAccessPatterns(symbolMap, node);
}
}
+
+ private static void rewriteSingleElementSymbol(
+ QueryMetadataInterface metadata, SingleElementSymbol ses) throws QueryPlannerException {
+ try {
+ if (ses instanceof AliasSymbol) {
+ ses = ((AliasSymbol)ses).getSymbol();
+ }
+ if (ses instanceof ExpressionSymbol) {
+ ExpressionSymbol es = (ExpressionSymbol)ses;
+ if (es.getExpression() != null) {
+ es.setExpression(QueryRewriter.rewriteExpression(es.getExpression(), null, null, metadata));
+ }
+ }
+ } catch(TeiidProcessingException e) {
+ throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0023", ses)); //$NON-NLS-1$
+ } catch (TeiidComponentException e) {
+ throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0023", ses)); //$NON-NLS-1$
+ }
+ }
private static Expression convertExpression(Expression expression, Map symbolMap) {
@@ -303,7 +335,7 @@
} catch(TeiidProcessingException e) {
throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0023", criteria)); //$NON-NLS-1$
} catch (TeiidComponentException e) {
- throw new TeiidRuntimeException(e);
+ throw new QueryPlannerException(e, QueryPlugin.Util.getString("ERR.015.004.0023", criteria)); //$NON-NLS-1$
}
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-07-13 19:58:48 UTC (rev 3310)
@@ -52,6 +52,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.Transform;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants.NonReserved;
@@ -876,11 +877,11 @@
try {
PostOrderNavigator.doVisit(obj, visitor);
} catch (TeiidRuntimeException err) {
- if (err.getChild() instanceof TeiidComponentException) {
- throw (TeiidComponentException)err.getChild();
+ if (err.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)err.getCause();
}
- if (err.getChild() instanceof TeiidProcessingException) {
- throw (TeiidProcessingException)err.getChild();
+ if (err.getCause() instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)err.getCause();
}
throw err;
}
@@ -2514,17 +2515,44 @@
}
function.setArgs(newArgs);
- if( FunctionLibrary.isConvert(function) &&
- newArgs[1] instanceof Constant) {
-
- Class srcType = newArgs[0].getType();
- String tgtTypeName = (String) ((Constant)newArgs[1]).getValue();
- Class tgtType = DataTypeManager.getDataTypeClass(tgtTypeName);
+ if( FunctionLibrary.isConvert(function)) {
+ Class<?> srcType = newArgs[0].getType();
+ Class<?> tgtType = function.getType();
if(srcType != null && tgtType != null && srcType.equals(tgtType)) {
- return newArgs[0];
+ return newArgs[0]; //unnecessary conversion
}
-
+
+ if (!(newArgs[0] instanceof Function) || tgtType == DataTypeManager.DefaultDataClasses.OBJECT) {
+ return function;
+ }
+ Function nested = (Function) newArgs[0];
+ if (!FunctionLibrary.isConvert(nested)) {
+ return function;
+ }
+ Class<?> nestedType = nested.getArgs()[0].getType();
+
+ Transform t = DataTypeManager.getTransform(nestedType, nested.getType());
+ if (t.isExplicit()) {
+ //explicit conversions are required
+ return function;
+ }
+ if (DataTypeManager.getTransform(nestedType, tgtType) == null) {
+ //no direct conversion exists
+ return function;
+ }
+ //can't remove a convert that would alter the lexical form
+ if (tgtType == DataTypeManager.DefaultDataClasses.STRING &&
+ (nestedType == DataTypeManager.DefaultDataClasses.BOOLEAN
+ || nestedType == DataTypeManager.DefaultDataClasses.DATE
+ || nestedType == DataTypeManager.DefaultDataClasses.TIME
+ || tgtType == DataTypeManager.DefaultDataClasses.BIG_DECIMAL
+ || tgtType == DataTypeManager.DefaultDataClasses.FLOAT
+ || (tgtType == DataTypeManager.DefaultDataClasses.DOUBLE && srcType != DataTypeManager.DefaultDataClasses.FLOAT))) {
+ return function;
+ }
+ //nested implicit transform is not needed
+ return rewriteExpressionDirect(ResolverUtil.getConversion(nested.getArgs()[0], DataTypeManager.getDataTypeName(nestedType), DataTypeManager.getDataTypeName(tgtType), false, funcLibrary));
}
//convert DECODESTRING function to CASE expression
Modified: branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-07-13 19:58:48 UTC (rev 3310)
@@ -232,7 +232,7 @@
ERR.015.004.0010= Unknown group specified in OPTION MAKEDEP/MAKENOTDEP: {0}
ERR.015.004.0012= Group has an access pattern which has not been met: group(s) {0}; access pattern(s) {1}
ERR.015.004.0020= Error getting model for {0}
-ERR.015.004.0023= Error rewriting criteria: {0}
+ERR.015.004.0023= Error rewriting: {0}
ERR.015.004.0024= Unable to create a query plan that sends a criteria to \"{0}\". This connection factory requires criteria set to true indicating that a query against this model requires criteria.
ERR.015.004.0029= Could not resolve group symbol {0}
ERR.015.004.0035= The criteria {0} has elements from the root staging table and the document nodes which is not allowed.
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-07-13 16:38:23 UTC (rev 3309)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-07-13 19:58:48 UTC (rev 3310)
@@ -124,11 +124,11 @@
}
private Map<ElementSymbol, Integer> elements;
- private List<List> tuples;
+ private List<List<? extends Object>> tuples;
@Before public void setUp() {
elements = null;
- tuples = new ArrayList<List>();
+ tuples = new ArrayList<List<? extends Object>>();
}
private Criteria helpTestRewriteCriteria(String original, Criteria expectedCrit, QueryMetadataInterface metadata) {
@@ -138,7 +138,7 @@
// rewrite
try {
ArrayList<Boolean> booleanVals = new ArrayList<Boolean>(tuples.size());
- for (List<Object> tuple : tuples) {
+ for (List<?> tuple : tuples) {
booleanVals.add(new Evaluator(elements, null, null).evaluate(origCrit, tuple));
}
actual = QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
@@ -2448,5 +2448,16 @@
String sql = "parsedate_(pm1.g1.e1) = {d'2001-01-01'}";
helpTestRewriteCriteria(sql, parseCriteria(sql, metadata), metadata);
}
+
+ @Test public void testRewriteNestedConvert() throws Exception {
+ helpTestRewriteExpression("cast(cast(pm1.g1.e3 as integer) as long)", "cast(pm1.g1.e3 as long)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRewriteNestedConvert1() throws Exception {
+ helpTestRewriteExpression("cast(cast(pm1.g1.e3 as integer) as string)", "convert(convert(pm1.g1.e3, integer), string)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ @Test public void testRewriteNestedConvert2() throws Exception {
+ helpTestRewriteExpression("cast(cast(pm1.g1.e3 as string) as clob)", "convert(convert(pm1.g1.e3, string), clob)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
13 years, 8 months
teiid SVN: r3309 - in branches/7.1.1.CP3: build/kits/jboss-container/deploy/teiid and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-07-13 12:38:23 -0400 (Wed, 13 Jul 2011)
New Revision: 3309
Modified:
branches/7.1.1.CP3/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
branches/7.1.1.CP3/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
branches/7.1.1.CP3/pom.xml
Log:
TEIID-1493: When a node rejoins the cluster after the initial cache has been populated, during the join time the state has been set to not transfer. This need be set to transfer, also JBoss cache only transfers the state on "active" regions.
Modified: branches/7.1.1.CP3/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml
===================================================================
--- branches/7.1.1.CP3/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-07-13 16:34:27 UTC (rev 3308)
+++ branches/7.1.1.CP3/build/kits/jboss-container/deploy/teiid/teiid-cache-manager-jboss-beans-rename-me.xml 2011-07-13 16:38:23 UTC (rev 3309)
@@ -85,7 +85,7 @@
<!-- Hibernate 2LC can replicate custom types, so we use marshalling -->
<property name="useRegionBasedMarshalling">true</property>
<!-- Must match the value of "useRegionBasedMarshalling" -->
- <property name="inactiveOnStartup">true</property>
+ <property name="inactiveOnStartup">false</property>
<!-- Disable asynchronous RPC marshalling/sending -->
<property name="serializationExecutorPoolSize">0</property>
Modified: branches/7.1.1.CP3/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/7.1.1.CP3/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-07-13 16:34:27 UTC (rev 3308)
+++ branches/7.1.1.CP3/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-07-13 16:38:23 UTC (rev 3309)
@@ -59,6 +59,7 @@
if (!this.cacheStore.getCacheStatus().allowInvocations()) {
this.cacheStore.start();
+ this.cacheStore.getRegion(this.cacheStore.getRoot().getFqn(), true).activate();
}
Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
@@ -67,6 +68,7 @@
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
+ cacheRegion.activate();
JBossCache jc = null;
if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
Modified: branches/7.1.1.CP3/pom.xml
===================================================================
--- branches/7.1.1.CP3/pom.xml 2011-07-13 16:34:27 UTC (rev 3308)
+++ branches/7.1.1.CP3/pom.xml 2011-07-13 16:38:23 UTC (rev 3309)
@@ -365,7 +365,7 @@
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
- <version>3.1.0.GA</version>
+ <version>3.2.5.GA</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
13 years, 8 months
teiid SVN: r3308 - in branches/7.4.x: test-integration/common/src/test/java/org/teiid/jdbc and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-13 12:34:27 -0400 (Wed, 13 Jul 2011)
New Revision: 3308
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-1614 refining fix for possible hangs in embedded execution
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-07-12 19:23:10 UTC (rev 3307)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-07-13 16:34:27 UTC (rev 3308)
@@ -163,6 +163,7 @@
private long processingTimestamp = System.currentTimeMillis();
protected boolean useCallingThread;
+ private volatile boolean hasThread;
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
this.requestMsg = requestMsg;
@@ -200,26 +201,34 @@
@Override
public void run() {
- while (!isDoneProcessing()) {
- super.run();
- if (!useCallingThread) {
- break;
- }
- //should use the calling thread
- synchronized (this) {
- if (this.resultsReceiver == null) {
- break; //allow results to be processed by calling thread
+ hasThread = true;
+ try {
+ while (!isDoneProcessing()) {
+ super.run();
+ if (!useCallingThread) {
+ break;
}
- try {
- wait();
- } catch (InterruptedException e) {
+ //should use the calling thread
+ synchronized (this) {
+ if (this.resultsReceiver == null) {
+ break; //allow results to be processed by calling thread
+ }
+ if (this.getThreadState() == ThreadState.MORE_WORK) {
+ continue;
+ }
try {
- requestCancel();
- } catch (TeiidComponentException e1) {
- throw new TeiidRuntimeException(e1);
+ wait();
+ } catch (InterruptedException e) {
+ try {
+ requestCancel();
+ } catch (TeiidComponentException e1) {
+ throw new TeiidRuntimeException(e1);
+ }
}
}
}
+ } finally {
+ hasThread = false;
}
}
@@ -237,14 +246,15 @@
public void doMoreWork() {
boolean run = false;
synchronized (this) {
- run = this.getThreadState() == ThreadState.IDLE;
moreWork();
if (!useCallingThread || this.getThreadState() != ThreadState.MORE_WORK) {
return;
}
+ run = !hasThread;
}
if (run) {
//run outside of the lock
+ LogManager.logDetail(LogConstants.CTX_DQP, "Restarting processing using the calling thread", requestID); //$NON-NLS-1$
run();
}
}
Modified: branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-12 19:23:10 UTC (rev 3307)
+++ branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-13 16:34:27 UTC (rev 3308)
@@ -26,17 +26,20 @@
import java.lang.Thread.UncaughtExceptionHandler;
import java.sql.Connection;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
-import org.jboss.netty.handler.timeout.TimeoutException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -74,12 +77,14 @@
static Condition waiting = lock.newCondition();
static Condition wait = lock.newCondition();
+ static Semaphore sourceCounter = new Semaphore(0);
+
public static int blocking() throws InterruptedException {
lock.lock();
try {
waiting.signal();
if (!wait.await(2, TimeUnit.SECONDS)) {
- throw new TimeoutException();
+ throw new RuntimeException();
}
} finally {
lock.unlock();
@@ -88,7 +93,7 @@
}
static FakeServer server = new FakeServer();
-
+
@SuppressWarnings("serial")
@BeforeClass public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
@@ -106,13 +111,15 @@
throws TranslatorException {
return new ResultSetExecution() {
+ boolean returnedRow = false;
+
@Override
public void execute() throws TranslatorException {
lock.lock();
try {
- waiting.signal();
+ sourceCounter.release();
if (!wait.await(2, TimeUnit.SECONDS)) {
- throw new TimeoutException();
+ throw new RuntimeException();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
@@ -133,8 +140,11 @@
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
- // TODO Auto-generated method stub
- return null;
+ if (returnedRow) {
+ return null;
+ }
+ returnedRow = true;
+ return new ArrayList<Object>(Collections.singleton(null));
}
};
}
@@ -255,23 +265,68 @@
SimpleUncaughtExceptionHandler handler = new SimpleUncaughtExceptionHandler();
t.setUncaughtExceptionHandler(handler);
+ sourceCounter.acquire();
+
+ //t should now be waiting also
+
lock.lock();
try {
- assertTrue(waiting.await(2, TimeUnit.SECONDS));
+ wait.signal();
} finally {
lock.unlock();
- }
+ }
+
+ //t should finish
+ t.join();
+ if (handler.t != null) {
+ throw handler.t;
+ }
+ }
+
+ @Test public void testWaitMultiple() throws Throwable {
+ final Connection c = server.createConnection("jdbc:teiid:test");
+
+ Thread t = new Thread() {
+ public void run() {
+ Statement s;
+ try {
+ s = c.createStatement();
+ assertTrue(s.execute("select part_id from parts union all select part_id from parts"));
+ ResultSet r = s.getResultSet();
+
+ //wake up the other source thread, should put the requestworkitem into the more work state
+ lock.lock();
+ try {
+ wait.signal();
+ } finally {
+ lock.unlock();
+ }
+ Thread.sleep(1000); //TODO: need a better hook to determine that connector work has finished
+ while (r.next()) {
+ //will hang unless this thread is allowed to resume processing
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ t.start();
+ SimpleUncaughtExceptionHandler handler = new SimpleUncaughtExceptionHandler();
+ t.setUncaughtExceptionHandler(handler);
+
+ sourceCounter.acquire(2);
+
//t should now be waiting also
+ //wake up 1 source thread
lock.lock();
try {
wait.signal();
} finally {
lock.unlock();
}
-
- //t should finish
+
t.join();
if (handler.t != null) {
13 years, 8 months
teiid SVN: r3307 - in branches/7.4.x: engine/src/main/java/org/teiid/dqp/internal/process and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-07-12 15:23:10 -0400 (Tue, 12 Jul 2011)
New Revision: 3307
Modified:
branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
Log:
TEIID-1614 more appropriate fix for possible hangs in embedded execution
Modified: branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -40,8 +40,6 @@
import java.util.Properties;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -538,11 +536,7 @@
});
if (synch) {
try {
- if (queryTimeoutMS > 0) {
- pendingResult.get(queryTimeoutMS, TimeUnit.MILLISECONDS);
- } else {
- pendingResult.get();
- }
+ pendingResult.get();
result.get(); //throw an exception if needed
return result;
} catch (ExecutionException e) {
@@ -552,8 +546,6 @@
throw TeiidSQLException.create(e);
} catch (InterruptedException e) {
timeoutOccurred();
- } catch (TimeoutException e) {
- timeoutOccurred();
}
throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Timeout_before_complete")); //$NON-NLS-1$
}
@@ -578,7 +570,7 @@
reqMsg.setExecutionId(this.currentRequestID);
ResultsFuture.CompletionListener<ResultsMessage> compeletionListener = null;
- if (queryTimeoutMS > 0 && !synch) {
+ if (queryTimeoutMS > 0) {
final CancelTask c = new QueryTimeoutCancelTask(queryTimeoutMS, this);
cancellationTimer.add(c);
compeletionListener = new ResultsFuture.CompletionListener<ResultsMessage>() {
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -26,7 +26,6 @@
import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkListener;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.logging.LogManager;
@@ -43,23 +42,14 @@
private ThreadState threadState = ThreadState.MORE_WORK;
private volatile boolean isProcessing;
- private Thread callingThread;
- public AbstractWorkItem(Thread callingThread) {
- this.callingThread = callingThread;
- }
-
public void run() {
- do {
- startProcessing();
- try {
- process();
- } finally {
- if (!endProcessing()) {
- break;
- }
- }
- } while (!isDoneProcessing());
+ startProcessing();
+ try {
+ process();
+ } finally {
+ endProcessing();
+ }
}
synchronized ThreadState getThreadState() {
@@ -79,10 +69,7 @@
this.threadState = ThreadState.WORKING;
}
- /**
- * @return true if processing should be continued
- */
- final private synchronized boolean endProcessing() {
+ private synchronized void endProcessing() {
isProcessing = false;
logTrace("end processing"); //$NON-NLS-1$
switch (this.threadState) {
@@ -92,21 +79,20 @@
this.threadState = ThreadState.DONE;
} else {
this.threadState = ThreadState.IDLE;
- return pauseProcessing();
+ pauseProcessing();
}
break;
case MORE_WORK:
if (isDoneProcessing()) {
logTrace("done processing - ignoring more"); //$NON-NLS-1$
this.threadState = ThreadState.DONE;
- } else if (this.callingThread == null) {
- resumeProcessing();
+ } else {
+ resumeProcessing();
}
break;
default:
throw new IllegalStateException("Should not END on " + this.threadState); //$NON-NLS-1$
}
- return this.callingThread != null;
}
protected boolean isIdle() {
@@ -117,24 +103,18 @@
moreWork(true);
}
- final protected synchronized void moreWork(boolean ignoreDone) {
+ protected synchronized void moreWork(boolean ignoreDone) {
logTrace("more work"); //$NON-NLS-1$
+ this.notifyAll();
switch (this.threadState) {
case WORKING:
this.threadState = ThreadState.MORE_WORK;
break;
case MORE_WORK:
- if (this.callingThread != null && !this.isProcessing) {
- useCallingThread();
- }
break;
case IDLE:
this.threadState = ThreadState.MORE_WORK;
- if (this.callingThread != null) {
- useCallingThread();
- } else {
- resumeProcessing();
- }
+ resumeProcessing();
break;
default:
if (!ignoreDone) {
@@ -143,14 +123,6 @@
LogManager.logDetail(org.teiid.logging.LogConstants.CTX_DQP, new Object[] {this, "ignoring more work, since the work item is done"}); //$NON-NLS-1$
}
}
-
- private void useCallingThread() {
- if (this.callingThread == Thread.currentThread()) {
- run(); //restart with the calling thread
- } else {
- this.notifyAll(); //notify the waiting caller
- }
- }
private void logTrace(String msg) {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, new Object[] {this, msg, this.threadState});
@@ -158,33 +130,8 @@
protected abstract void process();
- protected boolean pauseProcessing() {
- if (this.callingThread != null && !shouldPause()) {
- return false;
- }
- while (this.callingThread != null && this.getThreadState() == ThreadState.IDLE) {
- try {
- this.wait(); //the lock should already be held
- } catch (InterruptedException e) {
- interrupted(e);
- }
- }
- return this.callingThread != null;
+ protected void pauseProcessing() {
}
-
- /**
- * only called for synch processing
- */
- protected boolean shouldPause() {
- return false;
- }
-
- /**
- * only called for synch processing
- */
- protected void interrupted(InterruptedException e) {
- throw new TeiidRuntimeException(e);
- }
protected abstract void resumeProcessing();
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -108,7 +108,7 @@
@Override
public void run() {
- LogManager.logDetail("Running task for parent thread", parentName); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_DQP, "Running task for parent thread", parentName); //$NON-NLS-1$
super.run();
}
@@ -352,6 +352,7 @@
}
}
if (runInThread) {
+ workItem.useCallingThread = true;
workItem.run();
}
return resultsFuture;
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -188,11 +188,8 @@
}
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());
- }
+ DQPWorkContext previous = DQPWorkContext.getWorkContext();
+ boolean associated = attachDQPWorkContext();
try {
runnable.run();
} finally {
@@ -200,9 +197,21 @@
securityHelper.clearSecurityContext(this.getSecurityDomain());
}
DQPWorkContext.releaseWorkContext();
+ if (previous != null) {
+ previous.attachDQPWorkContext();
+ }
}
}
+ private boolean attachDQPWorkContext() {
+ DQPWorkContext.setWorkContext(this);
+ boolean associated = false;
+ if (securityHelper != null && this.getSubject() != null) {
+ associated = securityHelper.assosiateSecurityContext(this.getSecurityDomain(), this.getSecurityContext());
+ }
+ return associated;
+ }
+
public HashMap<String, DataPolicy> getAllowedDataPolicies() {
if (this.policies == null) {
this.policies = new HashMap<String, DataPolicy>();
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -162,8 +162,9 @@
/**The time when command begins processing on the server.*/
private long processingTimestamp = System.currentTimeMillis();
+ protected boolean useCallingThread;
+
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
- super(workContext.useCallingThread() || requestMsg.isSync() ? Thread.currentThread() : null);
this.requestMsg = requestMsg;
this.requestID = requestID;
this.processorTimeslice = dqpCore.getProcessorTimeSlice();
@@ -196,24 +197,56 @@
protected boolean isDoneProcessing() {
return isClosed;
}
+
+ @Override
+ public void run() {
+ while (!isDoneProcessing()) {
+ super.run();
+ if (!useCallingThread) {
+ break;
+ }
+ //should use the calling thread
+ synchronized (this) {
+ if (this.resultsReceiver == null) {
+ break; //allow results to be processed by calling thread
+ }
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ try {
+ requestCancel();
+ } catch (TeiidComponentException e1) {
+ throw new TeiidRuntimeException(e1);
+ }
+ }
+ }
+ }
+ }
@Override
protected void resumeProcessing() {
- if (doneProducingBatches && !closeRequested && !isCanceled) {
- this.run(); // just run in the IO thread
- } else {
+ if (!this.useCallingThread) {
dqpCore.addWork(this);
}
}
- @Override
- protected void interrupted(InterruptedException e) {
- try {
- this.requestCancel();
- } catch (TeiidComponentException e1) {
- throw new TeiidRuntimeException(e1);
+ /**
+ * Special call from request threads to allow resumption of processing by
+ * the calling thread.
+ */
+ public void doMoreWork() {
+ boolean run = false;
+ synchronized (this) {
+ run = this.getThreadState() == ThreadState.IDLE;
+ moreWork();
+ if (!useCallingThread || this.getThreadState() != ThreadState.MORE_WORK) {
+ return;
+ }
}
- super.interrupted(e);
+ if (run) {
+ //run outside of the lock
+ run();
+ }
}
@Override
@@ -650,12 +683,6 @@
return new TeiidProcessingException(exception, SQLStates.QUERY_CANCELED, exception.getMessage());
}
- @Override
- protected boolean shouldPause() {
- //if we are waiting on results it's ok to pause
- return this.resultsReceiver != null;
- }
-
private static List<ParameterInfo> getParameterInfo(StoredProcedure procedure) {
List<ParameterInfo> paramInfos = new ArrayList<ParameterInfo>();
@@ -750,12 +777,12 @@
if (!this.doneProducingBatches) {
this.requestCancel(); //pending work should be canceled for fastest clean up
}
- this.moreWork();
+ this.doMoreWork();
}
public void requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver) {
this.requestResults(batchFirst, batchLast, receiver);
- this.moreWork();
+ this.doMoreWork();
}
public void closeAtomicRequest(AtomicRequestID atomicRequestId) {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeConnector.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -22,35 +22,25 @@
package org.teiid.dqp.internal.datamgr;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junit.framework.Assert;
-
import org.teiid.language.Command;
-import org.teiid.language.QueryExpression;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
import org.teiid.translator.UpdateExecution;
-public class FakeConnector extends ExecutionFactory {
- private static final int RESULT_SIZE = 5;
-
- private boolean executeBlocks;
- private boolean nextBatchBlocks;
- private boolean returnsFinalBatch;
- private boolean driverThrowsExceptionOnCancel;
- private long simulatedBatchRetrievalTime = 1000L;
- private ClassLoader classloader;
+public class FakeConnector extends ExecutionFactory<Object, Object> {
private int connectionCount;
private int executionCount;
-
+
public int getConnectionCount() {
return connectionCount;
}
@@ -62,123 +52,52 @@
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
executionCount++;
- return new FakeBlockingExecution(executionContext);
+ return new FakeExecution(executionContext);
}
- public Object getConnection() {
- return new FakeConnection();
- }
-
@Override
public Object getConnection(Object factory) throws TranslatorException {
+ connectionCount++;
return factory;
}
@Override
public void closeConnection(Object connection, Object factory) {
}
-
- private class FakeConnection {
- public FakeConnection() {
- connectionCount++;
- }
-
- public boolean released = false;
- public void close() {
- Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
- released = true;
- }
- }
- private final class FakeBlockingExecution implements ResultSetExecution, UpdateExecution {
- private boolean closed = false;
- private boolean cancelled = false;
+ public final class FakeExecution implements ResultSetExecution, UpdateExecution {
private int rowCount;
ExecutionContext ec;
- public FakeBlockingExecution(ExecutionContext ec) {
+
+ public FakeExecution(ExecutionContext ec) {
this.ec = ec;
}
- public void execute(QueryExpression query, int maxBatchSize) throws TranslatorException {
- if (executeBlocks) {
- waitForCancel();
- }
- if (classloader != null) {
- Assert.assertSame(classloader, Thread.currentThread().getContextClassLoader());
- }
- }
- public synchronized void cancel() throws TranslatorException {
- cancelled = true;
- this.notify();
- }
- public void close() {
- Assert.assertFalse("The execution should not be closed more than once", closed); //$NON-NLS-1$
- closed = true;
- }
@Override
public void execute() throws TranslatorException {
ec.addWarning(new Exception("Some warning")); //$NON-NLS-1$
}
@Override
- public List next() throws TranslatorException, DataNotAvailableException {
- if (nextBatchBlocks) {
- waitForCancel();
- }
- if (this.rowCount >= RESULT_SIZE || returnsFinalBatch) {
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ if (this.rowCount == 1) {
return null;
}
this.rowCount++;
- return Arrays.asList(this.rowCount - 1);
+ return new ArrayList<Object>(Arrays.asList(this.rowCount - 1));
}
- private synchronized void waitForCancel() throws TranslatorException {
- try {
- this.wait(simulatedBatchRetrievalTime);
- if (cancelled && driverThrowsExceptionOnCancel) {
- throw new TranslatorException("Request cancelled"); //$NON-NLS-1$
- }
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
@Override
public int[] getUpdateCounts() throws DataNotAvailableException,
TranslatorException {
return new int[] {1};
}
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ }
}
- public boolean isExecuteBlocks() {
- return executeBlocks;
- }
- public void setExecuteBlocks(boolean executeBlocks) {
- this.executeBlocks = executeBlocks;
- }
- public boolean isNextBatchBlocks() {
- return nextBatchBlocks;
- }
- public void setNextBatchBlocks(boolean nextBatchBlocks) {
- this.nextBatchBlocks = nextBatchBlocks;
- }
- public boolean isReturnsFinalBatch() {
- return returnsFinalBatch;
- }
- public void setReturnsFinalBatch(boolean returnsFinalBatch) {
- this.returnsFinalBatch = returnsFinalBatch;
- }
- public boolean isDriverThrowsExceptionOnCancel() {
- return driverThrowsExceptionOnCancel;
- }
- public void setDriverThrowsExceptionOnCancel(
- boolean driverThrowsExceptionOnCancel) {
- this.driverThrowsExceptionOnCancel = driverThrowsExceptionOnCancel;
- }
- public long getSimulatedBatchRetrievalTime() {
- return simulatedBatchRetrievalTime;
- }
- public void setSimulatedBatchRetrievalTime(long simulatedBatchRetrievalTime) {
- this.simulatedBatchRetrievalTime = simulatedBatchRetrievalTime;
- }
- public void setClassloader(ClassLoader classloader) {
- this.classloader = classloader;
- }
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorManager.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -50,7 +50,7 @@
return c;
}
protected Object getConnectionFactory(){
- return c.getConnection();
+ return c;
}
};
cm.start();
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -87,7 +87,7 @@
int total_columns = 3;
StoredProcedure command = (StoredProcedure)helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT); //$NON-NLS-1$
command.getInputParameters().get(0).setExpression(new Constant(1));
- Call proc = (Call)new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
+ Call proc = new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -25,20 +25,10 @@
import static org.junit.Assert.*;
import org.junit.Test;
-import org.teiid.dqp.internal.process.AbstractWorkItem.ThreadState;
public class TestWorkItemState {
- private final class WorkItemRunner implements Runnable {
- TestWorkItem workItem;
-
- @Override
- public void run() {
- workItem.run();
- }
- }
-
private class TestWorkItem extends AbstractWorkItem {
private boolean isDone;
@@ -50,11 +40,6 @@
}
private TestWorkItem(boolean done, boolean callMoreWork) {
- this(done, callMoreWork, null);
- }
-
- private TestWorkItem(boolean done, boolean callMoreWork, Thread callingThread) {
- super(callingThread);
this.isDone = done;
this.callMoreWork = callMoreWork;
}
@@ -167,51 +152,4 @@
}
}
- @Test public void testUsingCallingThreadIdle() throws Exception {
- WorkItemRunner r = new WorkItemRunner();
- Thread t = new Thread(r);
- final TestWorkItem item = new TestWorkItem(false, false, t) {
- @Override
- protected boolean shouldPause() {
- return true;
- }
- };
- r.workItem = item;
- t.start();
- for (int i = 0; i < 10 && item.getThreadState() != ThreadState.IDLE; i++) {
- Thread.sleep(100);
- }
- assertEquals(ThreadState.IDLE, item.getThreadState());
- item.moreWork();
- //if we don't return from this call, that means that this thread has been hijacked -
- //we should instead use t.
- }
-
- @Test public void testUsingCallingThreadMoreWork() throws Exception {
- final int[] processCount = new int[1];
- final TestWorkItem item = new TestWorkItem(false, false, Thread.currentThread()) {
- @Override
- protected boolean shouldPause() {
- return false;
- }
-
- @Override
- protected void process() {
- super.process();
- processCount[0]++;
- }
- };
- item.run();
- assertEquals(ThreadState.IDLE, item.getThreadState());
- Thread t = new Thread() {
- @Override
- public void run() {
- item.moreWork();
- }
- };
- t.start();
- t.join();
- item.moreWork();
- assertEquals(2, processCount[0]);
- }
}
Modified: branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-11 19:37:33 UTC (rev 3306)
+++ branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2011-07-12 19:23:10 UTC (rev 3307)
@@ -26,8 +26,12 @@
import java.lang.Thread.UncaughtExceptionHandler;
import java.sql.Connection;
+import java.sql.SQLException;
import java.sql.Statement;
-import java.util.LinkedHashMap;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -37,13 +41,21 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.language.Command;
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
-import org.teiid.metadata.MetadataStore;
-import org.teiid.metadata.Schema;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.function.metadata.FunctionCategoryConstants;
-import org.teiid.query.metadata.TransformationMetadata.Resource;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
@SuppressWarnings("nls")
public class TestLocalConnections {
@@ -76,16 +88,71 @@
}
static FakeServer server = new FakeServer();
-
- @BeforeClass public static void oneTimeSetup() {
+
+ @SuppressWarnings("serial")
+ @BeforeClass public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
- MetadataStore ms = new MetadataStore();
- Schema s = new Schema();
- s.setName("test");
+ server.setConnectorManagerRepository(new ConnectorManagerRepository() {
+ @Override
+ public ConnectorManager getConnectorManager(String connectorName) {
+ return new ConnectorManager(connectorName, connectorName) {
+ @Override
+ protected ExecutionFactory<Object, Object> getExecutionFactory() {
+ return new ExecutionFactory<Object, Object>() {
+ @Override
+ public Execution createExecution(Command command,
+ ExecutionContext executionContext,
+ RuntimeMetadata metadata, Object connection)
+ throws TranslatorException {
+ return new ResultSetExecution() {
+
+ @Override
+ public void execute() throws TranslatorException {
+ lock.lock();
+ try {
+ waiting.signal();
+ if (!wait.await(2, TimeUnit.SECONDS)) {
+ throw new TimeoutException();
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ protected Object getConnectionFactory()
+ throws TranslatorException {
+ return null;
+ }
+ };
+ }
+ });
FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", new FunctionParameter[0], new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), true, FunctionMethod.Determinism.NONDETERMINISTIC);
- s.addFunction(function);
- ms.addSchema(s);
- server.deployVDB("test", ms, new LinkedHashMap<String, Resource>());
+ HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
+ udfs.put("test", Arrays.asList(function));
+ server.deployVDB("test", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", udfs);
}
@AfterClass public static void oneTimeTearDown() {
@@ -102,6 +169,7 @@
Statement s = c.createStatement();
s.execute("select foo()");
+ s.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -131,9 +199,84 @@
if (t.isAlive()) {
fail();
}
+ s.close();
if (handler.t != null) {
throw handler.t;
}
}
+ @Test public void testUseInDifferentThreads() throws Throwable {
+ Connection c = server.createConnection("jdbc:teiid:test");
+
+ final Statement s = c.createStatement();
+ s.execute("select 1");
+
+ assertFalse(server.dqp.getRequests().isEmpty());
+
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ s.close();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ SimpleUncaughtExceptionHandler handler = new SimpleUncaughtExceptionHandler();
+ t.setUncaughtExceptionHandler(handler);
+ t.start();
+ t.join(2000);
+ if (t.isAlive()) {
+ fail();
+ }
+
+ assertTrue(server.dqp.getRequests().isEmpty());
+
+ if (handler.t != null) {
+ throw handler.t;
+ }
+ }
+
+ @Test public void testWait() throws Throwable {
+ final Connection c = server.createConnection("jdbc:teiid:test");
+
+ Thread t = new Thread() {
+ public void run() {
+ Statement s;
+ try {
+ s = c.createStatement();
+ assertTrue(s.execute("select part_id from parts"));
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ t.start();
+ SimpleUncaughtExceptionHandler handler = new SimpleUncaughtExceptionHandler();
+ t.setUncaughtExceptionHandler(handler);
+
+ lock.lock();
+ try {
+ assertTrue(waiting.await(2, TimeUnit.SECONDS));
+ } finally {
+ lock.unlock();
+ }
+
+ //t should now be waiting also
+
+ lock.lock();
+ try {
+ wait.signal();
+ } finally {
+ lock.unlock();
+ }
+
+ //t should finish
+ t.join();
+
+ if (handler.t != null) {
+ throw handler.t;
+ }
+ }
+
}
13 years, 8 months