teiid SVN: r1809 - in trunk/engine/src: test/java/com/metamatrix/query/resolver and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-09 15:03:49 -0500 (Tue, 09 Feb 2010)
New Revision: 1809
Modified:
trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
Log:
TEIID-947 metadata calls against cloned set queries may return the wrong type
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-02-09 16:38:09 UTC (rev 1808)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-02-09 20:03:49 UTC (rev 1809)
@@ -180,6 +180,10 @@
if(this.getLimit() != null) {
copy.setLimit( (Limit) this.getLimit().clone() );
}
+
+ if (this.projectedTypes != null) {
+ copy.setProjectedTypes(new ArrayList<Class<?>>(projectedTypes));
+ }
return copy;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-02-09 16:38:09 UTC (rev 1808)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-02-09 20:03:49 UTC (rev 1809)
@@ -2079,6 +2079,16 @@
assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((SingleElementSymbol)command.getProjectedSymbols().get(0)).getType());
}
+ @Test public void testUnionQueryClone() throws Exception{
+ SetQuery command = (SetQuery)helpResolve("SELECT e2, e3 FROM pm1.g1 UNION SELECT e3, e2 from pm1.g1"); //$NON-NLS-1$
+
+ assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((SingleElementSymbol)command.getProjectedSymbols().get(1)).getType());
+
+ command = (SetQuery)command.clone();
+
+ assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((SingleElementSymbol)command.getProjectedSymbols().get(1)).getType());
+ }
+
@Test public void testSelectIntoNoFrom() {
helpResolve("SELECT 'a', 19, {b'true'}, 13.999 INTO pm1.g1"); //$NON-NLS-1$
}
14 years, 10 months
teiid SVN: r1808 - in trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results: TestInvalidQueries and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-09 11:38:09 -0500 (Tue, 09 Feb 2010)
New Revision: 1808
Added:
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
Log:
Teiid-773 - Added TestResultSetUtil so that when writing out a generated file for an exception, changed so that the line terminator was not being appended to the file. This was causing, in comparison mode, the expected exceptions to fail
Added: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
===================================================================
--- trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt (rev 0)
+++ trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt 2010-02-09 16:38:09 UTC (rev 1808)
@@ -0,0 +1,13 @@
+com.metamatrix.jdbc.MMSQLException : Parsing error: Encountered "pm1.g1" at line 1, column 11.
+Was expecting one of:
+ <EOF>
+ "from" ...
+ "intersect" ...
+ "into" ...
+ "limit" ...
+ "order" ...
+ ";" ...
+ "union" ...
+ "except" ...
+ "option" ...
+
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnon_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 10 months
teiid SVN: r1807 - trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-09 11:29:25 -0500 (Tue, 09 Feb 2010)
New Revision: 1807
Added:
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
Log:
Teiid-773 - Added TestResultSetUtil so that when writing out a generated file for an exception, changed so that the line terminator was not being appended to the file. This was causing, in comparison mode, the expected exceptions to fail
Added: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
===================================================================
--- trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt (rev 0)
+++ trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt 2010-02-09 16:29:25 UTC (rev 1807)
@@ -0,0 +1,13 @@
+com.metamatrix.jdbc.MMSQLException : Parsing error: Encountered "pm1.g1" at line 1, column 11.
+Was expecting one of:
+ <EOF>
+ "from" ...
+ "intersect" ...
+ "into" ...
+ "limit" ...
+ "order" ...
+ ";" ...
+ "union" ...
+ "except" ...
+ "option" ...
+
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/TestInvalidQueries_TestQuery1.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 10 months
teiid SVN: r1806 - in trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms: test_queries and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-09 11:29:06 -0500 (Tue, 09 Feb 2010)
New Revision: 1806
Added:
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/client_test_txnoff_expected_results/TestInvalidQueries/
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestInvalidQueries.xml
Modified:
trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestPhysicalQueries.xml
Log:
Teiid-773 - Added TestResultSetUtil so that when writing out a generated file for an exception, changed so that the line terminator was not being appended to the file. This was causing, in comparison mode, the expected exceptions to fail
Added: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestInvalidQueries.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestInvalidQueries.xml (rev 0)
+++ trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestInvalidQueries.xml 2010-02-09 16:29:06 UTC (rev 1806)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+
+<!-- * =====================================================================* -->
+<!-- * These tests are expected to fail * -->
+<!-- * =====================================================================* -->
+
+<!-- Missing FROM Clause -->
+<query name="TestQuery1">select * pm1.g1 order by e1</query>
+
+</root>
+
Property changes on: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestInvalidQueries.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestPhysicalQueries.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestPhysicalQueries.xml 2010-02-09 16:27:21 UTC (rev 1805)
+++ trunk/test-integration/db/src/main/resources/ctc_tests/queries/rdbms/test_queries/TestPhysicalQueries.xml 2010-02-09 16:29:06 UTC (rev 1806)
@@ -5,7 +5,7 @@
<!-- * Testing simple transactions * -->
<!-- * =====================================================================* -->
-<query name="TestQuery1">select * from pm1.g1 where e1 >= 0 order by e1
+<query name="TestQuery1">select * from pm1.g1 order by e1
</query>
<query name="TestQuery2">select * from pm1.g2 where e1 >= 0 order by e1</query>
14 years, 10 months
teiid SVN: r1805 - in trunk/test-integration/db/src/main/java/org/teiid/test: client/impl and 2 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-09 11:27:21 -0500 (Tue, 09 Feb 2010)
New Revision: 1805
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
Log:
Teiid-773 - Added TestResultSetUtil so that when writing out a generated file for an exception, changed so that the line terminator was not being appended to the file. This was causing, in comparison mode, the expected exceptions to fail
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java 2010-02-08 19:45:46 UTC (rev 1804)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResult.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -142,7 +142,20 @@
Throwable getException();
+ /**
+ * Set the exception that indicates the reason why there is a problem
+ * with the results. Call {@link #setExceptionMessage(String)} to display
+ * a different message in the summary file.
+ * @param error
+ */
void setException(Throwable error);
+
+ /**
+ * Set the error message relating to the reason why there is a problem
+ * with the results.
+ * @param errorMsg
+ */
+ void setExceptionMessage(String errorMsg);
/**
* Return the time (in a long value) that this query started.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java 2010-02-08 19:45:46 UTC (rev 1804)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -33,7 +33,7 @@
import org.teiid.test.client.ctc.ResultsHolder;
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.util.TestResultSetUtil;
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.jdbc.util.ResultSetUtil;
@@ -116,13 +116,12 @@
List<?> results = null;
if (actualException != null) {
-
try {
- results = ResultSetUtil.writeAndCompareThrowable(
- actualException, null, expectedResultsFile, false);
+ results = TestResultSetUtil.compareThrowable(
+ actualException, expectedResultsFile, false);
} catch (Throwable e) {
- TransactionRuntimeException t = new TransactionRuntimeException(
+ QueryTestFailedException t = new QueryTestFailedException(
e.getMessage());
t.initCause(e);
throw t;
@@ -177,7 +176,7 @@
} catch (QueryTestFailedException qe) {
throw qe;
} catch (Throwable e) {
- TransactionRuntimeException t = new TransactionRuntimeException(
+ QueryTestFailedException t = new QueryTestFailedException(
e.getMessage());
t.initCause(e);
throw t;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-02-08 19:45:46 UTC (rev 1804)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -55,18 +55,19 @@
if (getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
- Object error_results = null;
+ Object results = null;
try {
- error_results = this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ results = this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
sql,
resultSet,
resultException,
tr.getStatus(), isOrdered(sql), updateCnt, resultFromQuery);
- if (error_results == null) {
+ if (results == null) {
tr.setStatus(TestResult.RESULT_STATE.TEST_SUCCESS);
} else {
tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+ tr.setExceptionMessage("Results did not compare to expected results");
}
@@ -82,7 +83,7 @@
try {
this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
tr.getQueryID(), sql, resultSet, resultException,
- error_results );
+ results );
} catch (QueryTestFailedException qtfe) {
throw new TransactionRuntimeException(qtfe.getMessage());
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java 2010-02-08 19:45:46 UTC (rev 1804)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -37,7 +37,7 @@
import org.teiid.test.client.ResultsGenerator;
import org.teiid.test.client.TestProperties;
import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.util.TestResultSetUtil;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.jdbc.util.ResultSetUtil;
@@ -128,7 +128,7 @@
PrintStream filePrintStream = new PrintStream(actualOut);
if (ex != null) {
- ResultSetUtil.printThrowable(ex, filePrintStream);
+ TestResultSetUtil.printThrowable(ex, filePrintStream);
} else if (result != null ){
result.beforeFirst();
ResultSetUtil.printResultSet(result, MAX_COL_WIDTH, true, filePrintStream);
@@ -136,7 +136,7 @@
} catch (Exception e) {
e.printStackTrace();
- throw new TransactionRuntimeException(e);
+ throw new QueryTestFailedException(e);
} finally {
if (actualOut != null) {
try {
@@ -172,11 +172,13 @@
PrintStream filePrintStream = new PrintStream(actualOut);
- ResultSetUtil.printThrowable(queryError, filePrintStream);
+ TestResultSetUtil.printThrowable(queryError, filePrintStream);
+
+ filePrintStream.flush();
} catch (Exception e) {
e.printStackTrace();
- throw new TransactionRuntimeException(e);
+ throw new QueryTestFailedException(e);
} finally {
if (actualOut != null) {
try {
@@ -265,7 +267,7 @@
} catch (Exception e) {
e.printStackTrace();
- throw new TransactionRuntimeException(e);
+ throw new QueryTestFailedException(e);
} finally {
if (actualOut != null) {
try {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java 2010-02-08 19:45:46 UTC (rev 1804)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/results/TestResultStat.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -114,13 +114,18 @@
}
public String getExceptionMsg() {
- return (error != null ? error.getMessage() : "");
+ return (this.errorMsg != null ? this.errorMsg : ( error != null ? error.getMessage() : ""));
}
public void setException(Throwable error){
this.error = error;
}
+ public void setExceptionMessage(String errorMsg) {
+ this.errorMsg = errorMsg;
+
+ }
+
public Throwable getException() {
return this.error;
}
Added: trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java 2010-02-09 16:27:21 UTC (rev 1805)
@@ -0,0 +1,67 @@
+/*
+ * 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.test.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.sql.SQLException;
+import java.util.List;
+
+import com.metamatrix.jdbc.util.ResultSetUtil;
+
+
+/**
+ * TestResultSetUtil was built in order to override the {@link #printThrowable(Throwable, PrintStream)} method
+ * in order to call out.print instead of out.println
+ * This is because the println adds a line terminator, and when the result file is in turn used for
+ * comparison it fails because of the line terminator.
+ *
+ * @since
+ */
+public class TestResultSetUtil {
+
+ public static final int DEFAULT_MAX_COL_WIDTH = ResultSetUtil.DEFAULT_MAX_COL_WIDTH;
+
+ public static List compareThrowable(Throwable t, File expectedResultsFile, boolean printToConsole) throws IOException, SQLException {
+ BufferedReader expectedResultsReader = null;
+ if (expectedResultsFile != null && expectedResultsFile.exists() && expectedResultsFile.canRead()) {
+ expectedResultsReader = new BufferedReader(new FileReader(expectedResultsFile));
+ }
+
+ PrintStream out = ResultSetUtil.getPrintStream(null,expectedResultsReader, printToConsole ? System.out : null);
+
+ printThrowable(t, out);
+ return ResultSetUtil.getUnequalLines(out);
+ }
+
+
+ public static void printThrowable(Throwable t, PrintStream out) {
+
+ out.print(t.getClass().getName() + " : " + t.getMessage()); //$NON-NLS-1$
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 10 months
teiid SVN: r1804 - in trunk/test-integration/db/src/main/java/org/teiid/test/client: impl and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-08 14:45:46 -0500 (Mon, 08 Feb 2010)
New Revision: 1804
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
Log:
Teiid-773 - the error files were being created, but the status wasnt being set so that the summary indicated the number of errors
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-02-06 02:00:21 UTC (rev 1803)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-02-08 19:45:46 UTC (rev 1804)
@@ -154,7 +154,7 @@
.println("Number Passed : " + passFailGenMap.get("pass")); //$NON-NLS-1$ //$NON-NLS-2$
outputStream
.println("Number Failed : " + passFailGenMap.get("fail")); //$NON-NLS-1$ //$NON-NLS-2$
- outputStream.println("Number Generated : " + passFailGenMap.get("gen")); //$NON-NLS-1$ //$NON-NLS-2$
+// outputStream.println("Number Generated : " + passFailGenMap.get("gen")); //$NON-NLS-1$ //$NON-NLS-2$
ResponseTimes responseTimes = calcQueryResponseTimes(results);
outputStream.println("QPS : " + responseTimes.qps); //$NON-NLS-1$
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-02-06 02:00:21 UTC (rev 1803)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-02-08 19:45:46 UTC (rev 1804)
@@ -54,30 +54,36 @@
Throwable resultException = tr.getException();
if (getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
- Object results = null;
+
+ Object error_results = null;
try {
- results = this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ error_results = this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
sql,
resultSet,
resultException,
tr.getStatus(), isOrdered(sql), updateCnt, resultFromQuery);
- tr.setStatus(TestResult.RESULT_STATE.TEST_SUCCESS);
-
+ if (error_results == null) {
+ tr.setStatus(TestResult.RESULT_STATE.TEST_SUCCESS);
+ } else {
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+ }
+
+
} catch (QueryTestFailedException qtf) {
resultException = (resultException != null ? resultException
: qtf);
tr.setException(resultException);
tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
-
}
- if (results != null || tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
+ if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
try {
this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
tr.getQueryID(), sql, resultSet, resultException,
- results );
+ error_results );
+
} catch (QueryTestFailedException qtfe) {
throw new TransactionRuntimeException(qtfe.getMessage());
}
@@ -99,6 +105,7 @@
} else {
// just create the error file for any failures
if (tr.getException() != null) {
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
try {
this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
tr.getQueryID(), sql, resultSet, resultException, null);
14 years, 10 months
teiid SVN: r1803 - in branches/JCA: build/kit-jboss-container/deployers and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-05 21:00:21 -0500 (Fri, 05 Feb 2010)
New Revision: 1803
Added:
branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/
branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
Removed:
branches/JCA/build/kit-jboss-container/deployers/teiid-deployer-jboss-beans.xml
Modified:
branches/JCA/build/assembly/jboss-container/dist.xml
branches/JCA/jboss-integration/pom.xml
Log:
TEIID-833: moving teiid dependencies under deployer directory; only client, hibernate will be in the lib directory
Modified: branches/JCA/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-04 23:51:45 UTC (rev 1802)
+++ branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-06 02:00:21 UTC (rev 1803)
@@ -33,7 +33,6 @@
<moduleSet>
<includes>
<include>org.jboss.teiid:teiid-hibernate-dialect</include>
- <include>org.jboss.teiid:teiid-connector-api</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
@@ -61,7 +60,7 @@
<useDefaultExcludes>true</useDefaultExcludes>
</dependencySet>
</dependencySets>
- <outputDirectory>lib</outputDirectory>
+ <outputDirectory>deployers/teiid.deployer</outputDirectory>
</binaries>
</moduleSet>
Deleted: branches/JCA/build/kit-jboss-container/deployers/teiid-deployer-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deployers/teiid-deployer-jboss-beans.xml 2010-02-04 23:51:45 UTC (rev 1802)
+++ branches/JCA/build/kit-jboss-container/deployers/teiid-deployer-jboss-beans.xml 2010-02-06 02:00:21 UTC (rev 1803)
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- Deployer specific Stuff -->
- <bean name="VDBStructure" class="org.teiid.deployers.VDBStructure" />
- <bean name="VDBRepository" class="org.teiid.deployers.VDBRepository"/>
- <bean name="ConnectorManagerRepository" class="org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository"/>
-
- <bean name="VDBParserDeployer" class="org.teiid.deployers.VDBParserDeployer">
- <property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
- </bean>
-
-
- <bean name="DynamicVDBDeployer" class="org.teiid.deployers.DynamicVDBDeployer">
- <property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
- <property name="VDBRepository"><inject bean="VDBRepository"/></property>
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- </bean>
-
-
- <bean name="ObjectSerializer" class="org.teiid.deployers.ObjectSerializer">
- <property name="attachmentStoreRoot">${jboss.server.data.dir}/teiid</property>
- </bean>
-
- <bean name="VDBDeployer" class="org.teiid.deployers.VDBDeployer">
- <install bean="ManagedDeploymentCreator" method="addAttachmentType">
- <parameter>
- <value>org.teiid.adminapi.impl.VDBMetaData</value>
- </parameter>
- <parameter>
- <value>teiid-vdb</value>
- </parameter>
- </install>
- <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
- <parameter>
- <value>org.teiid.adminapi.impl.VDBMetaData</value>
- </parameter>
- </uninstall>
- <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
- <property name="VDBRepository"><inject bean="VDBRepository"/></property>
- <property name="contextCache"><inject bean="ContextCache"/></property>
- <depends>SystemVDBDeployer</depends>
- </bean>
-
-
-
- <bean name="SystemVDBDeployer" class="org.teiid.deployers.SystemVDBDeployer">
- <property name="VDBRepository"><inject bean="VDBRepository"/></property>
- </bean>
-
- <bean name="ConnectorBindingDeployer" class="org.teiid.jboss.deployers.ConnectorBindingDeployer">
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
- </bean>
-
- <bean name="DQPManager" class="org.teiid.dqp.internal.process.DQPManagementView">
- <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
- </bean>
-
- <!-- JBOSS Cache -->
- <!-- Uncomment for JBoss Cache -->
- <!--
- <bean name="TeiidJBossCacheConfig" class="org.jboss.cache.config.Configuration">
- <property name="runtimeConfig">
- <bean class="org.jboss.cache.config.RuntimeConfig">
- <property name="transactionManager">
- <inject bean="TransactionManager" property="transactionManager"/>
- </property>
- </bean>
- </property>
-
- <property name="isolationLevel">READ_COMMITTED</property>
-
- <property name="cacheMode">LOCAL</property>
-
- <property name="lockAcquisitionTimeout">15000</property>
-
- <property name="exposeManagementStatistics">true</property>
-
- <property name="evictionConfig">
- <bean class="org.jboss.cache.config.EvictionConfig">
- <property name="defaultEvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</property>
- <property name="wakeupIntervalSeconds">15</property>
- <property name="evictionRegionConfigs">
- <list>
- <bean class="org.jboss.cache.config.EvictionRegionConfig">
- <property name="regionName">/_default_</property>
- <property name="evictionAlgorithmConfig">
- <bean class="org.jboss.cache.eviction.LRUAlgorithmConfig">
- <property name="maxAge">-1</property>
- <property name="timeToLive">-1</property>
- <property name="maxNodes">10000</property>
- </bean>
- </property>
- </bean>
- </list>
- </property>
- </bean>
- </property>
- </bean>
-
- <bean name="TeiidDefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
- <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" factoryMethod="getInstance"/>
- </bean>
-
- <bean name="TeiidJBossCache" class="org.jboss.cache.Cache">
- <constructor factoryMethod="createCache">
- <factory bean="TeiidDefaultCacheFactory"/>
- <parameter class="org.jboss.cache.config.Configuration"><inject bean="TeiidJBossCacheConfig"/></parameter>
- <parameter class="boolean">false</parameter>
- </constructor>
- </bean>
-
- <bean name="TeiidJBossCacheMBean" class="org.jboss.cache.jmx.CacheJmxWrapper">
- <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=TeiidCache",exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class,registerDirectly=true)</annotation>
- <constructor>
- <parameter class="org.jboss.cache.Cache"><inject bean="TeiidJBossCache"/></parameter>
- </constructor>
- </bean>
-
- <bean name="TeiidCache" class="com.metamatrix.cache.jboss.JBossCacheFactory">
- <property name="cacheName">jboss.cache:service=TeiidCache</property>
- <demand>TransactionManager</demand>
- <demand>TeiidJBossCacheMBean</demand>
- </bean>
- -->
-
- <bean name="TeiidCache" class="org.teiid.cache.DefaultCacheFactory">
- </bean>
-
- <bean name="ContextCache" class="org.teiid.dqp.internal.cache.DQPContextCache">
- <property name="cacheFactory"><inject bean="TeiidCache"/></property>
- <property name="processName">localhost</property>
- </bean>
-</deployment>
\ No newline at end of file
Copied: branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml (from rev 1769, branches/JCA/build/kit-jboss-container/deployers/teiid-deployer-jboss-beans.xml)
===================================================================
--- branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-02-06 02:00:21 UTC (rev 1803)
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Deployer specific Stuff -->
+ <bean name="VDBStructure" class="org.teiid.deployers.VDBStructure" />
+ <bean name="VDBRepository" class="org.teiid.deployers.VDBRepository"/>
+ <bean name="ConnectorManagerRepository" class="org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository"/>
+
+ <bean name="VDBParserDeployer" class="org.teiid.deployers.VDBParserDeployer">
+ <property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
+ </bean>
+
+
+ <bean name="DynamicVDBDeployer" class="org.teiid.deployers.DynamicVDBDeployer">
+ <property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
+ <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ </bean>
+
+
+ <bean name="ObjectSerializer" class="org.teiid.deployers.ObjectSerializer">
+ <property name="attachmentStoreRoot">${jboss.server.data.dir}/teiid</property>
+ </bean>
+
+ <bean name="VDBDeployer" class="org.teiid.deployers.VDBDeployer">
+ <install bean="ManagedDeploymentCreator" method="addAttachmentType">
+ <parameter>
+ <value>org.teiid.adminapi.impl.VDBMetaData</value>
+ </parameter>
+ <parameter>
+ <value>teiid-vdb</value>
+ </parameter>
+ </install>
+ <uninstall bean="ManagedDeploymentCreator" method="removeAttachmentType">
+ <parameter>
+ <value>org.teiid.adminapi.impl.VDBMetaData</value>
+ </parameter>
+ </uninstall>
+ <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+ <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ <property name="contextCache"><inject bean="ContextCache"/></property>
+ <depends>SystemVDBDeployer</depends>
+ </bean>
+
+
+
+ <bean name="SystemVDBDeployer" class="org.teiid.deployers.SystemVDBDeployer">
+ <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+ </bean>
+
+ <bean name="ConnectorBindingDeployer" class="org.teiid.jboss.deployers.ConnectorBindingDeployer">
+ <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+ </bean>
+
+ <bean name="DQPManager" class="org.teiid.dqp.internal.process.DQPManagementView">
+ <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ </bean>
+
+ <!-- JBOSS Cache -->
+ <!-- Uncomment for JBoss Cache -->
+ <!--
+ <bean name="TeiidJBossCacheConfig" class="org.jboss.cache.config.Configuration">
+ <property name="runtimeConfig">
+ <bean class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager">
+ <inject bean="TransactionManager" property="transactionManager"/>
+ </property>
+ </bean>
+ </property>
+
+ <property name="isolationLevel">READ_COMMITTED</property>
+
+ <property name="cacheMode">LOCAL</property>
+
+ <property name="lockAcquisitionTimeout">15000</property>
+
+ <property name="exposeManagementStatistics">true</property>
+
+ <property name="evictionConfig">
+ <bean class="org.jboss.cache.config.EvictionConfig">
+ <property name="defaultEvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</property>
+ <property name="wakeupIntervalSeconds">15</property>
+ <property name="evictionRegionConfigs">
+ <list>
+ <bean class="org.jboss.cache.config.EvictionRegionConfig">
+ <property name="regionName">/_default_</property>
+ <property name="evictionAlgorithmConfig">
+ <bean class="org.jboss.cache.eviction.LRUAlgorithmConfig">
+ <property name="maxAge">-1</property>
+ <property name="timeToLive">-1</property>
+ <property name="maxNodes">10000</property>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean name="TeiidDefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
+ <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" factoryMethod="getInstance"/>
+ </bean>
+
+ <bean name="TeiidJBossCache" class="org.jboss.cache.Cache">
+ <constructor factoryMethod="createCache">
+ <factory bean="TeiidDefaultCacheFactory"/>
+ <parameter class="org.jboss.cache.config.Configuration"><inject bean="TeiidJBossCacheConfig"/></parameter>
+ <parameter class="boolean">false</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TeiidJBossCacheMBean" class="org.jboss.cache.jmx.CacheJmxWrapper">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=TeiidCache",exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class,registerDirectly=true)</annotation>
+ <constructor>
+ <parameter class="org.jboss.cache.Cache"><inject bean="TeiidJBossCache"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TeiidCache" class="com.metamatrix.cache.jboss.JBossCacheFactory">
+ <property name="cacheName">jboss.cache:service=TeiidCache</property>
+ <demand>TransactionManager</demand>
+ <demand>TeiidJBossCacheMBean</demand>
+ </bean>
+ -->
+
+ <bean name="TeiidCache" class="org.teiid.cache.DefaultCacheFactory">
+ </bean>
+
+ <bean name="ContextCache" class="org.teiid.dqp.internal.cache.DQPContextCache">
+ <property name="cacheFactory"><inject bean="TeiidCache"/></property>
+ <property name="processName">localhost</property>
+ </bean>
+</deployment>
\ No newline at end of file
Property changes on: branches/JCA/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2010-02-04 23:51:45 UTC (rev 1802)
+++ branches/JCA/jboss-integration/pom.xml 2010-02-06 02:00:21 UTC (rev 1803)
@@ -55,7 +55,6 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-connector-api</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
14 years, 10 months
teiid SVN: r1802 - branches/JCA/runtime/src/main/java/org/teiid/deployers.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-04 18:51:45 -0500 (Thu, 04 Feb 2010)
New Revision: 1802
Modified:
branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
Log:
TEIID-502: Fixing the error deploying the UDF
Modified: branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-02-04 23:09:58 UTC (rev 1801)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-02-04 23:51:45 UTC (rev 1802)
@@ -77,7 +77,7 @@
// check if this is a VDB with index files, if there are then build the TransformationMetadata
IndexMetadataFactory indexFactory = unit.getAttachment(IndexMetadataFactory.class);
- UDFMetaData udf = unit.removeAttachment(UDFMetaData.class);
+ UDFMetaData udf = unit.getAttachment(UDFMetaData.class);
if (indexFactory != null) {
Map<VirtualFile, Visibility> visibilityMap = indexFactory.getEntriesPlusVisibilities();
metadata = buildTransformationMetaData(deployment, visibilityMap, store, udf);
@@ -89,6 +89,7 @@
// add the metadata objects as attachments
deployment.removeAttachment(IndexMetadataFactory.class);
+ deployment.removeAttachment(UDFMetaData.class);
deployment.addAttchment(QueryMetadataInterface.class, metadata);
deployment.addAttchment(CompositeMetadataStore.class, metadata.getMetadataStore());
Modified: branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-02-04 23:09:58 UTC (rev 1801)
+++ branches/JCA/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-02-04 23:51:45 UTC (rev 1802)
@@ -141,7 +141,7 @@
// If the UDF file is enclosed then attach it to the deployment artifact
if (udf != null) {
- def.addAttchment(UDFMetaData.class, udf);
+ unit.addAttachment(UDFMetaData.class, udf);
}
log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
14 years, 10 months
teiid SVN: r1801 - in branches/JCA: build/assembly/jboss-container and 12 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-04 18:09:58 -0500 (Thu, 04 Feb 2010)
New Revision: 1801
Added:
branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/
branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/META-INF/
branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/META-INF/ra.xml
Removed:
branches/JCA/build/assembly/jboss-container/connectors.xml
branches/JCA/build/assembly/jboss-container/dependencies.xml
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
Modified:
branches/JCA/build/assembly/jboss-container/dist.xml
branches/JCA/cache-jbosscache/pom.xml
branches/JCA/common-internal/pom.xml
branches/JCA/connector-api/pom.xml
branches/JCA/connector-sdk/pom.xml
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
branches/JCA/engine/pom.xml
branches/JCA/jboss-integration/pom.xml
branches/JCA/metadata/pom.xml
branches/JCA/pom.xml
branches/JCA/runtime/pom.xml
Log:
TEIID-833: Fixing some dependencies such that client/connector-api are provided rest have dependent each other
Deleted: branches/JCA/build/assembly/jboss-container/connectors.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/connectors.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/build/assembly/jboss-container/connectors.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -1,34 +0,0 @@
-<!--This script builds a JAR for the Embedded Server Installation -->
-<assembly>
-
- <id>connector-rar</id>
-
- <formats>
- <format>dir</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
- <baseDirectory>teiid</baseDirectory>
-
- <moduleSets>
- <moduleSet>
- <includeSubModules>true</includeSubModules>
-
- <includes>
- <include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
- <include>org.jboss.teiid.connectors:connector-loopback</include>
- <include>org.jboss.teiid.connectors:connector-text</include>
- <include>org.jboss.teiid.connectors:connector-ldap</include>
- <include>org.jboss.teiid.connectors:connector-salesforce</include>
- </includes>
-
- <binaries>
- <includeDependencies>false</includeDependencies>
- <unpack>false</unpack>
- </binaries>
-
- </moduleSet>
-
- </moduleSets>
-
-</assembly>
\ No newline at end of file
Deleted: branches/JCA/build/assembly/jboss-container/dependencies.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dependencies.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/build/assembly/jboss-container/dependencies.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -1,59 +0,0 @@
-<!--This script builds a JAR for the Embedded Server Installation -->
-<assembly>
-
- <id>runtime-dependencies</id>
-
- <formats>
- <format>dir</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
- <baseDirectory>teiid</baseDirectory>
-
- <moduleSets>
- <moduleSet>
- <includeSubModules>true</includeSubModules>
-
- <includes>
- <include>org.jboss.teiid:teiid-cache-jbosscache</include>
- <include>org.jboss.teiid:teiid-common-internal</include>
-
- <include>org.jboss.teiid:teiid-connector-api</include>
- <include>org.jboss.teiid:teiid-connector-metadata</include>
- <include>org.jboss.teiid:teiid-runtime</include>
- <include>org.jboss.teiid:teiid-engine</include>
- <include>org.jboss.teiid:teiid-metadata</include>
- </includes>
-
- <binaries>
- <includeDependencies>true</includeDependencies>
- <unpack>false</unpack>
-
- <dependencySets>
- <dependencySet>
- <useProjectArtifact>true</useProjectArtifact>
- <unpack>false</unpack>
- <useTransitiveDependencies>true</useTransitiveDependencies>
- <useDefaultExcludes>true</useDefaultExcludes>
- <excludes>
- <exclude>teiid*</exclude>
- </excludes>
- </dependencySet>
- </dependencySets>
-
- </binaries>
-
- </moduleSet>
- <moduleSet>
- <includes>
- <include>org.jboss.teiid:teiid-hibernate-dialect</include>
- <include>org.jboss.teiid:teiid-jboss-integration</include>
- </includes>
- <binaries>
- <includeDependencies>false</includeDependencies>
- <unpack>false</unpack>
- </binaries>
- </moduleSet>
- </moduleSets>
-
-</assembly>
\ No newline at end of file
Modified: branches/JCA/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -11,36 +11,79 @@
<baseDirectory>teiid-${version}</baseDirectory>
<fileSets>
-
+
<fileSet>
+ <directory>build/kit-jboss-container</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+
+ <!-- only true dependency file for any client -->
+ <fileSet>
<directory>target/distribution</directory>
<includes>
<include>teiid-${version}-client.jar</include>
</includes>
<outputDirectory>lib</outputDirectory>
</fileSet>
-
- <fileSet>
- <directory>target/distribution/teiid-${version}-runtime-dependencies.dir</directory>
+
+ </fileSets>
+
+ <!-- these have external dependent clients like connectors-->
+ <moduleSets>
+ <moduleSet>
<includes>
- <include>*.jar</include>
+ <include>org.jboss.teiid:teiid-hibernate-dialect</include>
+ <include>org.jboss.teiid:teiid-connector-api</include>
</includes>
- <outputDirectory>lib</outputDirectory>
- </fileSet>
-
- <fileSet>
- <directory>target/distribution/teiid-${version}-connector-rar.dir</directory>
- <includes>
- <include>*.rar</include>
- </includes>
- <outputDirectory>deploy</outputDirectory>
- </fileSet>
+ <binaries>
+ <includeDependencies>false</includeDependencies>
+ <unpack>false</unpack>
+ <outputDirectory>lib</outputDirectory>
+ </binaries>
+ </moduleSet>
+
+ <!-- These are Teiid internal dependencies; to make JCA work -->
+ <moduleSet>
+ <includeSubModules>true</includeSubModules>
+
+ <includes>
+ <include>org.jboss.teiid:teiid-jboss-integration</include>
+ </includes>
+
+ <binaries>
+ <includeDependencies>true</includeDependencies>
+ <unpack>false</unpack>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>false</unpack>
+ <useTransitiveDependencies>true</useTransitiveDependencies>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ </dependencySet>
+ </dependencySets>
+ <outputDirectory>lib</outputDirectory>
+ </binaries>
+ </moduleSet>
+
+ <!-- These are built in connectors -->
+ <moduleSet>
+ <includeSubModules>true</includeSubModules>
+
+ <includes>
+ <include>org.jboss.teiid.connectors:connector-jdbc:rar</include>
+ <include>org.jboss.teiid.connectors:connector-loopback:rar</include>
+ <include>org.jboss.teiid.connectors:connector-text:rar</include>
+ <include>org.jboss.teiid.connectors:connector-ldap:rar</include>
+ <include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
+ </includes>
+
+ <binaries>
+ <includeDependencies>false</includeDependencies>
+ <unpack>false</unpack>
+ <outputDirectory>deploy</outputDirectory>
+ </binaries>
+
+ </moduleSet>
- <fileSet>
- <directory>build/kit-jboss-container</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
-
- </fileSets>
-
+ </moduleSets>
</assembly>
\ No newline at end of file
Added: branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/META-INF/ra.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/META-INF/ra.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-engine.rar/META-INF/ra.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Teiid Runtime Engine</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ </description>
+ <license-required>true</license-required>
+ </license>
+
+ <resourceadapter>
+ <resourceadapter-class>org.teiid.TeiidResourceAdapter</resourceadapter-class>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>org.teiid.TeiidManagedConnectionFactory</managedconnectionfactory-class>
+ <config-property>
+ <description>Name of the process that uniquely identifies this process </description>
+ <config-property-name>ProcessName</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>localhost</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Process pool maximum thread count. (default 64)</description>
+ <config-property-name>MaxThreads</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>64</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Query processor time slice, in milliseconds. (default 2000)</description>
+ <config-property-name>TimeSliceInMilli</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>2000</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Plan debug messages allowed. see option debug.</description>
+ <config-property-name>OptionDebugAllowed</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20000)</description>
+ <config-property-name>MaxRowsFetchSize</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>2000</config-property-value>
+ </config-property>
+ <config-property>
+ <description>The max lob chunk size transferred each time when processing blobs, clobs(10KB default)</description>
+ <config-property-name>LobChunkSizeInKB</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10</config-property-value>
+ </config-property>
+ <config-property>
+ <description>The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250) </description>
+ <config-property-name>PreparedPlanCacheMaxCount</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>250</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Maximum number of cached lookup tables. Note: this is a memory based cache and should be set to a value of at least 10 to accomidate system usage. (default 200)</description>
+ <config-property-name>CodeTablesMaxCount</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>200</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Maximum number of records in a single lookup table (default 10000)</description>
+ <config-property-name>CodeTablesMaxRowsPerTable</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>10000</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Maximum number of records in all lookup tables (default 200000)</description>
+ <config-property-name>CodeTablesMaxRows</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>200000</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Server Bind address</description>
+ <config-property-name>BindAddress</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>localhost</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Server Port Number</description>
+ <config-property-name>portNumber</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>31000</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Max Entries allowed for ResultSet Cache</description>
+ <config-property-name>ResultSetCacheMaxEntries</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>1024</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Enable Resultset Caching</description>
+ <config-property-name>ResultSetCacheEnabled</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <connectionfactory-interface>com.metamatrix.common.comm.api.ServerConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.TeiidConnectionFactory</connectionfactory-impl-class>
+ <connection-interface>com.metamatrix.common.comm.api.ServerConnection</connection-interface>
+ <connection-impl-class>org.teiid.WrappedConnection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>NoTransaction</transaction-support>
+
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+ </resourceadapter>
+</connector>
Deleted: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
===================================================================
(Binary files differ)
Modified: branches/JCA/cache-jbosscache/pom.xml
===================================================================
--- branches/JCA/cache-jbosscache/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/cache-jbosscache/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -11,9 +11,15 @@
<name>JBoss Cache</name>
<description>JBossCache provider.</description>
<dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.cache</groupId>
Modified: branches/JCA/common-internal/pom.xml
===================================================================
--- branches/JCA/common-internal/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/common-internal/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -16,6 +16,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -27,6 +28,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: branches/JCA/connector-api/pom.xml
===================================================================
--- branches/JCA/connector-api/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/connector-api/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -16,6 +16,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: branches/JCA/connector-sdk/pom.xml
===================================================================
--- branches/JCA/connector-sdk/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/connector-sdk/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -53,6 +53,10 @@
</resources>
</build>
<dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-connector-api</artifactId>
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2010-02-04 23:09:58 UTC (rev 1801)
@@ -23,10 +23,7 @@
package com.metamatrix.connector.object;
-import org.teiid.adminapi.AdminException;
-import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.basic.BasicConnection;
@@ -35,7 +32,6 @@
import com.metamatrix.connector.object.extension.IObjectSource;
import com.metamatrix.connector.object.extension.ISourceTranslator;
-import com.metamatrix.connector.object.util.ObjectConnectorUtil;
import com.metamatrix.core.util.ArgCheck;
/**
Modified: branches/JCA/engine/pom.xml
===================================================================
--- branches/JCA/engine/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/engine/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -50,11 +50,13 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-connector-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/jboss-integration/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -46,30 +46,19 @@
</build>
<dependencies>
+
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client</artifactId>
- <scope>provided</scope>
+ <artifactId>teiid-runtime</artifactId>
</dependency>
+
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-engine</artifactId>
+ <artifactId>teiid-connector-api</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-runtime</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.jboss.man</groupId>
<artifactId>jboss-managed</artifactId>
<scope>provided</scope>
@@ -96,6 +85,19 @@
<!-- these for just running profile service remotely -->
<dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client-jdbc</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.naming</groupId>
<artifactId>jnp-client</artifactId>
<version>5.0.3.GA</version>
Modified: branches/JCA/metadata/pom.xml
===================================================================
--- branches/JCA/metadata/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/metadata/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -15,6 +15,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -37,9 +38,16 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<scope>provided</scope>
Modified: branches/JCA/pom.xml
===================================================================
--- branches/JCA/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -83,8 +83,6 @@
<descriptor>build/assembly/src.xml</descriptor>
-->
<descriptor>build/assembly/client-jar.xml</descriptor>
- <descriptor>build/assembly/jboss-container/dependencies.xml</descriptor>
- <descriptor>build/assembly/jboss-container/connectors.xml</descriptor>
<descriptor>build/assembly/jboss-container/dist.xml</descriptor>
<descriptor>build/assembly/adminshell/adminshell-dependencies.xml</descriptor>
<descriptor>build/assembly/adminshell/adminshell-dist.xml</descriptor>
Modified: branches/JCA/runtime/pom.xml
===================================================================
--- branches/JCA/runtime/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
+++ branches/JCA/runtime/pom.xml 2010-02-04 23:09:58 UTC (rev 1801)
@@ -14,6 +14,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -27,10 +28,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-connector-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -48,6 +51,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client-jdbc</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
14 years, 10 months
teiid SVN: r1800 - in branches/JCA: adminshell/src/main/resources/commands and 88 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-04 13:44:39 -0500 (Thu, 04 Feb 2010)
New Revision: 1800
Added:
branches/JCA/client/src/test/java/org/
branches/JCA/client/src/test/java/org/teiid/
branches/JCA/client/src/test/java/org/teiid/netty/
branches/JCA/client/src/test/java/org/teiid/netty/handler/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
branches/JCA/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQL5Translator.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/MetadataProcessor.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/NameUtil.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Relationship.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/RelationshipImpl.java
branches/JCA/console/.settings/
branches/JCA/console/.settings/org.eclipse.jdt.core.prefs
branches/JCA/console/.settings/org.maven.ide.eclipse.prefs
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
branches/JCA/documentation/caching-guide/
branches/JCA/documentation/caching-guide/pom.xml
branches/JCA/documentation/caching-guide/src/
branches/JCA/documentation/caching-guide/src/main/
branches/JCA/documentation/caching-guide/src/main/docbook/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
Removed:
branches/JCA/client/src/test/java/org/teiid/
branches/JCA/client/src/test/java/org/teiid/netty/
branches/JCA/client/src/test/java/org/teiid/netty/handler/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/
branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
branches/JCA/console/.settings/org.eclipse.jdt.core.prefs
branches/JCA/console/.settings/org.maven.ide.eclipse.prefs
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java
branches/JCA/documentation/caching-guide/pom.xml
branches/JCA/documentation/caching-guide/src/
branches/JCA/documentation/caching-guide/src/main/
branches/JCA/documentation/caching-guide/src/main/docbook/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/ManagedBatch.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/storage/
Modified:
branches/JCA/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java
branches/JCA/adminshell/src/main/resources/commands/mparse.bsh
branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
branches/JCA/build/kit-runtime/deploy.properties
branches/JCA/build/kit-runtime/deploy/log4j.xml
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/BatchResults.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestBatchResults.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
branches/JCA/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
branches/JCA/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
branches/JCA/common-core/src/main/java/com/metamatrix/core/util/HashCodeUtil.java
branches/JCA/common-core/src/main/java/com/metamatrix/core/util/LRUCache.java
branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQL5Translator.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
branches/JCA/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java
branches/JCA/console/src/assembly/assemble-artifacts.xml
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/JCA/console/src/resources/embedded/META-INF/rhq-plugin.xml
branches/JCA/documentation/reference/src/main/docbook/en-US/content/architecture.xml
branches/JCA/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java
branches/JCA/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
branches/JCA/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
branches/JCA/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/MergeJoinStrategy.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortNode.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareEvaluator.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
branches/JCA/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
branches/JCA/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestResultsMessage.java
branches/JCA/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/BlockingFakeRelationalNode.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java
branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
branches/JCA/test-integration/pom.xml
Log:
TEIID-833: Forward merging -r 1724:1798 from trunk into JCA branch
Modified: branches/JCA/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java
===================================================================
--- branches/JCA/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/adminshell/src/main/java/com/metamatrix/script/shell/ReaderInterceptor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -21,18 +21,13 @@
*/
package com.metamatrix.script.shell;
-/*
- * Copyright � 2000-2005 MetaMatrix, Inc.
- * All rights reserved.
- */
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
-import bsh.Interpreter;
-
/**
* This class used in conjunction with BeanShell, to hijack the System.in
* and write a wrapper on top it,so that any commands entered in its console
@@ -131,33 +126,5 @@
}
}
}
-
- public static void main(String[] args) {
- final String ls = System.getProperty("line.separator"); //$NON-NLS-1$
- CustomParser p = new CustomParser() {
- public String convert(String str) {
- System.out.println(str);
- if (str.matches("select .+|insert into.+|delete .+|update table .*|exec .+")){ //$NON-NLS-1$
- return "execute(\""+str.substring(0,str.length()-1)+"\");"+ls; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return "foo:"+str+ls; //$NON-NLS-1$
- }
-
- public void setInterpreter(Interpreter i) {
- }
- };
-
- BufferedReader i = new BufferedReader(new ReaderInterceptor(p, null));
-
- try {
- String line = i.readLine();
- while(line != null) {
- System.out.println(line);
- line = i.readLine();
- }
- } catch (IOException err) {
- err.printStackTrace();
- }
- }
}
Modified: branches/JCA/adminshell/src/main/resources/commands/mparse.bsh
===================================================================
--- branches/JCA/adminshell/src/main/resources/commands/mparse.bsh 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/adminshell/src/main/resources/commands/mparse.bsh 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,5 +1,5 @@
/**
- * A simple parser for MetaMatrix specific commands.
+ * A simple parser for specific commands.
*/
String mparse() {
// mmstr is special variable set by the Input Interceptor. Just update
@@ -9,7 +9,7 @@
boolean record = false;
if (str.endsWith(";") && str.matches("(select|insert|delete|update|exec|create|drop)\\W.+")){
- mmstr="execute(\""+orig_str.substring(0,orig_str.length()-1)+"\");";
+ mmstr="execute(\""+orig_str.substring(0,orig_str.length()-1).replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") +"\");";
record = true;
}
else if (str.matches("(help|exit|quit|dir|pwd)\\(?\\)?")) {
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -50,7 +50,11 @@
<property name="bufferMemorySizeInMB">64</property>
<property name="processorBatchSize">2000</property>
<property name="connectorBatchSize">2000</property>
- <property name="cacheFactory"><inject bean="TeiidCache"/></property>
+ <property name="maxProcessingBatches">8</property>
+ <property name="maxReserveBatches">64</property>
+ <!-- Max File size in GB -->
+ <property name="maxFileSize">2</property>
+ <property name="maxOpenFiles">256</property>
</bean>
<bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
===================================================================
(Binary files differ)
Modified: branches/JCA/build/kit-runtime/deploy/log4j.xml
===================================================================
--- branches/JCA/build/kit-runtime/deploy/log4j.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/build/kit-runtime/deploy/log4j.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -81,6 +81,10 @@
<logger name="org.teiid">
<level value="WARN" />
</logger>
+
+ <logger name="org.apache.axis">
+ <level value="WARN" />
+ </logger>
<!-- un-comment to enable COMMAND log
<logger name="org.teiid.COMMAND_LOG" additivity="false">
Modified: branches/JCA/build/kit-runtime/deploy.properties
===================================================================
--- branches/JCA/build/kit-runtime/deploy.properties 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/build/kit-runtime/deploy.properties 2010-02-04 18:44:39 UTC (rev 1800)
@@ -37,11 +37,11 @@
#Plan debug messages allowed. see option debug.
process.optionDebugAllowed=true
-#Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20000)
-process.maxRowsFetchSize=20000
+#Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480)
+process.maxRowsFetchSize=20480
-# The max lob chunk size transferred each time when processing blobs, clobs(10KB default)
-process.lobChunkSizeInKB=10
+# The max lob chunk size transferred each time when processing blobs, clobs(100KB default)
+process.lobChunkSizeInKB=100
#
# BufferManager Settings
@@ -56,8 +56,8 @@
#Defines whether to use disk buffering or not. (default true)
dqp.buffer.useDisk=true
-#The numeric memory size in MB, to be used before disk buffering kicks in (default 64)
-dqp.buffer.memory=64
+#The number of batches to actively hold in the BufferManager
+org.teiid.buffer.maxReserveBatches=64
#
# Cache Settings
@@ -66,7 +66,7 @@
#The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)
PreparedPlanCache.maxCount=250
-#Maximum number of cached lookup tables. Note: this is a memory based cache and should be set to a value of at least 10 to accomidate system usage. (default 200)
+#Maximum number of cached lookup tables. Note: this is a memory based cache. (default 200)
CodeTables.maxCount=200
#Maximum number of records in a single lookup table (default 10000)
@@ -75,21 +75,12 @@
#Maximum number of records in all lookup tables (default 200000)
CodeTables.maxRows=200000
-#Denotes whether or not result set caching is enabled. (default false)
-ResultSetCache.enabled=false
+#Denotes whether or not result set caching is enabled. (default true)
+ResultSetCache.enabled=true
-#The maximum size of an result set cache entry in bytes. 0 indicates no limit. (default 1001024)
-#ResultSetCache.maxEntrySize=1001024
-
#The maximum number of result set cache entries. 0 indicates no limit. (default 1024)
#ResultSetCache.maxEntries=1024
-#The maximum time in seconds a result set will be kept in cache before being automatically cleared. 0 indicates no limit. (default 3600)
-#ResultSetCache.maxAge=3600
-
-#Defines whether caching is restricted to a specific session ('session') or a specific VDB version ('vdb'). (default vdb)
-#ResultSetCache.scope=vdb
-
#
# Session Service Settings
#
@@ -97,8 +88,8 @@
#Maximum number of sessions allowed by the system (default 5000)
session.maxSessions=5000
-#Max allowed time before the session is terminated by the system (default unlimited, default is 86400000 - 24hrs)
-#session.expirationTimeInMilli=86400000
+#Max allowed time before the session is terminated by the system, 0 indicates unlimited (default 0)
+#session.expirationTimeInMilli=0
#
# Membership Service Settings (handles the authentication of the user)
@@ -144,7 +135,7 @@
ssl.enabled=false
#ssl.protocol=SSLv3
-#SSL Authentication Mode, may be one of 1-way, 2-way, or annonymous (default 1-way)
+#SSL Authentication Mode, may be one of 1-way, 2-way, or anonymous (default 1-way)
#ssl.authenticationMode=1-way
#ssl.keymanagementalgorithm=
#ssl.keystore.filename=ssl.keystore
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/batch/BatchSerializer.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -151,7 +151,7 @@
readIsNullData(in, isNull);
for (int i = 0; i < batch.length; i++) {
if (!isNullObject(isNull, i)) {
- batch[i].set(col, readObject(in));
+ batch[i].set(col, DataTypeManager.getCanonicalValue(readObject(in)));
}
}
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -58,7 +58,6 @@
private final Socket socket;
private ObjectOutputStream outputStream;
private ObjectInputStream inputStream;
- private Object readLock = new Object();
private OioObjectChannel(Socket socket) throws IOException {
log.fine("creating new OioObjectChannel"); //$NON-NLS-1$
@@ -119,15 +118,13 @@
//## JDBC4.0-end ##
public Object read() throws IOException, ClassNotFoundException {
log.finer("reading message from socket"); //$NON-NLS-1$
- synchronized (readLock) {
- try {
- return inputStream.readObject();
- } catch (SocketTimeoutException e) {
- throw e;
- } catch (IOException e) {
- close();
- throw e;
- }
+ try {
+ return inputStream.readObject();
+ } catch (SocketTimeoutException e) {
+ throw e;
+ } catch (IOException e) {
+ close();
+ throw e;
}
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -83,6 +83,8 @@
private Map<Serializable, ResultsReceiver<Object>> asynchronousListeners = new ConcurrentHashMap<Serializable, ResultsReceiver<Object>>();
+ private boolean hasReader;
+
public SocketServerInstanceImpl() {
}
@@ -173,7 +175,7 @@
return socketChannel.isOpen();
}
- public void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
+ protected void send(Message message, ResultsReceiver<Object> listener, Serializable messageKey)
throws CommunicationException, InterruptedException {
if (listener != null) {
asynchronousListeners.put(messageKey, listener);
@@ -197,7 +199,7 @@
* Send an exception to all clients that are currently waiting for a
* response.
*/
- public void exceptionOccurred(Throwable e) {
+ private void exceptionOccurred(Throwable e) {
if (e instanceof CommunicationException) {
if (e.getCause() instanceof InvalidClassException) {
log.log(Level.SEVERE, "Unknown class or incorrect class version:", e); //$NON-NLS-1$
@@ -222,7 +224,7 @@
}
}
- public void receivedMessage(Object packet) {
+ private void receivedMessage(Object packet) {
log.log(Level.FINE, "reading packet"); //$NON-NLS-1$
if (packet instanceof Message) {
Message messagePacket = (Message)packet;
@@ -297,7 +299,7 @@
}
@Override
- public synchronized Object get() throws InterruptedException, ExecutionException {
+ public Object get() throws InterruptedException, ExecutionException {
try {
return this.get(SocketServerConnectionFactory.getInstance().getSynchronousTtl(), TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
@@ -310,25 +312,43 @@
* the actual reads.
*/
@Override
- public synchronized Object get(long timeout, TimeUnit unit)
+ public Object get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
- int timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
+ long timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
+ long start = System.currentTimeMillis();
while (!isDone()) {
- if (timeoutMillis <= 0) {
- throw new TimeoutException();
+ boolean reading = false;
+ synchronized (SocketServerInstanceImpl.this) {
+ if (!hasReader) {
+ hasReader = true;
+ reading = true;
+ } else if (!isDone()) {
+ SocketServerInstanceImpl.this.wait(Math.max(1, timeoutMillis));
+ }
+ }
+ if (reading) {
+ try {
+ if (!isDone()) {
+ receivedMessage(socketChannel.read());
+ }
+ } catch (SocketTimeoutException e) {
+ } catch (Exception e) {
+ exceptionOccurred(e);
+ } finally {
+ synchronized (SocketServerInstanceImpl.this) {
+ hasReader = false;
+ SocketServerInstanceImpl.this.notifyAll();
+ }
+ }
}
- long start = System.currentTimeMillis();
- try {
- receivedMessage(socketChannel.read());
- } catch (SocketTimeoutException e) {
- } catch (IOException e) {
- exceptionOccurred(e);
- } catch (ClassNotFoundException e) {
- exceptionOccurred(e);
- }
if (!isDone()) {
- timeoutMillis -= (System.currentTimeMillis() - start);
+ long now = System.currentTimeMillis();
+ timeoutMillis -= now - start;
+ start = now;
+ if (timeoutMillis <= 0) {
+ throw new TimeoutException();
+ }
}
}
return super.get(timeout, unit);
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -42,6 +42,7 @@
// cache properties
public static final String USE_RESULTSET_CACHE = "ResultSetCache.enabled"; //$NON-NLS-1$
+ public static final String MAX_RESULTSET_CACHE_ENTRIES = "ResultSetCache.maxEntries"; //$NON-NLS-1$
public static final String MAX_CODE_TABLE_RECORDS_PER_TABLE = "CodeTables.maxRowsPerTable"; //$NON-NLS-1$
public static final String MAX_CODE_TABLE_RECORDS = "CodeTables.maxRows"; //$NON-NLS-1$
public static final String MAX_CODE_TABLES = "CodeTables.maxCount"; //$NON-NLS-1$
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -39,7 +39,7 @@
static final long serialVersionUID = 2258063872049251854L;
- public static final int DEFAULT_FETCH_SIZE = 2000;
+ public static final int DEFAULT_FETCH_SIZE = 2048;
private String[] commands;
private boolean isBatchedUpdate;
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/message/ResultsMessage.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -57,9 +57,6 @@
/** Warning could be schema validation errors or partial results warnings */
private List<Throwable> warnings;
- /** Schemas associated with xml results. */
- private Collection schemas;
-
/** First row index */
private int firstRow = 0;
@@ -172,17 +169,9 @@
return planDescription;
}
-
/**
* @return
*/
- public Collection getSchemas() {
- return schemas;
- }
-
- /**
- * @return
- */
public List getWarnings() {
return warnings;
}
@@ -227,13 +216,6 @@
}
/**
- * @param collection
- */
- public void setSchemas(Collection collection) {
- schemas = collection;
- }
-
- /**
* @param list
*/
public void setWarnings(List<Throwable> list) {
@@ -295,9 +277,6 @@
this.warnings = ExceptionHolder.toThrowables(holderList);
}
- //Schemas
- schemas = ExternalizeUtil.readList(in);
-
firstRow = in.readInt();
lastRow = in.readInt();
finalRow = in.readInt();
@@ -334,8 +313,6 @@
out.writeObject(this.warnings);
}
- //Schemas
- ExternalizeUtil.writeCollection(out, schemas);
out.writeInt(firstRow);
out.writeInt(lastRow);
out.writeInt(finalRow);
Modified: branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,8 +22,10 @@
*/
package org.teiid.netty.handler.codec.serialization;
-import java.io.DataInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.EOFException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
@@ -40,11 +42,15 @@
*/
public class ObjectDecoderInputStream extends ObjectInputStream {
- private final DataInputStream in;
+ private final InputStream in;
private final ClassLoader classLoader;
private final int maxObjectSize;
+
+ private boolean foundLength;
+ private byte[] buffer;
+ private int count;
- public ObjectDecoderInputStream(DataInputStream in, ClassLoader classLoader, int maxObjectSize) throws SecurityException, IOException {
+ public ObjectDecoderInputStream(InputStream in, ClassLoader classLoader, int maxObjectSize) throws SecurityException, IOException {
super();
this.in = in;
this.classLoader = classLoader;
@@ -54,17 +60,47 @@
@Override
protected final Object readObjectOverride() throws IOException,
ClassNotFoundException {
- int dataLen = in.readInt();
- if (dataLen <= 0) {
- throw new StreamCorruptedException("invalid data length: " + dataLen); //$NON-NLS-1$
+ if (!foundLength) {
+ if (buffer == null) {
+ buffer = new byte[4];
+ }
+ fillBuffer();
+ int dataLen = getIntFromBytes(buffer);
+ if (dataLen <= 0) {
+ throw new StreamCorruptedException("invalid data length: " + dataLen); //$NON-NLS-1$
+ }
+ if (dataLen > maxObjectSize) {
+ throw new StreamCorruptedException(
+ "data length too big: " + dataLen + " (max: " + maxObjectSize + ')'); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ //check if the underlying buffer can be used
+ if (in.available() >= dataLen) {
+ return new CompactObjectInputStream(in, classLoader).readObject();
+ }
+ buffer = new byte[dataLen];
+ foundLength = true;
}
- if (dataLen > maxObjectSize) {
- throw new StreamCorruptedException(
- "data length too big: " + dataLen + " (max: " + maxObjectSize + ')'); //$NON-NLS-1$ //$NON-NLS-2$
+ fillBuffer();
+ foundLength = false;
+ ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+ buffer = null;
+ return new CompactObjectInputStream(bais, classLoader).readObject();
+ }
+
+ static int getIntFromBytes(byte[] buffer) {
+ return ((buffer[0] & 0xff) << 24) + ((buffer[1] & 0xff) << 16) + ((buffer[2] & 0xff) << 8) + (buffer[3] & 0xff);
+ }
+
+ private void fillBuffer() throws IOException, EOFException {
+ while (count < buffer.length) {
+ int read = in.read(buffer, count, buffer.length - count);
+ if (read == -1) {
+ throw new EOFException();
+ }
+ count += read;
}
-
- return new CompactObjectInputStream(in, classLoader).readObject();
- }
+ count = 0;
+ }
@Override
public void close() throws IOException {
Modified: branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,12 +22,13 @@
*/
package org.teiid.netty.handler.codec.serialization;
-import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
+import com.metamatrix.core.util.AccessibleByteArrayOutputStream;
+
/**
* An {@link ObjectOutput} which is interoperable with {@link ObjectDecoder}
* and {@link ObjectDecoderInputStream}.
@@ -42,7 +43,7 @@
private final DataOutputStream out;
private final int estimatedLength;
-
+
public ObjectEncoderOutputStream(DataOutputStream out, int estimatedLength) throws SecurityException, IOException {
super();
this.out = out;
@@ -51,14 +52,14 @@
@Override
final protected void writeObjectOverride(Object obj) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(estimatedLength);
+ AccessibleByteArrayOutputStream baos = new AccessibleByteArrayOutputStream(estimatedLength);
ObjectOutputStream oout = new CompactObjectOutputStream(baos);
oout.writeObject(obj);
oout.flush();
oout.close();
- out.writeInt(baos.size());
- out.write(baos.toByteArray());
+ out.writeInt(baos.getCount());
+ out.write(baos.getBuffer(), 0, baos.getCount());
}
@Override
Modified: branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
===================================================================
--- branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,6 +22,8 @@
package com.metamatrix.common.comm.platform.socket.client;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
@@ -32,7 +34,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.api.HostInfo;
@@ -42,7 +44,7 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
-public class TestSocketServerInstanceImpl extends TestCase {
+public class TestSocketServerInstanceImpl {
private static class FakeObjectChannel implements ObjectChannel, ObjectChannelFactory {
List<Object> msgs = new ArrayList<Object>();
@@ -82,6 +84,10 @@
//## JDBC4.0-end ##
public Object read() throws IOException,
ClassNotFoundException {
+ if (readCount >= readMsgs.size()) {
+ return "";
+ }
+
Object msg = readMsgs.get(readCount++);
if (msg instanceof IOException) {
if (msg instanceof SocketTimeoutException) {
@@ -119,7 +125,7 @@
}
- public void testHandshakeTimeout() throws Exception {
+ @Test public void testHandshakeTimeout() throws Exception {
SocketTimeoutException[] exs = new SocketTimeoutException[SocketServerInstanceImpl.HANDSHAKE_RETRIES];
Arrays.fill(exs, new SocketTimeoutException());
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(exs));
@@ -139,7 +145,7 @@
return ssii;
}
- public void testSuccessfulHandshake() throws Exception {
+ @Test public void testSuccessfulHandshake() throws Exception {
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException()));
SocketServerInstanceImpl instance = createInstance(channel);
@@ -154,7 +160,7 @@
}
}
- public void testVersionMismatch() throws Exception {
+ @Test public void testVersionMismatch() throws Exception {
Handshake h = new Handshake();
h.setVersion("foo"); //$NON-NLS-1$
final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(h));
Copied: branches/JCA/client/src/test/java/org (from rev 1798, trunk/client/src/test/java/org)
Copied: branches/JCA/client/src/test/java/org/teiid (from rev 1798, trunk/client/src/test/java/org/teiid)
Copied: branches/JCA/client/src/test/java/org/teiid/netty (from rev 1798, trunk/client/src/test/java/org/teiid/netty)
Copied: branches/JCA/client/src/test/java/org/teiid/netty/handler (from rev 1798, trunk/client/src/test/java/org/teiid/netty/handler)
Copied: branches/JCA/client/src/test/java/org/teiid/netty/handler/codec (from rev 1798, trunk/client/src/test/java/org/teiid/netty/handler/codec)
Copied: branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization (from rev 1798, trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization)
Deleted: branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java
===================================================================
--- trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.netty.handler.codec.serialization;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketTimeoutException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class TestObjectDecoderInputStream {
-
- @Test public void testTimeoutException() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectEncoderOutputStream oeos = new ObjectEncoderOutputStream(new DataOutputStream(baos), 512);
- List<Integer> obj = Arrays.asList(1, 2, 3);
- oeos.writeObject(obj);
- oeos.close();
- final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- InputStream is = new InputStream() {
- int count;
- @Override
- public int read() throws IOException {
- if (count++%2==0) {
- throw new SocketTimeoutException();
- }
- return bais.read();
- }
- };
- ObjectDecoderInputStream odis = new ObjectDecoderInputStream(new DataInputStream(is), Thread.currentThread().getContextClassLoader(), 1024);
- Object result = null;
- do {
- try {
- result = odis.readObject();
- } catch (IOException e) {
-
- }
- } while (result == null);
- assertEquals(obj, result);
- }
-
- @Test public void testLargeIntConversion() throws Exception {
- int testValue = 204503404;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(baos);
- dos.writeInt(testValue);
- dos.close();
- assertEquals(testValue, ObjectDecoderInputStream.getIntFromBytes(baos.toByteArray()));
- }
-
-}
Copied: branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java (from rev 1798, trunk/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java)
===================================================================
--- branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java (rev 0)
+++ branches/JCA/client/src/test/java/org/teiid/netty/handler/codec/serialization/TestObjectDecoderInputStream.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,79 @@
+/*
+ * 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.netty.handler.codec.serialization;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestObjectDecoderInputStream {
+
+ @Test public void testTimeoutException() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectEncoderOutputStream oeos = new ObjectEncoderOutputStream(new DataOutputStream(baos), 512);
+ List<Integer> obj = Arrays.asList(1, 2, 3);
+ oeos.writeObject(obj);
+ oeos.close();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ InputStream is = new InputStream() {
+ int count;
+ @Override
+ public int read() throws IOException {
+ if (count++%2==0) {
+ throw new SocketTimeoutException();
+ }
+ return bais.read();
+ }
+ };
+ ObjectDecoderInputStream odis = new ObjectDecoderInputStream(new DataInputStream(is), Thread.currentThread().getContextClassLoader(), 1024);
+ Object result = null;
+ do {
+ try {
+ result = odis.readObject();
+ } catch (IOException e) {
+
+ }
+ } while (result == null);
+ assertEquals(obj, result);
+ }
+
+ @Test public void testLargeIntConversion() throws Exception {
+ int testValue = 204503404;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeInt(testValue);
+ dos.close();
+ assertEquals(testValue, ObjectDecoderInputStream.getIntFromBytes(baos.toByteArray()));
+ }
+
+}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/BatchResults.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/BatchResults.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/BatchResults.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -73,6 +73,7 @@
private ArrayList<Batch> batches = new ArrayList<Batch>();
private int currentRowNumber;
+ private List<?> currentRow;
private int lastRowNumber = -1;
private int highestRowNumber;
private BatchFetcher batchFetcher;
@@ -93,25 +94,30 @@
* Moving backward through the results it's expected that the batches will match the fetch size.
*/
public List getCurrentRow() throws SQLException {
- if (currentRowNumber == 0 || (lastRowNumber != -1 && currentRowNumber > lastRowNumber)) {
+ if (currentRow != null) {
+ return currentRow;
+ }
+ if (this.currentRowNumber == 0 || (lastRowNumber != -1 && this.currentRowNumber > lastRowNumber)) {
return null;
}
for (int i = 0; i < batches.size(); i++) {
Batch batch = batches.get(i);
- if (currentRowNumber < batch.getBeginRow()) {
+ if (this.currentRowNumber < batch.getBeginRow()) {
continue;
}
- if (currentRowNumber > batch.getEndRow()) {
+ if (this.currentRowNumber > batch.getEndRow()) {
continue;
}
if (i != 0) {
batches.add(0, batches.remove(i));
}
- return batch.getRow(currentRowNumber);
+ currentRow = batch.getRow(this.currentRowNumber);
+ return currentRow;
}
- requestBatchAndWait(currentRowNumber);
+ requestBatchAndWait(this.currentRowNumber);
Batch batch = batches.get(0);
- return batch.getRow(currentRowNumber);
+ currentRow = batch.getRow(this.currentRowNumber);
+ return currentRow;
}
private void requestNextBatch() throws SQLException {
@@ -120,29 +126,30 @@
public boolean next() throws SQLException{
if (hasNext()) {
- currentRowNumber++;
+ setCurrentRowNumber(this.currentRowNumber + 1);
+ getCurrentRow();
return true;
}
- if (currentRowNumber == highestRowNumber) {
- currentRowNumber++;
+ if (this.currentRowNumber == highestRowNumber) {
+ setCurrentRowNumber(this.currentRowNumber + 1);
}
return false;
}
public boolean hasPrevious() {
- return (currentRowNumber != 0 && currentRowNumber != 1);
+ return (this.currentRowNumber != 0 && this.currentRowNumber != 1);
}
public boolean previous() {
if (hasPrevious()) {
- currentRowNumber--;
+ setCurrentRowNumber(this.currentRowNumber - 1);
return true;
}
if (this.currentRowNumber == 1) {
- currentRowNumber--;
+ setCurrentRowNumber(this.currentRowNumber - 1);
}
return false;
@@ -158,7 +165,7 @@
public boolean absolute(int row, int offset) throws SQLException {
if(row == 0) {
- currentRowNumber = 0;
+ setCurrentRowNumber(0);
return false;
}
@@ -169,11 +176,11 @@
}
if (row + offset <= highestRowNumber) {
- currentRowNumber = row;
+ setCurrentRowNumber(row);
return true;
}
- currentRowNumber = lastRowNumber + 1 - offset;
+ setCurrentRowNumber(lastRowNumber + 1 - offset);
return false;
}
@@ -186,11 +193,11 @@
int positiveRow = lastRowNumber + row + 1;
if (positiveRow <= 0) {
- currentRowNumber = 0;
+ setCurrentRowNumber(0);
return false;
}
- currentRowNumber = positiveRow;
+ setCurrentRowNumber(positiveRow);
return true;
}
@@ -219,11 +226,11 @@
}
public boolean hasNext(int next) throws SQLException {
- while (currentRowNumber + next > highestRowNumber && lastRowNumber == -1) {
+ while (this.currentRowNumber + next > highestRowNumber && lastRowNumber == -1) {
requestNextBatch();
}
- return (currentRowNumber + next <= highestRowNumber);
+ return (this.currentRowNumber + next <= highestRowNumber);
}
public int getFinalRowNumber() {
@@ -233,5 +240,12 @@
public int getHighestRowNumber() {
return highestRowNumber;
}
+
+ private void setCurrentRowNumber(int currentRowNumber) {
+ if (currentRowNumber != this.currentRowNumber) {
+ this.currentRow = null;
+ }
+ this.currentRowNumber = currentRowNumber;
+ }
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -46,6 +46,8 @@
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -365,7 +367,11 @@
checkClosed();
try {
ResultsFuture<ResultsMessage> results = statement.getDQP().processCursorRequest(requestID, beginRow, fetchSize);
- ResultsMessage currentResultMsg = results.get();
+ int timeoutSeconds = statement.getQueryTimeout();
+ if (timeoutSeconds == 0) {
+ timeoutSeconds = Integer.MAX_VALUE;
+ }
+ ResultsMessage currentResultMsg = results.get(timeoutSeconds, TimeUnit.SECONDS);
this.setResultsData(currentResultMsg);
this.updatedPlanDescription = currentResultMsg.getPlanDescription();
return getCurrentBatch(currentResultMsg);
@@ -375,6 +381,8 @@
throw MMSQLException.create(e);
} catch (ExecutionException e) {
throw MMSQLException.create(e);
+ } catch (TimeoutException e) {
+ throw MMSQLException.create(e);
}
}
@@ -392,7 +400,7 @@
}
protected int getOffset() {
- return parameters;
+ return parameters > 0 ? 1 : 0;
}
protected int getAbsoluteRowNumber() {
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -738,12 +738,6 @@
String partial = getExecutionProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE);
res.setPartialResults(Boolean.valueOf(partial).booleanValue());
- // Get fetch size
- res.setFetchSize(fetchSize);
-
- // Get cursor type
- res.setCursorType(this.resultSetType);
-
// Get xml validation mode
String validate = getExecutionProperty(ExecutionProperties.PROP_XML_VALIDATION);
if(validate == null) {
@@ -855,8 +849,8 @@
sqlOptions.toUpperCase().indexOf(ExecutionProperties.SQL_OPTION_SHOWPLAN.toUpperCase()) >= 0) {
reqMsg.setShowPlan(true);
}
-
- reqMsg.setFetchSize(getFetchSize());
+ reqMsg.setCursorType(this.resultSetType);
+ reqMsg.setFetchSize(this.fetchSize);
reqMsg.setStyleSheet(this.styleSheet);
reqMsg.setRowLimit(this.maxRows);
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,6 +22,7 @@
package com.metamatrix.jdbc;
+import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.sql.ResultSet;
@@ -35,8 +36,12 @@
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Matchers;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
@@ -47,7 +52,7 @@
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.query.unittest.TimestampUtil;
-public class TestAllResultsImpl extends TestCase {
+public class TestAllResultsImpl {
private static final long REQUEST_ID = 0;
private static final int TYPE_FORWARD_ONLY = ResultSet.TYPE_FORWARD_ONLY;
@@ -55,17 +60,12 @@
private MMStatement statement;
- public TestAllResultsImpl(String name) {
- super(name);
+ @Before public void setUp() throws Exception {
+ statement = TestMMResultSet.createMockStatement(TYPE_SCROLL_SENSITIVE);
}
-
- @Override
- protected void setUp() throws Exception {
- statement = TestMMResultSet.createMockStatement();
- }
/** test hasNext(), actual result set should return FALSE. */
- public void testHasNext1() throws Exception {
+ @Test public void testHasNext1() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
while (rs.next()) {
@@ -80,7 +80,7 @@
}
/** test hasNext(), actual result set should return TRUE. */
- public void testHasNext2() throws Exception {
+ @Test public void testHasNext2() throws Exception {
List[] results = exampleResults1(5);
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
@@ -100,7 +100,7 @@
* test next(), whether the result set's cursor is positioned on next row or
* not
*/
- public void testNext1() throws Exception {
+ @Test public void testNext1() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
@@ -113,7 +113,7 @@
}
/** test next(), walk through all rows of a result set and compare each row. */
- public void testNext2() throws Exception {
+ @Test public void testNext2() throws Exception {
List[] results = exampleResults1(5);
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
@@ -131,7 +131,7 @@
}
/** test next(), get result set and close without walking through */
- public void testNext3() throws Exception {
+ @Test public void testNext3() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
assertEquals(new Integer(0), new Integer(rs.getRow()));
@@ -140,7 +140,7 @@
}
/** test next(), walk through partial rows of a result set */
- public void testNext4() throws Exception {
+ @Test public void testNext4() throws Exception {
List[] results = exampleResults1(5);
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
@@ -156,7 +156,7 @@
}
/** test next(), when hasNext() == false */
- public void testNext5() throws Exception {
+ @Test public void testNext5() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
while (rs.next()) {
@@ -171,7 +171,7 @@
}
/** test getObject() at columnIndex = 2 of 5th row */
- public void testGetObject1() throws Exception {
+ @Test public void testGetObject1() throws Exception {
List[] results = exampleResults2();
MMResultSet rs = new MMResultSet(exampleResultsMsg2a(),
statement);
@@ -195,7 +195,7 @@
}
/** Should fail, test getObject() at wrong columnIndex */
- public void testGetObject2() throws Exception {
+ @Test public void testGetObject2() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2a(),
statement);
@@ -214,7 +214,7 @@
rs.close();
}
- public void testGetRow() throws Exception {
+ @Test public void testGetRow() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2(),
statement);
@@ -229,7 +229,7 @@
}
- public void testPrevious() throws Exception {
+ @Test public void testPrevious() throws Exception {
List[] results = exampleResults1(5);
MMResultSet rs = new MMResultSet(exampleResultsMsg1(),
statement);
@@ -250,7 +250,7 @@
rs.close();
}
- public void testGetCurrentRecord() throws Exception {
+ @Test public void testGetCurrentRecord() throws Exception {
List[] results = exampleResults2();
MMResultSet rs = new MMResultSet(exampleResultsMsg2(),
statement);
@@ -261,7 +261,7 @@
rs.close();
}
- public void testGetMetaData() throws Exception {
+ @Test public void testGetMetaData() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2a(),
statement);
ResultSetMetaData rmetadata = rs.getMetaData();
@@ -276,20 +276,20 @@
rs.close();
}
- public void testResultsWarnings() throws Exception {
+ @Test public void testResultsWarnings() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2(),
statement);
rs.close();
}
- public void testClose() throws Exception {
+ @Test public void testClose() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2(),
statement);
rs.close();
verify(statement, times(0)).close();
}
- public void testGetFetchSize() throws Exception {
+ @Test public void testGetFetchSize() throws Exception {
MMStatement s = mock(MMStatement.class);
stub(s.getFetchSize()).toReturn(500);
MMResultSet rs = new MMResultSet(exampleResultsMsg2(), s);
@@ -300,27 +300,17 @@
// //////////////////////Functions refer to ResultSet's TYPE_FORWARD_ONLY///
// /////////////////
- public void testIsAfterLast1() throws Exception {
+ @Test(expected=SQLException.class) public void testIsAfterLast1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
-
- // the last row
rs.last();
- boolean actual = rs.isAfterLast();
- assertEquals(false, actual);
- rs.close();
}
- public void testAfterLast1() throws Exception {
+ @Test(expected=SQLException.class) public void testAfterLast1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
-
- // move cursor right past the last row
rs.afterLast();
- assertEquals(0, rs.getRow());
- rs.close();
-
}
- public void testIsBeforeFirst1() throws Exception {
+ @Test public void testIsBeforeFirst1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
// right before the first row
@@ -329,7 +319,7 @@
rs.close();
}
- public void testIsBeforeFirst2() throws Exception {
+ @Test public void testIsBeforeFirst2() throws Exception {
MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
// right before the first row
@@ -338,7 +328,7 @@
rs.close();
}
- public void testBeforeFirst1() throws Exception {
+ @Test(expected=SQLException.class) public void testBeforeFirst1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
// move cursor to the first row
@@ -346,12 +336,9 @@
// move back to before first row
rs.beforeFirst();
-
- assertEquals(0, rs.getRow());
- rs.close();
}
- public void testIsFirst1() throws Exception {
+ @Test public void testIsFirst1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
// move cursor to the first row
@@ -361,7 +348,7 @@
rs.close();
}
- public void testIsFirst2() throws Exception {
+ @Test public void testIsFirst2() throws Exception {
MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
// move cursor to the first row
@@ -371,27 +358,23 @@
rs.close();
}
- public void testFirst1() throws Exception {
+ @Test(expected=SQLException.class) public void testFirst1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
// move cursor to the first row
rs.next();
- boolean actual = rs.first();
- assertEquals(true, actual);
- rs.close();
+ rs.first();
}
- public void testFirst2() throws Exception {
+ @Test(expected=SQLException.class) public void testFirst2() throws Exception {
MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
// move cursor to the first row
rs.next();
- boolean actual = rs.first();
- assertEquals(false, actual);
- rs.close();
+ rs.first();
}
- public void testFindColumn() throws Exception {
+ @Test public void testFindColumn() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2a(),
statement);
@@ -399,45 +382,29 @@
rs.close();
}
- public void testIsLast1() throws Exception {
+ @Test public void testIsLast1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
// move cursor to the last row
- rs.last();
boolean actual = rs.isLast();
- assertEquals(true, actual);
- rs.close();
+ assertEquals(false, actual);
}
- public void testIsLast2() throws Exception {
+ @Test public void testIsLast2() throws Exception {
MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
// move cursor to the last row
- rs.last();
boolean actual = rs.isLast();
assertEquals(false, actual);
- rs.close();
}
- public void testLast1() throws Exception {
+ @Test(expected=SQLException.class) public void testLast1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
- // check whether the movement of cursor is successful
- boolean actual = rs.last();
- assertEquals(true, actual);
- rs.close();
+ rs.last();
}
- public void testLast2() throws Exception {
- MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
-
- // check whether the movement of cursor is successful
- boolean actual = rs.last();
- assertEquals(false, actual);
- rs.close();
- }
-
- public void testRelative1() throws Exception {
+ @Test public void testRelative1() throws Exception {
MMResultSet rs = new MMResultSet(exampleResultsMsg2(),
statement);
@@ -454,28 +421,16 @@
rs.close();
}
- public void testAbsolute1() throws Exception {
+ @Test(expected=SQLException.class) public void testAbsolute1() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY);
- // check whether the movement of cursor is successful
- boolean actual = rs.absolute(1);
- assertEquals(true, actual);
- rs.close();
+ rs.absolute(1);
}
- public void testAbsolute2() throws Exception {
- MMResultSet rs = helpGetNoResults(TYPE_FORWARD_ONLY);
-
- // check whether the movement of cursor is successful
- boolean actual = rs.absolute(1);
- assertEquals(false, actual);
- rs.close();
- }
-
// //////////Functions refer to other types other than ResultSet's
// TYPE_FORWARD_ONLY//////
- public void testAfterLast1a() throws Exception {
+ @Test public void testAfterLast1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move cursor right past the last row
@@ -486,7 +441,7 @@
rs.close();
}
- public void testIsAfterLast1a() throws Exception {
+ @Test public void testIsAfterLast1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// the last row
@@ -501,7 +456,7 @@
rs.close();
}
- public void testIsBeforeFirst1a() throws Exception {
+ @Test public void testIsBeforeFirst1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// right before the first row
@@ -510,7 +465,7 @@
rs.close();
}
- public void testBeforeFirst1a() throws Exception {
+ @Test public void testBeforeFirst1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move cursor to the first row
@@ -524,7 +479,7 @@
rs.close();
}
- public void testIsFirst1a() throws Exception {
+ @Test public void testIsFirst1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move cursor to the first row
@@ -537,7 +492,7 @@
rs.close();
}
- public void testFirst1a() throws Exception {
+ @Test public void testFirst1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move cursor to the first row
@@ -559,7 +514,7 @@
rs.close();
}
- public void testIsLast1a() throws Exception {
+ @Test public void testIsLast1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// check whether the movement of cursor is successful
@@ -572,7 +527,7 @@
rs.close();
}
- public void testLast1a() throws Exception {
+ @Test public void testLast1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// check whether the movement of cursor is successful
@@ -585,7 +540,7 @@
}
/** normal relative move, only including moving from valid row to valid one */
- public void testRelative1a() throws Exception {
+ @Test public void testRelative1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move to 1st row
@@ -603,7 +558,7 @@
}
/** normal relative move, including moving from valid row to invalid one */
- public void testRelative1b() throws Exception {
+ @Test public void testRelative1b() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// move to 1st row
@@ -631,7 +586,7 @@
}
/** check only moving from an invalid row */
- public void testRelative1c() throws Exception {
+ @Test public void testRelative1c() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// test if move before first will work or not
@@ -681,7 +636,7 @@
}
/** test only valid row in result set */
- public void testAbsolute1a() throws Exception {
+ @Test public void testAbsolute1a() throws Exception {
MMResultSet rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE);
// start from beginning
@@ -706,7 +661,7 @@
}
/** test only valid row in result set */
- public void testAbsolute2a() throws Exception {
+ @Test public void testAbsolute2a() throws Exception {
MMResultSet rs = helpGetNoResults(TYPE_SCROLL_SENSITIVE);
// start from beginning
@@ -725,7 +680,7 @@
* Case 4293 - timestamps for begin and end processing should both be set
* server-side (from the same system clock)
*/
- public void testProcessingTime() throws Exception {
+ @Test public void testProcessingTime() throws Exception {
RequestMessage request = new RequestMessage();
request.setProcessingTimestamp(new Date(12345678L));
ResultsMessage resultsMsg = new ResultsMessage(request);
@@ -753,7 +708,7 @@
/**
* 3 batches
*/
- public void testMoreResults() throws Exception {
+ @Test public void testMoreResults() throws Exception {
int fetchSize = 5;
int batchLength = 4;
int totalLength = 10;
@@ -772,27 +727,26 @@
static MMResultSet helpTestBatching(MMStatement statement, int fetchSize, int batchLength,
int totalLength) throws InterruptedException, ExecutionException,
- MetaMatrixProcessingException, SQLException {
+ MetaMatrixProcessingException, SQLException, TimeoutException {
ClientSideDQP dqp = mock(ClientSideDQP.class);
stub(statement.getDQP()).toReturn(dqp);
stub(statement.getFetchSize()).toReturn(fetchSize);
for (int i = batchLength; i < totalLength; i += batchLength) {
//forward requests
ResultsFuture<ResultsMessage> nextBatch = mock(ResultsFuture.class);
- stub(nextBatch.get()).toReturn(exampleResultsMsg4(i + 1, Math.min(batchLength, totalLength - i), fetchSize, i + batchLength >= totalLength));
+ stub(nextBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i + 1, Math.min(batchLength, totalLength - i), fetchSize, i + batchLength >= totalLength));
stub(dqp.processCursorRequest(REQUEST_ID, i + 1, fetchSize)).toReturn(nextBatch);
if (i + batchLength < totalLength) {
//backward requests
ResultsFuture<ResultsMessage> previousBatch = mock(ResultsFuture.class);
- stub(previousBatch.get()).toReturn(exampleResultsMsg4(i - batchLength + 1, i, fetchSize, false));
+ stub(previousBatch.get(Matchers.anyLong(), (TimeUnit)Matchers.anyObject())).toReturn(exampleResultsMsg4(i - batchLength + 1, i, fetchSize, false));
stub(dqp.processCursorRequest(REQUEST_ID, i, fetchSize)).toReturn(previousBatch);
}
}
ResultsMessage msg = exampleResultsMsg4(1, batchLength, fetchSize, batchLength == totalLength);
- MMResultSet rs = new MMResultSet(msg, statement);
- return rs;
+ return new MMResultSet(msg, statement);
}
// /////////////////////Helper Method///////////////////
@@ -840,12 +794,14 @@
private MMResultSet helpGetResultSetImpl(int type)
throws SQLException {
ResultsMessage rsMsg = exampleResultsMsg2();
+ statement = TestMMResultSet.createMockStatement(type);
MMResultSet rs = new MMResultSet(rsMsg, statement);
return rs;
}
private MMResultSet helpGetNoResults(int type) throws SQLException {
ResultsMessage rsMsg = exampleResultsMsg3();
+ statement = TestMMResultSet.createMockStatement(type);
MMResultSet rs = new MMResultSet(rsMsg, statement);
return rs;
}
@@ -909,7 +865,7 @@
return resultsMsg;
}
- public void testNotCallingNext() throws SQLException {
+ @Test public void testNotCallingNext() throws SQLException {
MMResultSet cs = new MMResultSet(exampleResultsMsg2a(),
statement);
@@ -921,7 +877,7 @@
}
}
- public void testDateType() throws SQLException {
+ @Test public void testDateType() throws SQLException {
RequestMessage request = new RequestMessage();
request.setProcessingTimestamp(new Date(1L));
request.setExecutionId(REQUEST_ID);
@@ -943,8 +899,8 @@
assertEquals(new Timestamp(0), rs.getTimestamp(1, Calendar.getInstance(TimeZone.getTimeZone("GMT-05:00")))); //$NON-NLS-1$
}
- public void testWasNull() throws SQLException{
- ResultsMessage message = exampleMessage(new List[] { Arrays.asList((String)null), Arrays.asList("1") }, new String[] { "string" }, //$NON-NLS-1$ //$NON-NLS-1$
+ @Test public void testWasNull() throws SQLException{
+ ResultsMessage message = exampleMessage(new List[] { Arrays.asList((String)null), Arrays.asList("1") }, new String[] { "string" }, //$NON-NLS-1$
new String[] { MMJDBCSQLTypeInfo.STRING });
MMResultSet rs = new MMResultSet(message, statement);
assertTrue(rs.next());
@@ -956,9 +912,9 @@
assertTrue(rs.wasNull());
assertEquals(0l, rs.getLong(1));
assertTrue(rs.wasNull());
- assertEquals(0f, rs.getFloat(1));
+ assertEquals(0f, rs.getFloat(1), 0);
assertTrue(rs.wasNull());
- assertEquals(0d, rs.getDouble(1));
+ assertEquals(0d, rs.getDouble(1), 0);
assertTrue(rs.wasNull());
assertNull(rs.getString(1));
assertTrue(rs.wasNull());
@@ -968,7 +924,7 @@
assertFalse(rs.next());
}
- public void testGetters() throws SQLException{
+ @Test public void testGetters() throws SQLException{
TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00")); //$NON-NLS-1$
ResultsMessage message = exampleMessage(new List[] { Arrays.asList(1, TimestampUtil.createTime(0, 0, 0), TimestampUtil.createDate(1, 1, 1), TimestampUtil.createTimestamp(1, 1, 1, 1, 1, 1, 1), "<root/>") }, //$NON-NLS-1$
new String[] { "int", "time", "date", "timestamp", "sqlxml" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
@@ -980,8 +936,8 @@
assertEquals(1, rs.getShort(1));
assertEquals(1, rs.getInt(1));
assertEquals(1l, rs.getLong(1));
- assertEquals(1f, rs.getFloat(1));
- assertEquals(1d, rs.getDouble(1));
+ assertEquals(1f, rs.getFloat(1), 0);
+ assertEquals(1d, rs.getDouble(1), 0);
assertEquals("1", rs.getString(1)); //$NON-NLS-1$
assertEquals(Integer.valueOf(1), rs.getObject(1));
//the mock statement is in GMT-6 the server results are from GMT-5, so we expect them to display the same
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestBatchResults.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestBatchResults.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestBatchResults.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,20 +22,20 @@
package com.metamatrix.jdbc;
+import static org.junit.Assert.*;
+
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import org.junit.Test;
+
import com.metamatrix.jdbc.BatchResults.Batch;
-import junit.framework.TestCase;
-
-
-
/**
* @since 4.3
*/
-public class TestBatchResults extends TestCase {
+public class TestBatchResults {
static class MockBatchFetcher implements BatchFetcher {
@@ -81,10 +81,6 @@
}
- public TestBatchResults (String name) {
- super(name);
- }
-
private static List[] createBatch(int begin, int end) {
List[] results = new List[end - begin + 1];
for(int i=0; i<(end - begin + 1); i++) {
@@ -98,9 +94,8 @@
List[] results = new List[0];
return results;
}
-
- public void testGetCurrentRow1() throws Exception{
+ @Test public void testGetCurrentRow1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertNull(batchResults.getCurrentRow());
@@ -108,7 +103,7 @@
assertNull(batchResults.getCurrentRow());
}
- public void testGetCurrentRow2() throws Exception{
+ @Test public void testGetCurrentRow2() throws Exception{
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, true);
assertNull(batchResults.getCurrentRow());
batchResults.next();
@@ -117,30 +112,30 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testHasNext1() throws Exception{
+ @Test public void testHasNext1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertFalse(batchResults.hasNext());
}
- public void testHasNext2() throws Exception{
+ @Test public void testHasNext2() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
assertTrue(batchResults.hasNext());
}
- public void testHasNext3() throws Exception{
+ @Test public void testHasNext3() throws Exception{
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, true);
assertTrue(batchResults.hasNext());
}
- public void testNext1() throws Exception{
+ @Test public void testNext1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertFalse(batchResults.next());
}
- public void testNext2() throws Exception{
+ @Test public void testNext2() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
assertTrue(batchResults.next());
@@ -150,7 +145,7 @@
assertFalse(batchResults.next());
}
- public void testNext3() throws Exception{
+ @Test public void testNext3() throws Exception{
//one row batch, multiple batches
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
@@ -161,7 +156,7 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testNext4() throws Exception{
+ @Test public void testNext4() throws Exception{
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
int i;
@@ -179,13 +174,13 @@
assertFalse(batchResults.next());
}
- public void testHasPrevious1() throws Exception{
+ @Test public void testHasPrevious1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertFalse(batchResults.hasPrevious());
}
- public void testHasPrevious2() throws Exception{
+ @Test public void testHasPrevious2() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
assertFalse(batchResults.hasPrevious());
@@ -195,13 +190,13 @@
assertTrue(batchResults.hasPrevious());
}
- public void testPrevious1() throws Exception{
+ @Test public void testPrevious1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertFalse(batchResults.previous());
}
- public void testPrevious2() throws Exception{
+ @Test public void testPrevious2() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
assertTrue(batchResults.next());
@@ -214,7 +209,7 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testPrevious3() throws Exception{
+ @Test public void testPrevious3() throws Exception{
//one row batch, multiple batches
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
@@ -235,7 +230,7 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testPrevious4() throws Exception{
+ @Test public void testPrevious4() throws Exception{
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
int i;
@@ -250,14 +245,14 @@
}
}
- public void testAbsolute1() throws Exception{
+ @Test public void testAbsolute1() throws Exception{
//empty batch
BatchResults batchResults = new BatchResults(createEmptyBatch(), 0, 0, true);
assertFalse(batchResults.absolute(0));
assertFalse(batchResults.absolute(1));
}
- public void testAbsolute2() throws Exception{
+ @Test public void testAbsolute2() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
batchResults.setBatchFetcher(new MockBatchFetcher());
@@ -269,7 +264,7 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testAbsolute3() throws Exception{
+ @Test public void testAbsolute3() throws Exception{
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, false);
batchResults.setBatchFetcher(new MockBatchFetcher(200));
assertFalse(batchResults.absolute(0));
@@ -288,7 +283,7 @@
}
//move backwards with absolute
- public void testAbsolute4() throws Exception{
+ @Test public void testAbsolute4() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
@@ -299,7 +294,7 @@
assertEquals(batchResults.getCurrentRow(), expectedResult);
}
- public void testAbsolute5() throws Exception{
+ @Test public void testAbsolute5() throws Exception{
//one row batch
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, false);
batchResults.setBatchFetcher(new MockBatchFetcher());
@@ -311,7 +306,7 @@
assertFalse(batchResults.absolute(-100));
}
- public void testCurrentRowNumber() throws Exception {
+ @Test public void testCurrentRowNumber() throws Exception {
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, true);
assertEquals(0, batchResults.getCurrentRowNumber());
batchResults.next();
@@ -322,7 +317,7 @@
assertEquals(2, batchResults.getCurrentRowNumber());
}
- public void testSetException() throws Exception {
+ @Test public void testSetException() throws Exception {
BatchResults batchResults = new BatchResults(createBatch(1, 1), 1, 1, false);
MockBatchFetcher batchFetcher = new MockBatchFetcher();
batchResults.setBatchFetcher(batchFetcher);
@@ -335,7 +330,7 @@
}
}
- public void testBatching() throws Exception {
+ @Test public void testBatching() throws Exception {
BatchResults batchResults = new BatchResults(createBatch(1, 10), 1, 10, false);
MockBatchFetcher batchFetcher = new MockBatchFetcher(60);
batchResults.setBatchFetcher(batchFetcher);
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -613,7 +613,7 @@
ds.setServerName("hostName"); //$NON-NLS-1$
ds.setDatabaseName("vdbName"); //$NON-NLS-1$
ds.setPortNumber(1);
- assertEquals("jdbc:teiid:vdbName@mm://hostname:1;fetchSize=2000;ApplicationName=JDBC;serverURL=mm://hostname:1;a=b;VirtualDatabaseName=vdbName;foo=bar", ds.buildURL()); //$NON-NLS-1$
+ assertEquals("jdbc:teiid:vdbName@mm://hostname:1;fetchSize=2048;ApplicationName=JDBC;serverURL=mm://hostname:1;a=b;VirtualDatabaseName=vdbName;foo=bar", ds.buildURL()); //$NON-NLS-1$
}
public void testInvalidDataSource() {
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,6 +22,7 @@
package com.metamatrix.jdbc;
+import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.sql.ResultSet;
@@ -29,31 +30,30 @@
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.message.ResultsMessage;
-public class TestMMResultSet extends TestCase {
+public class TestMMResultSet {
- public TestMMResultSet(String name) {
- super(name);
- }
-
/** test next() without walking through */
- public void testNext1() throws SQLException {
+ @Test public void testNext1() throws SQLException {
ResultSet cs = helpExecuteQuery();
assertEquals(" Actual doesn't match with expected. ", new Integer(0), new Integer(cs.getRow())); //$NON-NLS-1$
cs.close();
}
/** test next() with walking through all the rows and compare records */
- public void testNext2() throws SQLException {
+ @Test public void testNext2() throws SQLException {
List[] expected = TestAllResultsImpl.exampleResults1(1000);
MMResultSet cs = helpExecuteQuery();
@@ -74,37 +74,37 @@
public static final int PROC_BATCH_SIZE = 100;
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchEqualsCount() throws Exception {
+ @Test public void testNextBeyondEnd_fetchEqualsCount() throws Exception {
helpTestNextBeyondResultSet(1000, 1000);
}
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchLessThanCount() throws Exception {
+ @Test public void testNextBeyondEnd_fetchLessThanCount() throws Exception {
helpTestNextBeyondResultSet(100, 1000);
}
/** Test stability when next() is called beyond the rowcount with one more row. */
- public void testNextBeyondEnd_fetchLessThanCount1() throws Exception {
+ @Test public void testNextBeyondEnd_fetchLessThanCount1() throws Exception {
helpTestNextBeyondResultSet(100, 101);
}
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchLessThanCountNonMultiple() throws Exception {
+ @Test public void testNextBeyondEnd_fetchLessThanCountNonMultiple() throws Exception {
helpTestNextBeyondResultSet(120, 1000);
}
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchGreaterThanCount() throws Exception {
+ @Test public void testNextBeyondEnd_fetchGreaterThanCount() throws Exception {
helpTestNextBeyondResultSet(300, PROC_BATCH_SIZE);
}
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchGreaterThanCountNonMultiple() throws Exception {
+ @Test public void testNextBeyondEnd_fetchGreaterThanCountNonMultiple() throws Exception {
helpTestNextBeyondResultSet(310, PROC_BATCH_SIZE-50);
}
/** Test stability when next() is called beyond the rowcount. */
- public void testNextBeyondEnd_fetchGreaterThanCountNonMultiple2() throws Exception {
+ @Test public void testNextBeyondEnd_fetchGreaterThanCountNonMultiple2() throws Exception {
helpTestNextBeyondResultSet(300, PROC_BATCH_SIZE+10);
}
@@ -112,12 +112,12 @@
* fetchSize < rows < proc batch size.
* Test for defect 11356
*/
- public void testNextBeyondEnd_fetchLessThanCount_ResultsBetweenFetchAndProcBatch() throws Exception {
+ @Test public void testNextBeyondEnd_fetchLessThanCount_ResultsBetweenFetchAndProcBatch() throws Exception {
helpTestNextBeyondResultSet(30, PROC_BATCH_SIZE-25);
}
public void helpTestNextBeyondResultSet(int fetchSize, int numRows) throws Exception {
- ResultSet cs = helpExecuteQuery(fetchSize, numRows);
+ ResultSet cs = helpExecuteQuery(fetchSize, numRows, ResultSet.TYPE_SCROLL_INSENSITIVE);
try {
Object lastRowValue = null;
for (int rowNum = 1; rowNum <= numRows; rowNum++) {
@@ -143,7 +143,7 @@
}
/** test both next() and previous() -- when result set scroll in bidirection */
- public void testBidirection() throws SQLException {
+ @Test public void testBidirection() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertNotNull(cs);
cs.absolute(290);
@@ -160,14 +160,14 @@
}
/** test hasNext() without walking through any row */
- public void testHasNext1() throws SQLException {
+ @Test public void testHasNext1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertEquals(" hasNext() doesn't match expected value. ", true, cs.hasNext()); //$NON-NLS-1$
cs.close();
}
/** test hasNext() with blocking for the Next batch -- triggering point */
- public void testHasNext2() throws SQLException {
+ @Test public void testHasNext2() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(100);
assertEquals(" hasNext() doesn't match expected value. ", true, cs.hasNext()); //$NON-NLS-1$
@@ -175,7 +175,7 @@
}
/** test hasNext() with nextBatch!=null -- short response */
- public void testHasNext3() throws SQLException {
+ @Test public void testHasNext3() throws SQLException {
MMResultSet cs = helpExecuteQuery();
int i = 0;
while (cs.next()) {
@@ -189,7 +189,7 @@
}
/** at the end of all batches */
- public void testHasNext4() throws SQLException {
+ @Test public void testHasNext4() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(1000);
assertTrue(!cs.hasNext());
@@ -197,7 +197,7 @@
}
/** walk all way through from the end back to first row */
- public void testPrevious1() throws SQLException {
+ @Test public void testPrevious1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
List[] expected = TestAllResultsImpl.exampleResults1(1000);
while(cs.next()) {
@@ -217,7 +217,7 @@
}
/** test the previous in the middle of a batch */
- public void testPrevious2() throws SQLException {
+ @Test public void testPrevious2() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(290);
@@ -228,9 +228,9 @@
}
/** walk all way through from the end back to first row */
- public void testPrevious3() throws SQLException {
+ @Test public void testPrevious3() throws Exception {
//large batch size
- MMResultSet cs = helpExecuteQuery(600, 10000);
+ MMResultSet cs = helpExecuteQuery(600, 10000, ResultSet.TYPE_SCROLL_INSENSITIVE);
List[] expected = TestAllResultsImpl.exampleResults1(10000);
while(cs.next()) {
}
@@ -248,9 +248,9 @@
}
/** walk all way through from the end back to first row */
- public void testPrevious4() throws SQLException {
+ @Test public void testPrevious4() throws Exception {
//small batch size
- MMResultSet cs = helpExecuteQuery(50, 1000);
+ MMResultSet cs = helpExecuteQuery(50, 1000, ResultSet.TYPE_SCROLL_INSENSITIVE);
List[] expected = TestAllResultsImpl.exampleResults1(1000);
while(cs.next()) {
//System.out.println(" rs.next == " + cs.getCurrentRecord());
@@ -269,7 +269,7 @@
}
/** test rare case that cursor change direction */
- public void testChangeDirection() throws SQLException {
+ @Test public void testChangeDirection() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(291);
cs.previous();
@@ -278,7 +278,7 @@
cs.close();
}
- public void testIsFirst() throws SQLException {
+ @Test public void testIsFirst() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.next();
assertTrue(cs.isFirst());
@@ -286,7 +286,7 @@
}
/** test cursor is in the middle of all batches */
- public void testIsLast1() throws SQLException {
+ @Test public void testIsLast1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.next();
assertTrue(!cs.isLast());
@@ -294,7 +294,7 @@
}
/** test cursor at the triggering point -- blocking case*/
- public void testIsLast2() throws SQLException {
+ @Test public void testIsLast2() throws SQLException {
MMResultSet cs = helpExecuteQuery();
int i = 0;
@@ -310,20 +310,20 @@
}
/** test cursor at the last row of all batches */
- public void testIsLast3() throws SQLException {
+ @Test public void testIsLast3() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(1000);
assertTrue(cs.isLast());
cs.close();
}
- public void testIsBeforeFirst() throws SQLException {
+ @Test public void testIsBeforeFirst() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertTrue(cs.isBeforeFirst());
cs.close();
}
- public void testBeforeFirst() throws SQLException {
+ @Test public void testBeforeFirst() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row 1
@@ -336,7 +336,7 @@
cs.close();
}
- public void testFirst() throws SQLException {
+ @Test public void testFirst() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -350,7 +350,7 @@
cs.close();
}
- public void testAfterLast() throws SQLException {
+ @Test public void testAfterLast() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.afterLast();
assertTrue(cs.isAfterLast());
@@ -358,7 +358,7 @@
}
/** right after the last row */
- public void testIsAfterLast1() throws SQLException {
+ @Test public void testIsAfterLast1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(1000);
cs.next();
@@ -367,14 +367,14 @@
}
/** right before the first */
- public void testIsAfterLast2() throws Exception {
+ @Test public void testIsAfterLast2() throws Exception {
MMResultSet cs = helpExecuteQuery();
assertTrue(!cs.isAfterLast());
cs.close();
}
/** absolute with cursor movement backward in the same batch -- absolute(positive) */
- public void testAbsolute1() throws SQLException {
+ @Test public void testAbsolute1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -389,7 +389,7 @@
}
/** absolute with cursor movement forward in the same batch -- absolute(positive) */
- public void testAbsolute2() throws SQLException {
+ @Test public void testAbsolute2() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -404,7 +404,7 @@
}
/** absolute with cursor movement forward -- absolute(positive) -- blocking */
- public void testAbsolute3() throws SQLException {
+ @Test public void testAbsolute3() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -419,7 +419,7 @@
}
/** absolute with cursor movement forward -- absolute(positive) -- triggering point */
- public void testAbsolute4() throws SQLException {
+ @Test public void testAbsolute4() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -434,7 +434,7 @@
}
/** absolute with cursor movement back in the same batch -- absolute(negative) */
- public void testAbsolute5() throws SQLException {
+ @Test public void testAbsolute5() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to row #2
@@ -449,7 +449,7 @@
}
/** absolute after last row */
- public void testAbsolute6() throws SQLException {
+ @Test public void testAbsolute6() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.absolute(1005);
// Cursor should be after last row. getRow() should return 0 because
@@ -459,7 +459,7 @@
}
/** relative(positive) -- forward to another batch */
- public void testRelative1() throws SQLException {
+ @Test public void testRelative1() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to the row #3
@@ -473,7 +473,7 @@
}
/** relative(negative) -- backward to another batch */
- public void testRelative2() throws SQLException {
+ @Test public void testRelative2() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to the row #137
@@ -487,7 +487,7 @@
}
/** relative(negative) -- backward to triggering point or blocking batch */
- public void testRelative3() throws SQLException {
+ @Test public void testRelative3() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to the row #137
@@ -501,7 +501,7 @@
}
/** relative(negative) -- backward to triggering point or blocking batch */
- public void testRelative4() throws SQLException {
+ @Test public void testRelative4() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// move to the row #237 in the third batch, so that the fourth batch has been requested when we switch direction
@@ -515,7 +515,7 @@
}
/** in the first fetched batch */
- public void testGetRow1() throws SQLException {
+ @Test public void testGetRow1() throws SQLException {
ResultSet cs = helpExecuteQuery();
int i = 0;
@@ -531,7 +531,7 @@
}
/** in the first batch */
- public void testGetRow2() throws SQLException {
+ @Test public void testGetRow2() throws SQLException {
ResultSet cs = helpExecuteQuery();
cs.next();
@@ -540,7 +540,7 @@
}
/** in the triggering point -- blocking */
- public void testGetRow3() throws SQLException {
+ @Test public void testGetRow3() throws SQLException {
ResultSet cs = helpExecuteQuery();
int i = 0;
while (cs.next()) {
@@ -553,7 +553,7 @@
cs.close();
}
- public void testGetCurrentRecord() throws SQLException {
+ @Test public void testGetCurrentRecord() throws SQLException {
ResultSet cs = helpExecuteQuery();
cs.absolute(103);
assertEquals(" Current record doesn't match with expected one.", new Integer(103), ((MMResultSet)cs).getCurrentRecord().get(0)); //$NON-NLS-1$
@@ -561,14 +561,14 @@
}
/** test close() without walking through any of the record*/
- public void testClose() throws SQLException {
+ @Test public void testClose() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertEquals(" Actual doesn't match with expected. ", new Integer(0), new Integer(cs.getRow())); //$NON-NLS-1$
cs.close();
}
/** test basic results-related metadata */
- public void testGetMetaData() throws SQLException {
+ @Test public void testGetMetaData() throws SQLException {
MMResultSet cs = helpExecuteQuery();
// check result set metadata
@@ -589,7 +589,7 @@
cs.close();
}
- public void testFindColumn() throws SQLException {
+ @Test public void testFindColumn() throws SQLException {
MMResultSet cs = helpExecuteQuery();
ResultSetMetaData rm = cs.getMetaData();
assertNotNull(rm);
@@ -598,7 +598,7 @@
cs.close();
}
- public void testFindNonExistentColumn() throws SQLException {
+ @Test public void testFindNonExistentColumn() throws SQLException {
ResultSet rs = helpExecuteQuery();
rs.next();
try {
@@ -613,13 +613,13 @@
rs.close();
}
- public void testGetStatement() throws SQLException {
+ @Test public void testGetStatement() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertNotNull(cs.getStatement());
cs.close();
}
- public void testGetPlanDescription() throws SQLException {
+ @Test public void testGetPlanDescription() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertNotNull(cs);
@@ -628,7 +628,7 @@
}
/** getObject(String) */
- public void testGetObject2() throws SQLException {
+ @Test public void testGetObject2() throws SQLException {
ResultSet cs = helpExecuteQuery();
// move to the 1st row
@@ -637,19 +637,19 @@
cs.close();
}
- public void testGetWarnings() throws SQLException {
+ @Test public void testGetWarnings() throws SQLException {
ResultSet cs = helpExecuteQuery();
assertNull(cs.getWarnings());
cs.close();
}
- public void testGetCursorName() throws SQLException {
+ @Test public void testGetCursorName() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertNull(cs.getCursorName());
cs.close();
}
- public void testAllGetters() throws SQLException {
+ @Test public void testAllGetters() throws SQLException {
MMResultSet cs = helpExecuteQuery();
cs.next();
assertEquals(" Actual value of getInt() doesn't match with expected one. ", 1, cs.getInt("IntKey")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -663,7 +663,7 @@
}
/** test wasNull() for ResultSet, this result actually is not a cursor result, but AllResults here. */
- public void testWasNull() throws SQLException {
+ @Test public void testWasNull() throws SQLException {
ResultSet cs = helpExecuteQuery();
cs.next();
assertNotNull(cs.getObject("IntKey")); //$NON-NLS-1$
@@ -671,36 +671,64 @@
}
/** test getProcessingTime() -- include test for getProcessingTimestamp() and getCompletedTimestamp() */
- public void testGetProcessingTime() throws SQLException {
+ @Test public void testGetProcessingTime() throws SQLException {
MMResultSet cs = helpExecuteQuery();
assertTrue(cs.getProcessingTime() == cs.getCompletedTimestamp().getTime() - 1);
cs.close();
}
+
+ @Test public void testForwardOnly() throws Exception {
+ MMResultSet cs = helpExecuteQuery(400, 1000, ResultSet.TYPE_FORWARD_ONLY);
+
+ while (cs.next()) {
+ cs.getObject(1);
+ }
+
+ assertTrue(cs.isAfterLast());
+ cs.close();
+ }
+
+ @Test public void testOutputParameter() throws Exception {
+ MMStatement statement = createMockStatement(ResultSet.TYPE_FORWARD_ONLY);
+ ResultsMessage resultsMsg = new ResultsMessage();
+ resultsMsg.setResults(new List<?>[] {Arrays.asList(1, null, null), Arrays.asList(null, 2, 3)});
+ resultsMsg.setLastRow(2);
+ resultsMsg.setFirstRow(1);
+ resultsMsg.setFinalRow(2);
+ resultsMsg.setColumnNames(new String[] {"x", "out1", "out2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ resultsMsg.setDataTypes(new String[] {"integer", "integer", "integer"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ MMResultSet cs = new MMResultSet(resultsMsg, statement, null, 2);
+
+ int count = 0;
+ while (cs.next()) {
+ cs.getObject(1);
+ count++;
+ }
+ assertEquals(1, count);
+ assertTrue(cs.isAfterLast());
+ assertEquals(2, cs.getOutputParamValue(2));
+ assertEquals(3, cs.getOutputParamValue(3));
+ }
/////////////////////// Helper Method ///////////////////
- private MMResultSet helpExecuteQuery() throws SQLException {
- return helpExecuteQuery(400, 1000);
- }
-
- private MMResultSet helpExecuteQuery(int fetchSize, int totalResults) throws SQLException {
- MMStatement statement = createMockStatement();
+ private MMResultSet helpExecuteQuery() {
try {
- return TestAllResultsImpl.helpTestBatching(statement, fetchSize, Math.min(fetchSize, totalResults), totalResults);
- } catch (MetaMatrixProcessingException e) {
- throw new SQLException(e.getMessage());
- } catch (InterruptedException e) {
- throw new SQLException(e.getMessage());
- } catch (ExecutionException e) {
- throw new SQLException(e.getMessage());
+ return helpExecuteQuery(400, 1000, ResultSet.TYPE_SCROLL_INSENSITIVE);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
+
+ private MMResultSet helpExecuteQuery(int fetchSize, int totalResults, int cursorType) throws SQLException, MetaMatrixProcessingException, InterruptedException, ExecutionException, TimeoutException {
+ MMStatement statement = createMockStatement(cursorType);
+ return TestAllResultsImpl.helpTestBatching(statement, fetchSize, Math.min(fetchSize, totalResults), totalResults);
+ }
- static MMStatement createMockStatement() throws SQLException {
+ static MMStatement createMockStatement(int cursorType) throws SQLException {
MMStatement statement = mock(MMStatement.class);
stub(statement.getDQP()).toReturn(mock(ClientSideDQP.class));
- stub(statement.getResultSetType()).toReturn(
- ResultSet.TYPE_SCROLL_INSENSITIVE);
+ stub(statement.getResultSetType()).toReturn(cursorType);
TimeZone tz = TimeZone.getTimeZone("GMT-06:00"); //$NON-NLS-1$
TimeZone serverTz = TimeZone.getTimeZone("GMT-05:00"); //$NON-NLS-1$
stub(statement.getDefaultCalendar()).toReturn(Calendar.getInstance(tz));
Modified: branches/JCA/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,8 +22,6 @@
package com.metamatrix.common.types;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
@@ -130,24 +128,6 @@
this.reference.truncate(len);
}
- /**
- * Utility Method to convert blob into byte array
- * @param blob
- * @return byte array
- */
- public static byte[] getByteArray(Blob blob) throws SQLException, IOException {
- InputStream reader = blob.getBinaryStream();
- ByteArrayOutputStream writer = new ByteArrayOutputStream();
- int c = reader.read();
- while (c != -1) {
- writer.write((byte)c);
- c = reader.read();
- }
- reader.close();
- byte[] data = writer.toByteArray();
- writer.close();
- return data;
- }
//## JDBC4.0-begin ##
public void free() throws SQLException {
this.reference.free();
Modified: branches/JCA/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -23,6 +23,7 @@
package com.metamatrix.common.types;
import java.io.IOException;
+import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Blob;
@@ -42,6 +43,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.WeakHashMap;
import javax.xml.transform.Source;
@@ -61,6 +63,7 @@
import com.metamatrix.common.types.basic.NumberToLongTransform;
import com.metamatrix.common.types.basic.NumberToShortTransform;
import com.metamatrix.common.types.basic.ObjectToAnyTransform;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.ErrorMessageKeys;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -81,6 +84,11 @@
* </p>
*/
public class DataTypeManager {
+
+ private static final int MAX_VALUE_MAP_SIZE = 10000;
+ private static boolean USE_VALUE_CACHE = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.useValueCache", true); //$NON-NLS-1$
+
+ private static Map<Class<?>, Map<Object, WeakReference<Object>>> valueMaps = new HashMap<Class<?>, Map<Object, WeakReference<Object>>>();
public static final int MAX_STRING_LENGTH = 4000;
@@ -418,19 +426,33 @@
*/
static void loadDataTypes() {
DataTypeManager.addDataType(DefaultDataTypes.BOOLEAN, DefaultDataClasses.BOOLEAN);
+ valueMaps.put(DefaultDataClasses.BOOLEAN, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.BYTE, DefaultDataClasses.BYTE);
+ valueMaps.put(DefaultDataClasses.BYTE, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.SHORT, DefaultDataClasses.SHORT);
+ valueMaps.put(DefaultDataClasses.SHORT, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.CHAR, DefaultDataClasses.CHAR);
+ valueMaps.put(DefaultDataClasses.CHAR, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.INTEGER, DefaultDataClasses.INTEGER);
+ valueMaps.put(DefaultDataClasses.INTEGER, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.LONG, DefaultDataClasses.LONG);
+ valueMaps.put(DefaultDataClasses.LONG, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.BIG_INTEGER, DefaultDataClasses.BIG_INTEGER);
+ valueMaps.put(DefaultDataClasses.BIG_INTEGER, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.FLOAT, DefaultDataClasses.FLOAT);
+ valueMaps.put(DefaultDataClasses.FLOAT, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.DOUBLE, DefaultDataClasses.DOUBLE);
+ valueMaps.put(DefaultDataClasses.DOUBLE, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.BIG_DECIMAL, DefaultDataClasses.BIG_DECIMAL);
+ valueMaps.put(DefaultDataClasses.BIG_DECIMAL, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.DATE, DefaultDataClasses.DATE);
+ valueMaps.put(DefaultDataClasses.DATE, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.TIME, DefaultDataClasses.TIME);
+ valueMaps.put(DefaultDataClasses.TIME, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.TIMESTAMP, DefaultDataClasses.TIMESTAMP);
+ valueMaps.put(DefaultDataClasses.TIMESTAMP, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.STRING, DefaultDataClasses.STRING);
+ valueMaps.put(DefaultDataClasses.STRING, Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Object>>()));
DataTypeManager.addDataType(DefaultDataTypes.CLOB, DefaultDataClasses.CLOB);
DataTypeManager.addDataType(DefaultDataTypes.XML, DefaultDataClasses.XML);
DataTypeManager.addDataType(DefaultDataTypes.OBJECT, DefaultDataClasses.OBJECT);
@@ -686,7 +708,8 @@
Object[] params = new Object[] { sourceType, targetClass, value};
throw new TransformationException(CorePlugin.Util.getString("ObjectToAnyTransform.Invalid_value", params)); //$NON-NLS-1$
}
- return (T) transform.transform(value);
+ T result = (T) transform.transform(value);
+ return getCanonicalValue(result);
}
public static boolean isNonComparable(String type) {
@@ -699,4 +722,29 @@
public static <S> void addSourceTransform(Class<S> sourceClass, SourceTransform<S, ?> transform) {
sourceConverters.put(sourceClass, transform);
}
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getCanonicalValue(T value) {
+ if (USE_VALUE_CACHE) {
+ if (value == null) {
+ return null;
+ }
+ Map<Object, WeakReference<Object>> valueMap = valueMaps.get(value.getClass());
+ if (valueMap == null) {
+ return value;
+ }
+ WeakReference<Object> valueReference = valueMap.get(value);
+ Object canonicalValue = null;
+ if (valueReference != null) {
+ canonicalValue = valueReference.get();
+ }
+ if (canonicalValue != null) {
+ return (T)canonicalValue;
+ }
+ if (valueMap.size() <= MAX_VALUE_MAP_SIZE) {
+ valueMap.put(value, new WeakReference<Object>(value));
+ }
+ }
+ return value;
+ }
}
Copied: branches/JCA/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java (from rev 1798, trunk/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java)
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java (rev 0)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/core/util/AccessibleByteArrayOutputStream.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,45 @@
+/*
+ * 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 com.metamatrix.core.util;
+
+import java.io.ByteArrayOutputStream;
+
+public class AccessibleByteArrayOutputStream extends ByteArrayOutputStream {
+
+ public AccessibleByteArrayOutputStream() {
+ super();
+ }
+
+ public AccessibleByteArrayOutputStream(int size) {
+ super(size);
+ }
+
+ public byte[] getBuffer() {
+ return this.buf;
+ }
+
+ public int getCount() {
+ return this.count;
+ }
+
+}
\ No newline at end of file
Modified: branches/JCA/common-core/src/main/java/com/metamatrix/core/util/HashCodeUtil.java
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/core/util/HashCodeUtil.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/core/util/HashCodeUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,7 +22,6 @@
package com.metamatrix.core.util;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -71,17 +70,13 @@
return hashCode(previous, (x == 0.0) ? 0L : Double.doubleToLongBits(x));
}
- public static final int hashCode(int previous, Object x) {
- return (x == null) ? (PRIME*previous) : (PRIME*previous) + x.hashCode();
- }
-
- public static final int hashCode(int previous, Object[] x) {
+ public static final int hashCode(int previous, Object... x) {
if(x == null) {
return PRIME*previous;
}
- int hc = 0;
+ int hc = previous;
for(int i=0; i<x.length; i++) {
- hc = hashCode(hc, x[i]);
+ hc = (x[i] == null) ? (PRIME*hc) : (PRIME*hc) + x[i].hashCode();
}
return hc;
}
@@ -107,26 +102,6 @@
}
/**
- * Compute a hash code on a large list by walking the list
- * and combining the hash code at every exponential index:
- * 1, 2, 4, 8, ... This has been shown to give a good hash
- * for good time complexity.
- */
- public static final int expHashCode(int previous, List x) {
- if(x == null) {
- return PRIME*previous;
- }
- int hc = (PRIME*previous) + x.size();
- int index = 1;
- int xlen = x.size()+1; // switch to 1-based
- while(index < xlen) {
- hc = hashCode(hc, x.get(index-1));
- index = index << 1; // left shift by 1 to double
- }
- return hc;
- }
-
- /**
* Compute a hash code on a large collection by walking the list
* and combining the hash code at every exponential index:
* 1, 2, 4, 8, ... This has been shown to give a good hash
@@ -134,7 +109,7 @@
* the collection and pull the necessary hash code values.
* Slower than a List or array but faster than getting EVERY value.
*/
- public static final int expHashCode(int previous, Collection x) {
+ public static final int expHashCode(int previous, List x) {
if(x == null || x.size() == 0) {
return PRIME*previous;
}
Modified: branches/JCA/common-core/src/main/java/com/metamatrix/core/util/LRUCache.java
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/core/util/LRUCache.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/core/util/LRUCache.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -27,7 +27,6 @@
/**
* This class replaces a verbose legacy implementation of LRUCaching.
- * However technically this is an eldest first purging policy.
*/
public class LRUCache<K, V> extends LinkedHashMap<K, V> {
Modified: branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java
===================================================================
--- branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/common-internal/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -182,8 +182,11 @@
t.interrupt();
}
}
- List<Runnable> result = new ArrayList<Runnable>(queue);
- queue.clear();
+ List<Runnable> result = Collections.EMPTY_LIST;
+ if (!queue.isEmpty()) {
+ new ArrayList<Runnable>(queue);
+ queue.clear();
+ }
return result;
}
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLReservedWords.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,8 +22,11 @@
package org.teiid.connector.visitor.util;
-public interface SQLReservedWords {
+import java.util.HashSet;
+import java.util.Set;
+public class SQLReservedWords {
+
public static final String ANY = "ANY"; //$NON-NLS-1$
public static final String ALL = "ALL"; //$NON-NLS-1$
public static final String ALL_COLS = "*"; //$NON-NLS-1$
@@ -145,4 +148,44 @@
public static final String LPAREN = "("; //$NON-NLS-1$
public static final String RPAREN = ")"; //$NON-NLS-1$
+
+ public static final String[] ALL_WORDS = new String[] {ALL, ALL_COLS, AND, ANY, AS, ASC, AVG, BEGIN, BETWEEN, BIGINTEGER,
+ BIGDECIMAL, BREAK, BY, BYTE, CASE, CAST, CHAR, CONVERT, CONTINUE, COUNT, CREATE, CRITERIA, CROSS, DATE, DEBUG, DECLARE,
+ DELETE, DESC, DISTINCT, DOUBLE, ELSE, END, ERROR, ESCAPE, EXCEPT, EXEC, EXECUTE, EXISTS, FALSE, FLOAT, FOR, FROM, FULL,
+ GROUP, HAS, HAVING, IF, IN, INNER, INSERT, INTEGER, INTERSECT, INTO, IS, JOIN, LEFT, LIKE, LONG, LOOP, MAKEDEP, MIN, MAX,
+ NOT, NULL, OBJECT, ON, OR, ORDER, OPTION, OUTER, PROCEDURE, RIGHT, SELECT, SET, SHORT, SHOWPLAN, SOME,
+ SQL_TSI_FRAC_SECOND, SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH,
+ SQL_TSI_QUARTER, SQL_TSI_YEAR, STRING, SUM, THEN, TIME, TIMESTAMP, TIMESTAMPADD, TIMESTAMPDIFF, TRANSLATE, TRUE, UNION,
+ UNKNOWN, UPDATE, USING, VALUES, VIRTUAL, WHEN, WITH, WHERE, WHILE,};
+
+ /**
+ * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
+ */
+ private static final Set RESERVED_WORDS = new HashSet();
+
+ // Initialize RESERVED_WORDS set
+ static {
+ // Iterate through the reserved words and capitalize all of them
+ for (int i = 0; i != SQLReservedWords.ALL_WORDS.length; ++i) {
+ String reservedWord = SQLReservedWords.ALL_WORDS[i];
+ SQLReservedWords.RESERVED_WORDS.add(reservedWord.toUpperCase());
+ }
+ }
+
+ /** Can't construct */
+ private SQLReservedWords() {
+ }
+
+ /**
+ * Check whether a string is a reserved word.
+ *
+ * @param str String to check
+ * @return True if reserved word, false if not or null
+ */
+ public static final boolean isReservedWord( String str ) {
+ if (str == null) {
+ return false;
+ }
+ return RESERVED_WORDS.contains(str.toUpperCase());
+ }
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -82,7 +82,7 @@
* Creates a SQL string for a LanguageObject subtree. Instances of this class
* are not reusable, and are not thread-safe.
*/
-public class SQLStringVisitor extends AbstractLanguageVisitor implements SQLReservedWords {
+public class SQLStringVisitor extends AbstractLanguageVisitor {
private Set<String> infixFunctions = new HashSet<String>(Arrays.asList("%", "+", "-", "*", "+", "/", "||", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
"&", "|", "^", "#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -130,8 +130,8 @@
if (items != null && items.size() != 0) {
append(items.get(0));
for (int i = 1; i < items.size(); i++) {
- buffer.append(COMMA)
- .append(SPACE);
+ buffer.append(SQLReservedWords.COMMA)
+ .append(SQLReservedWords.SPACE);
append(items.get(i));
}
}
@@ -146,8 +146,8 @@
if (items != null && items.length != 0) {
append(items[0]);
for (int i = 1; i < items.length; i++) {
- buffer.append(COMMA)
- .append(SPACE);
+ buffer.append(SQLReservedWords.COMMA)
+ .append(SQLReservedWords.SPACE);
append(items[i]);
}
}
@@ -171,19 +171,19 @@
*/
public void visit(IAggregate obj) {
buffer.append(obj.getName())
- .append(LPAREN);
+ .append(SQLReservedWords.LPAREN);
if ( obj.isDistinct()) {
- buffer.append(DISTINCT)
- .append(SPACE);
+ buffer.append(SQLReservedWords.DISTINCT)
+ .append(SQLReservedWords.SPACE);
}
if (obj.getExpression() == null) {
- buffer.append(ALL_COLS);
+ buffer.append(SQLReservedWords.ALL_COLS);
} else {
append(obj.getExpression());
}
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
@@ -191,18 +191,18 @@
*/
public void visit(ICompareCriteria obj) {
append(obj.getLeftExpression());
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
switch(obj.getOperator()) {
- case EQ: buffer.append(EQ); break;
- case GE: buffer.append(GE); break;
- case GT: buffer.append(GT); break;
- case LE: buffer.append(LE); break;
- case LT: buffer.append(LT); break;
- case NE: buffer.append(NE); break;
+ case EQ: buffer.append(SQLReservedWords.EQ); break;
+ case GE: buffer.append(SQLReservedWords.GE); break;
+ case GT: buffer.append(SQLReservedWords.GT); break;
+ case LE: buffer.append(SQLReservedWords.LE); break;
+ case LT: buffer.append(SQLReservedWords.LT); break;
+ case NE: buffer.append(SQLReservedWords.NE); break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getRightExpression());
}
@@ -212,8 +212,8 @@
public void visit(ICompoundCriteria obj) {
String opString = null;
switch(obj.getOperator()) {
- case AND: opString = AND; break;
- case OR: opString = OR; break;
+ case AND: opString = SQLReservedWords.AND; break;
+ case OR: opString = SQLReservedWords.OR; break;
default: opString = UNDEFINED;
}
@@ -224,16 +224,16 @@
// Special case - should really never happen, but we are tolerant
append((ILanguageObject)criteria.get(0));
} else {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append((ILanguageObject)criteria.get(0));
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
for (int i = 1; i < criteria.size(); i++) {
- buffer.append(SPACE)
+ buffer.append(SQLReservedWords.SPACE)
.append(opString)
- .append(SPACE)
- .append(LPAREN);
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LPAREN);
append((ILanguageObject)criteria.get(i));
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
}
@@ -243,16 +243,16 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IDelete)
*/
public void visit(IDelete obj) {
- buffer.append(DELETE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.DELETE)
+ .append(SQLReservedWords.SPACE);
buffer.append(getSourceComment(obj));
- buffer.append(FROM)
- .append(SPACE);
+ buffer.append(SQLReservedWords.FROM)
+ .append(SQLReservedWords.SPACE);
append(obj.getGroup());
if (obj.getCriteria() != null) {
- buffer.append(SPACE)
- .append(WHERE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(SQLReservedWords.SPACE);
append(obj.getCriteria());
}
}
@@ -319,7 +319,7 @@
// If not, do normal logic: [group + "."] + element
if(groupName != null) {
elementName.append(groupName);
- elementName.append(DOT);
+ elementName.append(SQLReservedWords.DOT);
}
elementName.append(elemShortName);
return elementName.toString();
@@ -342,8 +342,8 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExecute)
*/
public void visit(IProcedure obj) {
- buffer.append(EXEC)
- .append(SPACE);
+ buffer.append(SQLReservedWords.EXEC)
+ .append(SQLReservedWords.SPACE);
if(obj.getMetadataObject() != null) {
buffer.append(getName(obj.getMetadataObject()));
@@ -351,7 +351,7 @@
buffer.append(obj.getProcedureName());
}
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
final List params = obj.getParameters();
if (params != null && params.size() != 0) {
IParameter param = null;
@@ -359,8 +359,8 @@
param = (IParameter)params.get(i);
if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) {
if (i != 0) {
- buffer.append(COMMA)
- .append(SPACE);
+ buffer.append(SQLReservedWords.COMMA)
+ .append(SQLReservedWords.SPACE);
}
if (param.getValue() != null) {
buffer.append(param.getValue().toString());
@@ -370,26 +370,26 @@
}
}
}
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/*
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExistsCriteria)
*/
public void visit(IExistsCriteria obj) {
- buffer.append(EXISTS)
- .append(SPACE)
- .append(LPAREN);
+ buffer.append(SQLReservedWords.EXISTS)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LPAREN);
append(obj.getQuery());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IFrom)
*/
public void visit(IFrom obj) {
- buffer.append(FROM)
- .append(SPACE);
+ buffer.append(SQLReservedWords.FROM)
+ .append(SQLReservedWords.SPACE);
append(obj.getItems());
}
@@ -404,61 +404,61 @@
String name = obj.getName();
List<IExpression> args = obj.getParameters();
- if(name.equalsIgnoreCase(CONVERT) || name.equalsIgnoreCase(CAST)) {
+ if(name.equalsIgnoreCase(SQLReservedWords.CONVERT) || name.equalsIgnoreCase(SQLReservedWords.CAST)) {
Object typeValue = ((ILiteral)args.get(1)).getValue();
buffer.append(name);
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append(args.get(0));
- if(name.equalsIgnoreCase(CONVERT)) {
- buffer.append(COMMA);
- buffer.append(SPACE);
+ if(name.equalsIgnoreCase(SQLReservedWords.CONVERT)) {
+ buffer.append(SQLReservedWords.COMMA);
+ buffer.append(SQLReservedWords.SPACE);
} else {
- buffer.append(SPACE);
- buffer.append(AS);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
+ buffer.append(SQLReservedWords.AS);
+ buffer.append(SQLReservedWords.SPACE);
}
buffer.append(typeValue);
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
} else if(isInfixFunction(name)) {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
if(args != null) {
for(int i=0; i<args.size(); i++) {
append(args.get(i));
if(i < (args.size()-1)) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
buffer.append(name);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
}
}
}
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
- } else if(name.equalsIgnoreCase(TIMESTAMPADD) || name.equalsIgnoreCase(TIMESTAMPDIFF)) {
+ } else if(name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPDIFF)) {
buffer.append(name);
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
if(args != null && args.size() > 0) {
buffer.append(((ILiteral)args.get(0)).getValue());
for(int i=1; i<args.size(); i++) {
- buffer.append(COMMA);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.COMMA);
+ buffer.append(SQLReservedWords.SPACE);
append(args.get(i));
}
}
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
} else {
buffer.append(obj.getName())
- .append(LPAREN);
+ .append(SQLReservedWords.LPAREN);
append(obj.getParameters());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
}
@@ -478,10 +478,10 @@
}
if (obj.getDefinition() != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
if (useAsInGroupAlias()){
- buffer.append(AS)
- .append(SPACE);
+ buffer.append(SQLReservedWords.AS)
+ .append(SQLReservedWords.SPACE);
}
buffer.append(obj.getContext());
}
@@ -502,10 +502,10 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IGroupBy)
*/
public void visit(IGroupBy obj) {
- buffer.append(GROUP)
- .append(SPACE)
- .append(BY)
- .append(SPACE);
+ buffer.append(SQLReservedWords.GROUP)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.BY)
+ .append(SQLReservedWords.SPACE);
append(obj.getElements());
}
@@ -515,29 +515,29 @@
public void visit(IInCriteria obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SPACE)
- .append(NOT);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.NOT);
}
- buffer.append(SPACE)
- .append(IN)
- .append(SPACE)
- .append(LPAREN);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.IN)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LPAREN);
append(obj.getRightExpressions());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
public void visit(IInlineView obj) {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
if (obj.getOutput() != null) {
buffer.append(obj.getOutput());
} else {
append(obj.getQuery());
}
- buffer.append(RPAREN);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.RPAREN);
+ buffer.append(SQLReservedWords.SPACE);
if(useAsInGroupAlias()) {
- buffer.append(AS);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.AS);
+ buffer.append(SQLReservedWords.SPACE);
}
buffer.append(obj.getContext());
}
@@ -546,33 +546,33 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IInsert)
*/
public void visit(IInsert obj) {
- buffer.append(INSERT).append(SPACE);
+ buffer.append(SQLReservedWords.INSERT).append(SQLReservedWords.SPACE);
buffer.append(getSourceComment(obj));
- buffer.append(INTO).append(SPACE);
+ buffer.append(SQLReservedWords.INTO).append(SQLReservedWords.SPACE);
append(obj.getGroup());
if (obj.getElements() != null && obj.getElements().size() != 0) {
- buffer.append(SPACE).append(LPAREN);
+ buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.LPAREN);
int elementCount = obj.getElements().size();
for (int i = 0; i < elementCount; i++) {
buffer.append(getElementName(obj.getElements().get(i), false));
if (i < elementCount - 1) {
- buffer.append(COMMA);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.COMMA);
+ buffer.append(SQLReservedWords.SPACE);
}
}
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getValueSource());
}
@Override
public void visit(IInsertExpressionValueSource obj) {
- buffer.append(VALUES).append(SPACE).append(LPAREN);
+ buffer.append(SQLReservedWords.VALUES).append(SQLReservedWords.SPACE).append(SQLReservedWords.LPAREN);
append(obj.getValues());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
@@ -580,14 +580,14 @@
*/
public void visit(IIsNullCriteria obj) {
append(obj.getExpression());
- buffer.append(SPACE)
- .append(IS)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.IS)
+ .append(SQLReservedWords.SPACE);
if (obj.isNegated()) {
- buffer.append(NOT)
- .append(SPACE);
+ buffer.append(SQLReservedWords.NOT)
+ .append(SQLReservedWords.SPACE);
}
- buffer.append(NULL);
+ buffer.append(SQLReservedWords.NULL);
}
/**
@@ -596,56 +596,56 @@
public void visit(IJoin obj) {
IFromItem leftItem = obj.getLeftItem();
if(useParensForJoins() && leftItem instanceof IJoin) {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append(leftItem);
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
} else {
append(leftItem);
}
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
switch(obj.getJoinType()) {
case CROSS_JOIN:
- buffer.append(CROSS);
+ buffer.append(SQLReservedWords.CROSS);
break;
case FULL_OUTER_JOIN:
- buffer.append(FULL)
- .append(SPACE)
- .append(OUTER);
+ buffer.append(SQLReservedWords.FULL)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.OUTER);
break;
case INNER_JOIN:
- buffer.append(INNER);
+ buffer.append(SQLReservedWords.INNER);
break;
case LEFT_OUTER_JOIN:
- buffer.append(LEFT)
- .append(SPACE)
- .append(OUTER);
+ buffer.append(SQLReservedWords.LEFT)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.OUTER);
break;
case RIGHT_OUTER_JOIN:
- buffer.append(RIGHT)
- .append(SPACE)
- .append(OUTER);
+ buffer.append(SQLReservedWords.RIGHT)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.OUTER);
break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SPACE)
- .append(JOIN)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.JOIN)
+ .append(SQLReservedWords.SPACE);
IFromItem rightItem = obj.getRightItem();
if(rightItem instanceof IJoin && (useParensForJoins() || obj.getJoinType() == IJoin.JoinType.CROSS_JOIN)) {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append(rightItem);
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
} else {
append(rightItem);
}
final List criteria = obj.getCriteria();
if (criteria != null && criteria.size() != 0) {
- buffer.append(SPACE)
- .append(ON)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.ON)
+ .append(SQLReservedWords.SPACE);
Iterator critIter = criteria.iterator();
while(critIter.hasNext()) {
@@ -653,15 +653,15 @@
if(crit instanceof IPredicateCriteria) {
append(crit);
} else {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append(crit);
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
if(critIter.hasNext()) {
- buffer.append(SPACE)
- .append(AND)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.AND)
+ .append(SQLReservedWords.SPACE);
}
}
}
@@ -673,31 +673,31 @@
public void visit(ILikeCriteria obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SPACE)
- .append(NOT);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.NOT);
}
- buffer.append(SPACE)
- .append(LIKE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LIKE)
+ .append(SQLReservedWords.SPACE);
append(obj.getRightExpression());
if (obj.getEscapeCharacter() != null) {
- buffer.append(SPACE)
- .append(ESCAPE)
- .append(SPACE)
- .append(QUOTE)
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.ESCAPE)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.QUOTE)
.append(obj.getEscapeCharacter().toString())
- .append(QUOTE);
+ .append(SQLReservedWords.QUOTE);
}
}
public void visit(ILimit obj) {
- buffer.append(LIMIT)
- .append(SPACE);
+ buffer.append(SQLReservedWords.LIMIT)
+ .append(SQLReservedWords.SPACE);
if (obj.getRowOffset() > 0) {
buffer.append(obj.getRowOffset())
- .append(COMMA)
- .append(SPACE);
+ .append(SQLReservedWords.COMMA)
+ .append(SQLReservedWords.SPACE);
}
buffer.append(obj.getRowLimit());
}
@@ -709,32 +709,32 @@
if (obj.isBindValue()) {
buffer.append("?"); //$NON-NLS-1$
} else if (obj.getValue() == null) {
- buffer.append(NULL);
+ buffer.append(SQLReservedWords.NULL);
} else {
Class type = obj.getType();
String val = obj.getValue().toString();
if(Number.class.isAssignableFrom(type)) {
buffer.append(val);
} else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- buffer.append("{b'") //$NON-NLS-1$
+ buffer.append("{b '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
- buffer.append("{ts'") //$NON-NLS-1$
+ buffer.append("{ts '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
- buffer.append("{t'") //$NON-NLS-1$
+ buffer.append("{t '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
- buffer.append("{d'") //$NON-NLS-1$
+ buffer.append("{d '") //$NON-NLS-1$
.append(val)
.append("'}"); //$NON-NLS-1$
} else {
- buffer.append(QUOTE)
- .append(escapeString(val, QUOTE))
- .append(QUOTE);
+ buffer.append(SQLReservedWords.QUOTE)
+ .append(escapeString(val, SQLReservedWords.QUOTE))
+ .append(SQLReservedWords.QUOTE);
}
}
}
@@ -743,21 +743,21 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.INotCriteria)
*/
public void visit(INotCriteria obj) {
- buffer.append(NOT)
- .append(SPACE)
- .append(LPAREN);
+ buffer.append(SQLReservedWords.NOT)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LPAREN);
append(obj.getCriteria());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IOrderBy)
*/
public void visit(IOrderBy obj) {
- buffer.append(ORDER)
- .append(SPACE)
- .append(BY)
- .append(SPACE);
+ buffer.append(SQLReservedWords.ORDER)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.BY)
+ .append(SQLReservedWords.SPACE);
append(obj.getItems());
}
@@ -774,8 +774,8 @@
buffer.append(UNDEFINED);
}
if (obj.getDirection() == IOrderByItem.DESC) {
- buffer.append(SPACE)
- .append(DESC);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.DESC);
} // Don't print default "ASC"
}
@@ -786,7 +786,7 @@
if (obj.getValue() == null) {
buffer.append(UNDEFINED_PARAM);
} else if (obj.getValue() == null) {
- buffer.append(NULL);
+ buffer.append(SQLReservedWords.NULL);
} else {
buffer.append(obj.getValue().toString());
}
@@ -798,31 +798,31 @@
public void visit(IQuery obj) {
visitSelect(obj.getSelect(), obj);
if (obj.getFrom() != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getFrom());
}
if (obj.getWhere() != null) {
- buffer.append(SPACE)
- .append(WHERE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(SQLReservedWords.SPACE);
append(obj.getWhere());
}
if (obj.getGroupBy() != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getGroupBy());
}
if (obj.getHaving() != null) {
- buffer.append(SPACE)
- .append(HAVING)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.HAVING)
+ .append(SQLReservedWords.SPACE);
append(obj.getHaving());
}
if (obj.getOrderBy() != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getOrderBy());
}
if (obj.getLimit() != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(obj.getLimit());
}
}
@@ -831,26 +831,26 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.ISearchedCaseExpression)
*/
public void visit(ISearchedCaseExpression obj) {
- buffer.append(CASE);
+ buffer.append(SQLReservedWords.CASE);
final int whenCount = obj.getWhenCount();
for (int i = 0; i < whenCount; i++) {
- buffer.append(SPACE)
- .append(WHEN)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.WHEN)
+ .append(SQLReservedWords.SPACE);
append(obj.getWhenCriteria(i));
- buffer.append(SPACE)
- .append(THEN)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.THEN)
+ .append(SQLReservedWords.SPACE);
append(obj.getThenExpression(i));
}
if (obj.getElseExpression() != null) {
- buffer.append(SPACE)
- .append(ELSE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.ELSE)
+ .append(SQLReservedWords.SPACE);
append(obj.getElseExpression());
}
- buffer.append(SPACE)
- .append(END);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.END);
}
/**
@@ -861,10 +861,10 @@
}
private void visitSelect(ISelect obj, ICommand command) {
- buffer.append(SELECT).append(SPACE);
+ buffer.append(SQLReservedWords.SELECT).append(SQLReservedWords.SPACE);
buffer.append(getSourceComment(command));
if (obj.isDistinct()) {
- buffer.append(DISTINCT).append(SPACE);
+ buffer.append(SQLReservedWords.DISTINCT).append(SQLReservedWords.SPACE);
}
append(obj.getSelectSymbols());
}
@@ -877,9 +877,9 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IScalarSubquery)
*/
public void visit(IScalarSubquery obj) {
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.LPAREN);
append(obj.getQuery());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
@@ -888,9 +888,9 @@
public void visit(ISelectSymbol obj) {
append(obj.getExpression());
if (obj.hasAlias()) {
- buffer.append(SPACE)
- .append(AS)
- .append(SPACE)
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.AS)
+ .append(SQLReservedWords.SPACE)
.append(obj.getOutputName());
}
}
@@ -900,27 +900,27 @@
*/
public void visit(ISubqueryCompareCriteria obj) {
append(obj.getLeftExpression());
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
switch(obj.getOperator()) {
- case EQ: buffer.append(EQ); break;
- case GE: buffer.append(GE); break;
- case GT: buffer.append(GT); break;
- case LE: buffer.append(LE); break;
- case LT: buffer.append(LT); break;
- case NE: buffer.append(NE); break;
+ case EQ: buffer.append(SQLReservedWords.EQ); break;
+ case GE: buffer.append(SQLReservedWords.GE); break;
+ case GT: buffer.append(SQLReservedWords.GT); break;
+ case LE: buffer.append(SQLReservedWords.LE); break;
+ case LT: buffer.append(SQLReservedWords.LT); break;
+ case NE: buffer.append(SQLReservedWords.NE); break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
switch(obj.getQuantifier()) {
- case ALL: buffer.append(ALL); break;
- case SOME: buffer.append(SOME); break;
+ case ALL: buffer.append(SQLReservedWords.ALL); break;
+ case SOME: buffer.append(SQLReservedWords.SOME); break;
default: buffer.append(UNDEFINED);
}
- buffer.append(SPACE);
- buffer.append(LPAREN);
+ buffer.append(SQLReservedWords.SPACE);
+ buffer.append(SQLReservedWords.LPAREN);
append(obj.getQuery());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/*
@@ -929,33 +929,33 @@
public void visit(ISubqueryInCriteria obj) {
append(obj.getLeftExpression());
if (obj.isNegated()) {
- buffer.append(SPACE)
- .append(NOT);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.NOT);
}
- buffer.append(SPACE)
- .append(IN)
- .append(SPACE)
- .append(LPAREN);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.IN)
+ .append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.LPAREN);
append(obj.getQuery());
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
}
/**
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.IUpdate)
*/
public void visit(IUpdate obj) {
- buffer.append(UPDATE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.UPDATE)
+ .append(SQLReservedWords.SPACE);
buffer.append(getSourceComment(obj));
append(obj.getGroup());
- buffer.append(SPACE)
- .append(SET)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.SET)
+ .append(SQLReservedWords.SPACE);
append(obj.getChanges());
if (obj.getCriteria() != null) {
- buffer.append(SPACE)
- .append(WHERE)
- .append(SPACE);
+ buffer.append(SQLReservedWords.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(SQLReservedWords.SPACE);
append(obj.getCriteria());
}
}
@@ -966,34 +966,34 @@
public void visit(ISetClause clause) {
buffer.append(getElementName(clause.getSymbol(), false));
- buffer.append(SPACE).append(EQ).append(SPACE);
+ buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.EQ).append(SQLReservedWords.SPACE);
append(clause.getValue());
}
public void visit(ISetQuery obj) {
- appendSetQuery(obj.getLeftQuery());
+ appendSetQuery(obj, obj.getLeftQuery(), false);
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
appendSetOperation(obj.getOperation());
if(obj.isAll()) {
- buffer.append(SPACE);
- buffer.append(ALL);
+ buffer.append(SQLReservedWords.SPACE);
+ buffer.append(SQLReservedWords.ALL);
}
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
- appendSetQuery(obj.getRightQuery());
+ appendSetQuery(obj, obj.getRightQuery(), true);
IOrderBy orderBy = obj.getOrderBy();
if(orderBy != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(orderBy);
}
ILimit limit = obj.getLimit();
if(limit != null) {
- buffer.append(SPACE);
+ buffer.append(SQLReservedWords.SPACE);
append(limit);
}
}
@@ -1006,11 +1006,14 @@
return false;
}
- protected void appendSetQuery(IQueryCommand obj) {
- if(obj instanceof ISetQuery || useParensForSetQueries()) {
- buffer.append(LPAREN);
+ protected void appendSetQuery(ISetQuery parent, IQueryCommand obj, boolean right) {
+ if((!(obj instanceof ISetQuery) && useParensForSetQueries())
+ || (right && obj instanceof ISetQuery
+ && ((parent.isAll() && !((ISetQuery)obj).isAll())
+ || parent.getOperation() != ((ISetQuery)obj).getOperation()))) {
+ buffer.append(SQLReservedWords.LPAREN);
append(obj);
- buffer.append(RPAREN);
+ buffer.append(SQLReservedWords.RPAREN);
} else {
append(obj);
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQL5Translator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQL5Translator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQL5Translator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,11 +22,31 @@
package org.teiid.connector.jdbc.mysql;
+import java.util.Arrays;
+import java.util.List;
+
import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
+import org.teiid.connector.jdbc.translator.FunctionModifier;
+import org.teiid.connector.language.IFunction;
-public class MySQL5Translator extends MySQLTranslator {
+public class MySQL5Translator extends MySQLTranslator {
@Override
+ public void initialize(JDBCManagedConnectionFactory env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {
+
+ @Override
+ public List<?> translate(IFunction function) {
+ return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ }
+
+ @Override
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return MySQL5Capabilities.class;
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/mysql/MySQLTranslator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -34,6 +34,7 @@
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.SourceSystemFunctions;
+import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
import org.teiid.connector.jdbc.translator.ConvertModifier;
import org.teiid.connector.jdbc.translator.FunctionModifier;
@@ -46,6 +47,19 @@
*/
public class MySQLTranslator extends Translator {
+ /**
+ * Adds support for the 2 argument form of padding
+ */
+ private final class PadFunctionModifier extends FunctionModifier {
+ @Override
+ public List<?> translate(IFunction function) {
+ if (function.getParameters().size() == 2) {
+ function.getParameters().add(getLanguageFactory().createLiteral(" ", TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$
+ }
+ return null;
+ }
+ }
+
@Override
public void initialize(JDBCManagedConnectionFactory env) throws ConnectorException {
super.initialize(env);
@@ -54,10 +68,11 @@
registerFunctionModifier(SourceSystemFunctions.BITOR, new BitFunctionModifier("|", getLanguageFactory())); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.BITXOR, new BitFunctionModifier("^", getLanguageFactory())); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
-
+ registerFunctionModifier(SourceSystemFunctions.LPAD, new PadFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.RPAD, new PadFunctionModifier());
//add in type conversion
ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("signed", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG); //$NON-NLS-1$
+ convertModifier.addTypeMapping("signed", FunctionModifier.BOOLEAN, FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG); //$NON-NLS-1$
//char(n) assume 4.1 or later
convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
convertModifier.addTypeMapping("char", FunctionModifier.STRING); //$NON-NLS-1$
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/postgresql/PostgreSQLTranslator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -41,6 +41,7 @@
import org.teiid.connector.jdbc.translator.EscapeSyntaxModifier;
import org.teiid.connector.jdbc.translator.ExtractFunctionModifier;
import org.teiid.connector.jdbc.translator.FunctionModifier;
+import org.teiid.connector.jdbc.translator.ModFunctionModifier;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.IAggregate;
import org.teiid.connector.language.IExpression;
@@ -93,6 +94,8 @@
registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory(), Arrays.asList(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, TypeFacility.RUNTIME_TYPES.BIG_DECIMAL))); //$NON-NLS-1$
//specific to 8.2 client or later
registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -65,7 +65,7 @@
if (obj instanceof IElement) {
IElement elem = (IElement)obj;
try {
- if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
+ if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && elem.getMetadataObject() != null && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
return Arrays.asList("cast(", elem, " as char(36))"); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (ConnectorException e) {
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/ModFunctionModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -39,20 +40,27 @@
*/
public class ModFunctionModifier extends AliasModifier {
- private static Set<Class> SUPPORTED_TYPES = new HashSet<Class>(Arrays.asList(TypeFacility.RUNTIME_TYPES.INTEGER, TypeFacility.RUNTIME_TYPES.LONG));
+ private Set<Class> supportedTypes = new HashSet<Class>(Arrays.asList(TypeFacility.RUNTIME_TYPES.INTEGER, TypeFacility.RUNTIME_TYPES.LONG));
private ILanguageFactory langFactory;
-
+
public ModFunctionModifier(String modFunction, ILanguageFactory langFactory) {
+ this(modFunction, langFactory, null);
+ }
+
+ public ModFunctionModifier(String modFunction, ILanguageFactory langFactory, Collection<Class> supportedTypes) {
super(modFunction);
- this.langFactory = langFactory;
+ this.langFactory = langFactory;
+ if (supportedTypes != null) {
+ this.supportedTypes.addAll(supportedTypes);
+ }
}
@Override
public List<?> translate(IFunction function) {
List<IExpression> expressions = function.getParameters();
Class<?> type = function.getType();
- if (SUPPORTED_TYPES.contains(type)) {
+ if (supportedTypes.contains(type)) {
modify(function);
return null;
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -53,6 +53,7 @@
import org.teiid.connector.language.ISetClause;
import org.teiid.connector.language.IParameter.Direction;
import org.teiid.connector.language.ISetQuery.Operation;
+import org.teiid.connector.visitor.util.SQLReservedWords;
import org.teiid.connector.visitor.util.SQLStringVisitor;
@@ -138,7 +139,7 @@
*/
private void translateSQLType(Class type, Object obj, StringBuilder valuesbuffer) {
if (obj == null) {
- valuesbuffer.append(NULL);
+ valuesbuffer.append(SQLReservedWords.NULL);
} else {
if(Number.class.isAssignableFrom(type)) {
boolean useFormatting = false;
@@ -173,9 +174,9 @@
} else {
// If obj is string, toSting() will not create a new String
// object, it returns it self, so new object creation.
- valuesbuffer.append(QUOTE)
- .append(escapeString(obj.toString(), QUOTE))
- .append(QUOTE);
+ valuesbuffer.append(SQLReservedWords.QUOTE)
+ .append(escapeString(obj.toString(), SQLReservedWords.QUOTE))
+ .append(SQLReservedWords.QUOTE);
}
}
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -212,7 +212,7 @@
} else if (obj instanceof IElement) {
IElement elem = (IElement)obj;
try {
- if (trimChar && elem.getType() == TypeFacility.RUNTIME_TYPES.STRING
+ if (trimChar && elem.getType() == TypeFacility.RUNTIME_TYPES.STRING && elem.getMetadataObject() != null
&& ("char".equalsIgnoreCase(elem.getMetadataObject().getNativeType()) || "nchar".equalsIgnoreCase(elem.getMetadataObject().getNativeType()))) { //$NON-NLS-1$ //$NON-NLS-2$
return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.RTRIM, new IExpression[] {elem}, TypeFacility.RUNTIME_TYPES.STRING));
}
@@ -279,18 +279,18 @@
/**
* Subclasses should override this method to provide a different sql translation
* of the literal date value. By default, a date literal is represented as:
- * <code>{d'2002-12-31'}</code>
+ * <code>{d '2002-12-31'}</code>
* @param dateValue Date value, never null
* @return Translated string
*/
public String translateLiteralDate(java.sql.Date dateValue) {
- return "{d'" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{d '" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Subclasses should override this method to provide a different sql translation
* of the literal time value. By default, a time literal is represented as:
- * <code>{t'23:59:59'}</code>
+ * <code>{t '23:59:59'}</code>
*
* See {@link Translator#hasTimeType()} to represent literal times as timestamps.
*
@@ -299,15 +299,15 @@
*/
public String translateLiteralTime(Time timeValue) {
if (!hasTimeType()) {
- return "{ts'1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{ts '1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
- return "{t'" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Subclasses should override this method to provide a different sql translation
* of the literal timestamp value. By default, a timestamp literal is
- * represented as: <code>{ts'2002-12-31 23:59:59'}</code>.
+ * represented as: <code>{ts '2002-12-31 23:59:59'}</code>.
*
* See {@link Translator#getTimestampNanoPrecision()} to control the literal
* precision.
@@ -316,7 +316,7 @@
* @return Translated string
*/
public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "{ts'" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
}
/**
Modified: branches/JCA/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -17,6 +17,7 @@
<PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" IsRequired="true" />
<PropertyDefinition Name="TrimStrings" DisplayName="Trim string flag" ShortDescription="Right Trim fixed character types returned as Strings - note that the native type must be char or nchar and the source must support the rtrim function." DefaultValue="false" PropertyType="Boolean" IsExpert="true" />
<PropertyDefinition Name="UseCommentsInSourceQuery" DisplayName="Use informational comments in Source Queries" ShortDescription="This will embed /*comment*/ style comment with session/request id in source SQL query for informational purposes" DefaultValue="false" PropertyType="Boolean" IsExpert="true"/>
+ <PropertyDefinition Name="FetchSize" DisplayName="Statement Fetch Size" ShortDescription="Statement Fetch Size" DefaultValue="0" PropertyType="Integer" IsExpert="true"/>
</ComponentType>
<ComponentType Name="Oracle Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="JDBC Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup">
<PropertyDefinition Name="ConnectionSource" DisplayName="Connection Source Class" ShortDescription="Driver, DataSource, or XADataSource class name" DefaultValue="oracle.jdbc.driver.OracleDriver" IsRequired="true" />
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2ConvertModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -477,38 +477,38 @@
// Source = DATE
public void testDateToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d'2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d '2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d'2003-11-01'}, '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d '2003-11-01'}, '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIME
public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t '23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t'23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t '23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
public void testTimestampToString() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTimestampToTime() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -39,7 +39,7 @@
}
@Test public void testTimestampDiff() throws Exception {
- String input = "select timestampdiff(SQL_TSI_FRAC_SECOND, timestampvalue, {d'1970-01-01'}) from BQT1.Smalla"; //$NON-NLS-1$
+ String input = "select timestampdiff(SQL_TSI_FRAC_SECOND, timestampvalue, {d '1970-01-01'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT datediff('MILLISECOND', SmallA.TimestampValue, TIMESTAMP '1970-01-01 00:00:00.0') * 1000000 FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
@@ -53,7 +53,7 @@
}
@Test public void testTimestampAdd1() throws Exception {
- String input = "select timestampadd(SQL_TSI_HOUR, intnum, {t'00:00:00'}) from BQT1.Smalla"; //$NON-NLS-1$
+ String input = "select timestampadd(SQL_TSI_HOUR, intnum, {t '00:00:00'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT cast(dateadd('HOUR', SmallA.IntNum, TIMESTAMP '1970-01-01 00:00:00.0') AS time) FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
Copied: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQL5Translator.java (from rev 1798, trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQL5Translator.java)
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQL5Translator.java (rev 0)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQL5Translator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,51 @@
+/*
+ * 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.connector.jdbc.mysql;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
+
+/**
+ */
+public class TestMySQL5Translator {
+
+ private static MySQL5Translator TRANSLATOR;
+
+ @BeforeClass public static void oneTimeSetup() throws ConnectorException {
+ TRANSLATOR = new MySQL5Translator();
+ TRANSLATOR.initialize(new JDBCManagedConnectionFactory());
+ }
+
+ @Test public void testChar() throws Exception {
+ String input = "SELECT intkey, CHR(CONVERT(bigintegervalue, integer)) FROM BQT1.MediumA"; //$NON-NLS-1$
+ String output = "SELECT MediumA.IntKey, char(cast(MediumA.BigIntegerValue AS signed) USING ASCII) FROM MediumA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -20,109 +20,110 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.jdbc.mysql;
-
+package org.teiid.connector.jdbc.mysql;
+
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
import org.teiid.connector.jdbc.TranslationHelper;
-
-/**
- */
-public class TestMySQLTranslator {
-
- private static MySQLTranslator TRANSLATOR;
+
+/**
+ */
+public class TestMySQLTranslator {
+
+ private static MySQLTranslator TRANSLATOR;
- @BeforeClass public static void oneTimeSetup() throws ConnectorException {
- TRANSLATOR = new MySQLTranslator();
+ @BeforeClass public static void oneTimeSetup() throws ConnectorException {
+ TRANSLATOR = new MySQLTranslator();
TRANSLATOR.initialize(new JDBCManagedConnectionFactory());
- }
-
- private String getTestVDB() {
- return TranslationHelper.PARTS_VDB;
- }
-
- private String getTestBQTVDB() {
- return TranslationHelper.BQT_VDB;
- }
-
+ }
+
+ private String getTestVDB() {
+ return TranslationHelper.PARTS_VDB;
+ }
+
+ private String getTestBQTVDB() {
+ return TranslationHelper.BQT_VDB;
+ }
+
@Test public void testConversion1() throws Exception {
- String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT char((cast(PARTS.PART_WEIGHT AS signed) + 100)) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
-
+ String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT char((cast(PARTS.PART_WEIGHT AS signed) + 100)) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
@Test public void testConversion2() throws Exception {
- String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT cast(PARTS.PART_WEIGHT AS signed) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
-
+ String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT cast(PARTS.PART_WEIGHT AS signed) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
@Test public void testConversion3() throws Exception {
- String input = "SELECT convert(convert(PART_WEIGHT, long), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
-
+ String input = "SELECT convert(convert(PART_WEIGHT, long), string) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
@Test public void testConversion4() throws Exception {
- String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT date_format(DATE(PARTS.PART_WEIGHT), '%Y-%m-%d') FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT date_format(DATE(PARTS.PART_WEIGHT), '%Y-%m-%d') FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testConversion5() throws Exception {
- String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT date_format(TIME(PARTS.PART_WEIGHT), '%H:%i:%S') FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT date_format(TIME(PARTS.PART_WEIGHT), '%H:%i:%S') FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testConversion6() throws Exception {
- String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT date_format(TIMESTAMP(PARTS.PART_WEIGHT), '%Y-%m-%d %H:%i:%S.%f') FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT date_format(TIMESTAMP(PARTS.PART_WEIGHT), '%Y-%m-%d %H:%i:%S.%f') FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testConversion8() throws Exception {
- String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT ifnull(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT ifnull(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testConversion7() throws Exception {
- String input = "SELECT convert(convert(PART_WEIGHT, integer), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT convert(convert(PART_WEIGHT, integer), string) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testInsert() throws Exception {
- String input = "SELECT insert(PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT insert(PARTS.PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
-
+ String input = "SELECT insert(PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT insert(PARTS.PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
/**
* Test the translator's ability to rewrite the LOCATE() function in a form
* suitable for the data source.
@@ -206,7 +207,7 @@
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
- }
+ }
/**
* Test the translator's ability to rewrite the LOCATE() function in a form
@@ -243,48 +244,48 @@
}
@Test public void testSubstring1() throws Exception {
- String input = "SELECT substring(PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substring(PARTS.PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT substring(PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT substring(PARTS.PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testSubstring2() throws Exception {
- String input = "SELECT substring(PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substring(PARTS.PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
+ String input = "SELECT substring(PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT substring(PARTS.PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
+ }
@Test public void testUnionWithOrderBy() throws Exception {
- String input = "SELECT PART_ID FROM PARTS UNION SELECT PART_ID FROM PARTS ORDER BY PART_ID"; //$NON-NLS-1$
- String output = "(SELECT PARTS.PART_ID FROM PARTS) UNION (SELECT PARTS.PART_ID FROM PARTS) ORDER BY PART_ID"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestVDB(),
- input,
- output, TRANSLATOR);
- }
-
- @Test public void testRowLimit2() throws Exception {
- String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestBQTVDB(),
- input,
- output, TRANSLATOR);
+ String input = "SELECT PART_ID FROM PARTS UNION SELECT PART_ID FROM PARTS ORDER BY PART_ID"; //$NON-NLS-1$
+ String output = "(SELECT PARTS.PART_ID FROM PARTS) UNION (SELECT PARTS.PART_ID FROM PARTS) ORDER BY PART_ID"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestVDB(),
+ input,
+ output, TRANSLATOR);
}
-
- @Test public void testRowLimit3() throws Exception {
- String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
- String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 50, 100"; //$NON-NLS-1$
-
- TranslationHelper.helpTestVisitor(getTestBQTVDB(),
- input,
- output, TRANSLATOR);
+
+ @Test public void testRowLimit2() throws Exception {
+ String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
}
+ @Test public void testRowLimit3() throws Exception {
+ String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 50, 100"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
@Test public void testBitAnd() throws Exception {
String input = "select bitand(intkey, intnum) from bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT cast((SmallA.IntKey & SmallA.IntNum) AS signed) FROM SmallA"; //$NON-NLS-1$
@@ -310,5 +311,52 @@
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
- }
-}
+ }
+
+ @Test public void testPad() throws Exception {
+ String input = "select lpad(smalla.stringkey, 18), rpad(smalla.stringkey, 12) from bqt1.smalla"; //$NON-NLS-1$
+ String output = "SELECT lpad(SmallA.StringKey, 18, ' '), rpad(SmallA.StringKey, 12, ' ') FROM SmallA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testChar() throws Exception {
+ String input = "SELECT intkey, CHR(CONVERT(bigintegervalue, integer)) FROM BQT1.MediumA"; //$NON-NLS-1$
+ String output = "SELECT MediumA.IntKey, char(cast(MediumA.BigIntegerValue AS signed)) FROM MediumA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testBooleanToString() throws Exception {
+ String input = "SELECT convert(INTKEY, boolean) FROM BQT1.SmallA ORDER BY INTKEY"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN SmallA.IntKey = 0 THEN 0 WHEN SmallA.IntKey IS NOT NULL THEN 1 END FROM SmallA ORDER BY INTKEY"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testThreeUnionBranches() throws Exception {
+ String input = "select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id"; //$NON-NLS-1$
+ String output = "(SELECT PARTS.PART_ID AS id FROM PARTS) UNION ALL (SELECT PARTS.PART_NAME FROM PARTS) UNION ALL (SELECT PARTS.PART_ID FROM PARTS) ORDER BY id"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.PARTS_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Ignore("There's no good workaround for this case on mysql 4 and for 5 can be done with a suquery, but only if the first union branch has no parens...")
+ @Test public void testNestedSetQuery() throws Exception {
+ String input = "select part_id id FROM parts UNION ALL (select part_name FROM parts UNION select part_id FROM parts)"; //$NON-NLS-1$
+ String output = ""; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.PARTS_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -67,24 +67,24 @@
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
- "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'DDD'))"); //$NON-NLS-1$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, SourceSystemFunctions.DAYOFYEAR,
- "to_number(TO_CHAR({d'2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({d '2004-01-21'}, 'DDD'))"); //$NON-NLS-1$
}
public void test9() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, SourceSystemFunctions.QUARTER,
- "to_number(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Q'))"); //$NON-NLS-1$
}
public void test10() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, SourceSystemFunctions.QUARTER,
- "to_number(TO_CHAR({d'2004-01-21'}, 'Q'))"); //$NON-NLS-1$
+ "to_number(TO_CHAR({d '2004-01-21'}, 'Q'))"); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -66,24 +66,24 @@
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, "Month", //$NON-NLS-1$
- "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Month'))"); //$NON-NLS-1$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, "Month", //$NON-NLS-1$
- "rtrim(TO_CHAR({d'2004-01-21'}, 'Month'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({d '2004-01-21'}, 'Month'))"); //$NON-NLS-1$
}
public void test3() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
helpTestMod(arg1, "Day", //$NON-NLS-1$
- "rtrim(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({ts '2004-01-21 10:05:00.0'}, 'Day'))"); //$NON-NLS-1$
}
public void test4() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
helpTestMod(arg1, "Day", //$NON-NLS-1$
- "rtrim(TO_CHAR({d'2004-01-21'}, 'Day'))"); //$NON-NLS-1$
+ "rtrim(TO_CHAR({d '2004-01-21'}, 'Day'))"); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleConvertModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -480,38 +480,38 @@
// Source = DATE
@Test public void testDateToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "to_char({d'2003-11-01'}, 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "to_char({d '2003-11-01'}, 'YYYY-MM-DD')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d'2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d '2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIME
@Test public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts'1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "to_char({ts '1970-01-01 23:59:59'}, 'HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts'1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts '1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
@Test public void testTimestampToString() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts'2003-11-01 12:05:02.0'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "to_char({ts '2003-11-01 12:05:02.0'}, 'YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimestampToDate() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc(cast({ts'2003-11-01 12:05:02.0'} AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "trunc(cast({ts '2003-11-01 12:05:02.0'} AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTimestampToTime() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "case when {ts'2003-11-01 12:05:02.0'} is null then null else to_date('1970-01-01 ' || to_char({ts'2003-11-01 12:05:02.0'}, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "case when {ts '2003-11-01 12:05:02.0'} is null then null else to_date('1970-01-01 ' || to_char({ts '2003-11-01 12:05:02.0'}, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -115,30 +115,30 @@
@Test public void testDateLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
+ "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimeLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
+ "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testTimestampLiteral() throws Exception {
helpTestVisitor(getTestVDB(),
- "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+ "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
null,
- "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
@Test public void testUnionOrderByWithThreeBranches() throws Exception {
helpTestVisitor(getTestVDB(),
"select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
null,
- "(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+ "SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
true);
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -158,6 +158,9 @@
TranslationUtility tu = new TranslationUtility(metadata);
ICommand command = tu.parseCommand("select max(x) from bar"); //$NON-NLS-1$
TranslationHelper.helpTestVisitor("SELECT MAX(cast(bar.x as char(36))) FROM bar", trans, command); //$NON-NLS-1$
+
+ command = tu.parseCommand("select * from (select max(x) from bar) x"); //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor("SELECT x.MAX FROM (SELECT MAX(cast(bar.x as char(36))) FROM bar) x", trans, command); //$NON-NLS-1$
}
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseConvertModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -107,7 +107,7 @@
LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
java.sql.Date.class);
- helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts'1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast(stuff(stuff(convert(varchar, {ts '1989-03-03 07:08:12.0'}, 102), 5, 1, '-'), 8, 1, '-') AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(date AS INPUT) ******************/
@@ -131,7 +131,7 @@
LANG_FACTORY.createLiteral("time", String.class)}, //$NON-NLS-1$
java.sql.Time.class);
- helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts'1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
+ helpGetString1(func, "cast('1970-01-01 ' + convert(varchar, {ts '1989-03-03 07:08:12.0'}, 8) AS datetime)"); //$NON-NLS-1$
}
/********************END of cast(time AS INPUT) ******************/
@@ -154,7 +154,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{ts'1970-01-01 12:02:03'}"); //$NON-NLS-1$
+ helpGetString1(func, "{ts '1970-01-01 12:02:03'}"); //$NON-NLS-1$
}
@Test public void testDateToTimestamp() throws Exception {
@@ -164,7 +164,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "{d'1989-03-03'}"); //$NON-NLS-1$
+ helpGetString1(func, "{d '1989-03-03'}"); //$NON-NLS-1$
}
/********************END of cast(timestamp AS INPUT) ******************/
@@ -187,7 +187,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(convert(varchar, {ts'2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(convert(varchar, {ts '2003-11-01 12:05:02.0'}, 123), 11, 1, ' ')"); //$NON-NLS-1$
}
@Test public void testDateToString() throws Exception {
@@ -198,7 +198,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "stuff(stuff(convert(varchar, {d'2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
+ helpGetString1(func, "stuff(stuff(convert(varchar, {d '2003-11-01'}, 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$
}
@Test public void testTimeToString() throws Exception {
@@ -209,7 +209,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "convert(varchar, {ts'1970-01-01 03:10:01'}, 8)"); //$NON-NLS-1$
+ helpGetString1(func, "convert(varchar, {ts '1970-01-01 03:10:01'}, 8)"); //$NON-NLS-1$
}
@Test public void testBigDecimalToString() throws Exception {
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -179,22 +179,22 @@
@Test
public void testDateLiteral() {
helpTestVisitor(getTestVDB(),
- "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
- "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
+ "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimeLiteral() {
helpTestVisitor(getTestVDB(),
- "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
+ "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@Test
public void testTimestampLiteral() {
helpTestVisitor(getTestVDB(),
- "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+ "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
@Test
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestEscapeSyntaxModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -62,7 +62,7 @@
ILiteral arg3 = CommandBuilder.getLanuageFactory().createLiteral(TimestampUtil.createTimestamp(0, 0, 0, 0, 0, 0, 0), Timestamp.class);
IFunction func = CommandBuilder.getLanuageFactory().createFunction("timestampadd", Arrays.asList( arg1, arg2, arg3), Timestamp.class); //$NON-NLS-1$
- helpTest(func, "{fn timestampadd(SQL_TSI_HOUR, 1, {ts'1899-12-31 00:00:00.0'})}");
+ helpTest(func, "{fn timestampadd(SQL_TSI_HOUR, 1, {ts '1899-12-31 00:00:00.0'})}");
}
private void helpTest(IFunction func, String expected) {
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestExtractFunctionModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -71,32 +71,32 @@
}
public void test1() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(MONTH FROM {d'2004-01-21'})" , "month"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(MONTH FROM {d '2004-01-21'})" , "month"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(MONTH FROM {ts'2004-01-21 17:05:00.0'})", "month"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(MONTH FROM {ts '2004-01-21 17:05:00.0'})", "month"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test3() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(YEAR FROM {d'2004-01-21'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(YEAR FROM {d '2004-01-21'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test4() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(YEAR FROM {ts'2004-01-21 17:05:00.0'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(YEAR FROM {ts '2004-01-21 17:05:00.0'})", "year"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test5() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {d'2004-01-21'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {d '2004-01-21'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test6() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {ts'2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {ts '2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test11() throws Exception {
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/translator/TestModFunctionModifier.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -144,22 +144,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * MOD(x,y) using {@link Integer} constants for both parameters returns
- * MOD(x,y). {@link ModFunctionModifier} will be constructed with a
- * function name of "MOD" and a supported type list which contains {@link Integer}.
- *
- * @throws Exception
- */
- public void testTwoIntConst3() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
- LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
- };
- helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* x % y using {@link Integer} constants for both parameters returns (x % y).
* {@link ModFunctionModifier} will be constructed with a function name of
* "%" and no supported type list.
@@ -176,22 +160,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * x % y using {@link Integer} constants for both parameters returns (x % y).
- * {@link ModFunctionModifier} will be constructed with a function name of
- * "%" and a supported type list which contains {@link Integer}.
- *
- * @throws Exception
- */
- public void testTwoIntConst6() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createLiteral(new Integer(10), Integer.class),
- LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
- };
- helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* MOD(x,y) using {@link Long} constants for both parameters returns
* MOD(x,y). {@link ModFunctionModifier} will be constructed without
* specifying a function name or a supported type list.
@@ -224,22 +192,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * MOD(x,y) using {@link Long} constants for both parameters returns
- * MOD(x,y). {@link ModFunctionModifier} will be constructed with a
- * function name of "MOD" and a supported type list which contains {@link Long}.
- *
- * @throws Exception
- */
- public void testTwoLongConst3() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createLiteral(new Long(10), Long.class),
- LANG_FACTORY.createLiteral(new Long(6), Long.class)
- };
- helpTestMod("MOD", args, "MOD(10, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* x % y using {@link Long} constants for both parameters returns (x % y).
* {@link ModFunctionModifier} will be constructed with a function name of
* "%" and no supported type list.
@@ -256,22 +208,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * x % y using {@link Long} constants for both parameters returns (x % y).
- * {@link ModFunctionModifier} will be constructed with a function name of
- * "%" and a supported type list which contains {@link Long}.
- *
- * @throws Exception
- */
- public void testTwoLongConst6() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createLiteral(new Long(10), Long.class),
- LANG_FACTORY.createLiteral(new Long(6), Long.class)
- };
- helpTestMod("%", args, "(10 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* MOD(x,y) using {@link Float} constants for both parameters returns
* (x - (TRUNC((x / y), 0) * y)). {@link ModFunctionModifier} will be
* constructed without specifying a function name or a supported type list.
@@ -354,23 +290,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * MOD(e1,y) using a {@link Integer} element and a {@link Integer} constant
- * for parameters returns MOD(e1,y). {@link ModFunctionModifier} will be
- * constructed with a function name of "MOD" and a supported type list which
- * contains {@link Integer}.
- *
- * @throws Exception
- */
- public void testOneIntElemOneIntConst3() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
- LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
- };
- helpTestMod("MOD", args, "MOD(e1, 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* e1 % y using a {@link Integer} element and a {@link Integer} constant for
* parameters returns (e1 % y). {@link ModFunctionModifier} will be
* constructed with a function name of "%" and no supported type list.
@@ -388,23 +307,6 @@
/**
* Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
- * e1 % y using a {@link Integer} element and a {@link Integer} constant for
- * parameters returns (e1 % y). {@link ModFunctionModifier} will be
- * constructed with a function name of "%" and a supported type list which
- * contains {@link Integer}.
- *
- * @throws Exception
- */
- public void testOneIntElemOneIntConst6() throws Exception {
- IExpression[] args = new IExpression[] {
- LANG_FACTORY.createElement("e1", null, null, Integer.class), //$NON-NLS-1$
- LANG_FACTORY.createLiteral(new Integer(6), Integer.class)
- };
- helpTestMod("%", args, "(e1 % 6)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test {@link ModFunctionModifier#modify(IFunction)} to validate a call to
* MOD(e1,y) using a {@link BigDecimal} element and a {@link BigDecimal}
* constant for parameters returns (e1 - (TRUNC((e1 / y), 0) * y)).
* {@link ModFunctionModifier} will be constructed without specifying a
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -36,7 +36,6 @@
public class Connector extends org.teiid.connector.basic.BasicConnector {
private SalesForceManagedConnectionFactory connectorEnv;
- private ConnectorState state;
private boolean singleIdentity;
// ///////////////////////////////////////////////////////////
@@ -68,8 +67,6 @@
this.connectorEnv = (SalesForceManagedConnectionFactory)env;
getLogger().logInfo("Started"); //$NON-NLS-1$
- this.state = new ConnectorState(this.connectorEnv);
-
getLogger().logInfo("Initialized"); //$NON-NLS-1$
getLogger().logTrace("Initialization Properties: " + this.connectorEnv.toString()); //$NON-NLS-1$
@@ -91,10 +88,6 @@
}
- public ConnectorState getState() {
- return state;
- }
-
@Override
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return SalesforceCapabilities.class;
Deleted: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.connector.salesforce;
-
-import java.net.URL;
-
-
-public class ConnectorState {
-
- private String username;
- private String password;
- private URL url;
-
- public ConnectorState(SalesForceManagedConnectionFactory config) {
- String username = config.getUsername();
- if (username != null) {
- setUsername(username);
- }
-
- String password = config.getPassword();
- if (password != null) {
- setPassword(password);
- }
- setUrl(config.getURL());
- }
-
- private void setUrl(URL salesforceURL) {
- url = salesforceURL;
- }
-
- private void setUsername(String username) {
- this.username = username;
- }
-
- private void setPassword(String password) {
- this.password = password;
- }
-
- public URL getURL() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
-}
Copied: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/MetadataProcessor.java (from rev 1798, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/MetadataProcessor.java)
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/MetadataProcessor.java (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/MetadataProcessor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,295 @@
+package com.metamatrix.connector.salesforce;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.KeyRecord;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
+import com.sforce.soap.partner.ChildRelationship;
+import com.sforce.soap.partner.DescribeGlobalResult;
+import com.sforce.soap.partner.DescribeGlobalSObjectResult;
+import com.sforce.soap.partner.DescribeSObjectResult;
+import com.sforce.soap.partner.Field;
+import com.sforce.soap.partner.FieldType;
+import com.sforce.soap.partner.PicklistEntry;
+
+public class MetadataProcessor {
+ private MetadataFactory metadataFactory;
+ private SalesforceConnection connection;
+ private SalesForceManagedConnectionFactory connectorEnv;
+
+ private Map<String, Table> tableMap = new HashMap<String, Table>();
+ private List<Relationship> relationships = new ArrayList<Relationship>();
+ private boolean hasUpdateableColumn = false;
+ private List<Column> columns;
+
+ // Audit Fields
+ public static final String AUDIT_FIELD_CREATED_BY_ID = "CreatedById"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_CREATED_DATE = "CreatedDate"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_LAST_MODIFIED_BY_ID = "LastModifiedById"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_LAST_MODIFIED_DATE = "LastModifiedDate"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_SYSTEM_MOD_STAMP = "SystemModstamp"; //$NON-NLS-1$
+
+ // Model Extensions
+ static final String TABLE_SUPPORTS_CREATE = "Supports Create"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_DELETE = "Supports Delete"; //$NON-NLS-1$
+ static final String TABLE_CUSTOM = "Custom"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_LOOKUP = "Supports ID Lookup"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_MERGE = "Supports Merge"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_QUERY = "Supports Query"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_REPLICATE = "Supports Replicate"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_RETRIEVE = "Supports Retrieve"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_SEARCH = "Supports Search"; //$NON-NLS-1$
+
+ static final String COLUMN_DEFAULTED = "Defaulted on Create"; //$NON-NLS-1$
+ static final String COLUMN_CUSTOM = "Custom"; //$NON-NLS-1$
+ static final String COLUMN_CALCULATED = "Calculated"; //$NON-NLS-1$
+ static final String COLUMN_PICKLIST_VALUES = "Picklist Values"; //$NON-NLS-1$
+
+ public MetadataProcessor(SalesforceConnection connection, MetadataFactory metadataFactory, SalesForceManagedConnectionFactory env) {
+ this.connection = connection;
+ this.metadataFactory = metadataFactory;
+ this.connectorEnv = env;
+ }
+
+ public void processMetadata() throws ConnectorException {
+ DescribeGlobalResult globalResult = connection.getObjects();
+ DescribeGlobalSObjectResult[] objects = globalResult.getSobjects();
+ for (int i=0;i < objects.length;i++) {
+ DescribeGlobalSObjectResult object = objects[i];
+ addTable(object);
+ }
+ addRelationships();
+ }
+
+ private void addRelationships() throws ConnectorException {
+ for (Iterator<Relationship> iterator = relationships.iterator(); iterator.hasNext();) {
+ Relationship relationship = iterator.next();
+ if (!this.connectorEnv.isModelAuditFields() && isAuditField(relationship.getForeignKeyField())) {
+ continue;
+ }
+
+ Table parent = tableMap.get(NameUtil.normalizeName(relationship.getParentTable()));
+ KeyRecord pk = parent.getPrimaryKey();
+ if (null == pk) {
+ throw new RuntimeException("ERROR !!primary key column not found!!"); //$NON-NLS-1$
+ }
+ ArrayList<String> columnNames = new ArrayList<String>();
+ columnNames.add(pk.getName());
+
+
+ Table child = tableMap.get(NameUtil.normalizeName(relationship.getChildTable()));
+
+ Column col = null;
+ columns = child.getColumns();
+ for (Iterator colIter = columns.iterator(); colIter.hasNext();) {
+ Column column = (Column) colIter.next();
+ if(column.getName().equals(relationship.getForeignKeyField())) {
+ col = column;
+ }
+ }
+ if (null == col) throw new RuntimeException(
+ "ERROR !!foreign key column not found!! " + child.getName() + relationship.getForeignKeyField()); //$NON-NLS-1$
+
+
+ String columnName = "FK_" + parent.getName() + "_" + col.getName();
+ ArrayList<String> columnNames2 = new ArrayList<String>();
+ columnNames2.add(col.getName());
+ metadataFactory.addForiegnKey(columnName, columnNames2, parent, child);
+
+ }
+
+
+ }
+
+ public static boolean isAuditField(String name) {
+ boolean result = false;
+ if(name.equals(AUDIT_FIELD_CREATED_BY_ID) ||
+ name.equals(AUDIT_FIELD_CREATED_DATE) ||
+ name.equals(AUDIT_FIELD_LAST_MODIFIED_BY_ID) ||
+ name.equals(AUDIT_FIELD_LAST_MODIFIED_DATE) ||
+ name.equals(AUDIT_FIELD_SYSTEM_MOD_STAMP)) {
+ result = true;
+ }
+ return result;
+ }
+
+ private void addTable(DescribeGlobalSObjectResult object) throws ConnectorException {
+ DescribeSObjectResult objectMetadata = connection.getObjectMetaData(object.getName());
+ String name = NameUtil.normalizeName(objectMetadata.getName());
+ Table table = metadataFactory.addTable(name);
+
+ table.setNameInSource(objectMetadata.getName());
+ tableMap.put(name, table);
+ getRelationships(objectMetadata);
+
+ table.setProperty(TABLE_CUSTOM, String.valueOf(objectMetadata.isCustom()));
+ table.setProperty(TABLE_SUPPORTS_CREATE, String.valueOf(objectMetadata.isCreateable()));
+ table.setProperty(TABLE_SUPPORTS_DELETE, String.valueOf(objectMetadata.isDeletable()));
+ table.setProperty(TABLE_SUPPORTS_MERGE, String.valueOf(objectMetadata.isMergeable()));
+ table.setProperty(TABLE_SUPPORTS_QUERY, String.valueOf(objectMetadata.isQueryable()));
+ table.setProperty(TABLE_SUPPORTS_REPLICATE, String.valueOf(objectMetadata.isReplicateable()));
+ table.setProperty(TABLE_SUPPORTS_RETRIEVE, String.valueOf(objectMetadata.isRetrieveable()));
+ table.setProperty(TABLE_SUPPORTS_SEARCH, String.valueOf(objectMetadata.isSearchable()));
+
+ hasUpdateableColumn = false;
+ addColumns(objectMetadata, table);
+
+ // Some SF objects return true for isUpdateable() but have no updateable columns.
+ if(hasUpdateableColumn && objectMetadata.isUpdateable()) {
+ table.setSupportsUpdate(true);
+ }
+ }
+
+ private void getRelationships(DescribeSObjectResult objectMetadata) {
+ ChildRelationship[] children = objectMetadata.getChildRelationships();
+ if(children != null && children.length != 0) {
+ for (int i = 0; i < children.length; i++) {
+ ChildRelationship childRelation = children[i];
+ Relationship newRelation = new RelationshipImpl();
+ newRelation.setParentTable(objectMetadata.getName());
+ newRelation.setChildTable(childRelation.getChildSObject());
+ newRelation.setForeignKeyField(childRelation.getField());
+ newRelation.setCascadeDelete(childRelation.isCascadeDelete());
+ relationships.add(newRelation);
+ }
+ }
+ }
+
+ private void addColumns(DescribeSObjectResult objectMetadata, Table table) throws ConnectorException {
+ Field[] fields = objectMetadata.getFields();
+ for (int i=0;i < fields.length;i++) {
+ Field field = fields[i];
+ String normalizedName = NameUtil.normalizeName(field.getName());
+ FieldType fieldType = field.getType();
+ if(!this.connectorEnv.isModelAuditFields() && isAuditField(field.getName())) {
+ continue;
+ }
+ String sfTypeName = fieldType.getValue();
+ Column column = null;
+ if(sfTypeName.equals(FieldType._value1) || //string
+ sfTypeName.equals(FieldType._value4) || //"combobox"
+ sfTypeName.equals(FieldType._value5) || //"reference"
+ sfTypeName.equals(FieldType._value13) || //"phone"
+ sfTypeName.equals(FieldType._value14) || //"id"
+ sfTypeName.equals(FieldType._value18) || //"url"
+ sfTypeName.equals(FieldType._value19) || //"email"
+ sfTypeName.equals(FieldType._value20) || //"encryptedstring"
+ sfTypeName.equals(FieldType._value21)) { //"anytype"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ column.setNativeType(sfTypeName);
+ if(sfTypeName.equals(FieldType._value14)) {
+ column.setNullType(NullType.No_Nulls);
+ ArrayList<String> columnNames = new ArrayList<String>();
+ columnNames.add(field.getName());
+ metadataFactory.addPrimaryKey(field.getName()+"_PK", columnNames, table);
+ }
+ }
+ else if(sfTypeName.equals(FieldType._value2)) { // "picklist"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ if(field.isRestrictedPicklist()) {
+ column.setNativeType("restrictedpicklist");
+ } else {
+ column.setNativeType(FieldType._value2);
+ }
+
+ column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
+ }
+ else if(sfTypeName.equals(FieldType._value3)) { //"multipicklist"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ if(field.isRestrictedPicklist()) {
+ column.setNativeType("restrictedmultiselectpicklist");
+ } else {
+ column.setNativeType(FieldType._value3);
+ }
+ column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
+ }
+ else if(sfTypeName.equals(FieldType._value6)) { //"base64"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BLOB, table);
+ column.setNativeType(FieldType._value6);
+ }
+ else if(sfTypeName.equals(FieldType._value7)) { //"boolean"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BOOLEAN, table);
+ column.setNativeType(FieldType._value7);
+ }
+ else if(sfTypeName.equals(FieldType._value8)) { //"currency"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
+ column.setNativeType(FieldType._value8);
+ column.setCurrency(true);
+ column.setScale(field.getScale());
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType._value9)) { //"textarea"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ column.setNativeType(FieldType._value9);
+ column.setSearchType(SearchType.Unsearchable);
+ }
+ else if(sfTypeName.equals(FieldType._value10)) { //"int"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.INTEGER, table);
+ column.setNativeType(FieldType._value10);
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType._value11) || //"double"
+ sfTypeName.equals(FieldType._value12)) { //"percent"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
+ column.setNativeType(sfTypeName);
+ column.setScale(field.getScale());
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType._value15)) { //"date"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DATE, table);
+ column.setNativeType(FieldType._value15);
+ }
+ else if(sfTypeName.equals(FieldType._value16)) { //"datetime"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIMESTAMP, table);
+ column.setNativeType(FieldType._value16);
+ }
+ else if(sfTypeName.equals(FieldType._value17)) { //"time"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIME, table);
+ column.setNativeType(FieldType._value17);
+ }
+ if(null == column) {
+ connectorEnv.getLogger().logError("Unknown type returned by SalesForce: " + sfTypeName);
+ continue;
+ } else {
+ column.setNameInSource(field.getName());
+ column.setLength(field.getLength());
+ if(field.isUpdateable()) {
+ column.setUpdatable(true);
+ hasUpdateableColumn = true;
+ }
+ column.setProperty(COLUMN_CALCULATED, String.valueOf(field.isCalculated()));
+ column.setProperty(COLUMN_CUSTOM, String.valueOf(field.isCustom()));
+ column.setProperty(COLUMN_DEFAULTED, String.valueOf(field.isDefaultedOnCreate()));
+ }
+
+ }
+ }
+
+ private String getPicklistValues(Field field) {
+ StringBuffer picklistValues = new StringBuffer();
+ if(null != field.getPicklistValues() && 0 != field.getPicklistValues().length) {
+ List<PicklistEntry> entries = Arrays.asList(field.getPicklistValues());
+ for (Iterator iterator = entries.iterator(); iterator.hasNext();) {
+ PicklistEntry entry = (PicklistEntry) iterator.next();
+ picklistValues.append(entry.getValue());
+ if(iterator.hasNext()) {
+ picklistValues.append(',');
+ }
+ }
+ }
+ return picklistValues.toString();
+ }
+}
Copied: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/NameUtil.java (from rev 1798, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/NameUtil.java)
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/NameUtil.java (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/NameUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package com.metamatrix.connector.salesforce;
+
+import org.teiid.connector.visitor.util.SQLReservedWords;
+
+public class NameUtil {
+
+ public static String normalizeName( String nameIn ) {
+ String normal = nameIn.trim();
+ normal = removeDuplicate(normal);
+ normal = removeSpaces(normal);
+ normal = removeIllegalChars(normal);
+ normal = removeTrailingUnderscore(normal);
+ normal = removeLeadingUnderscore(normal);
+ normal = checkReservedWords(normal);
+ return normal;
+
+ }
+
+ /**
+ * @param normal
+ * @return
+ */
+ private static String checkReservedWords( String normal ) {
+ if (SQLReservedWords.isReservedWord(normal)) {
+ normal = normal + "_"; //$NON-NLS-1$
+ }
+ return normal;
+ }
+
+ private static String removeTrailingUnderscore( String normal ) {
+ if (normal.endsWith("_")) { //$NON-NLS-1$
+ return normal.substring(0, normal.lastIndexOf('_'));
+ }
+ return normal;
+ }
+
+ private static String removeIllegalChars( String normal ) {
+ String edit = normal;
+ edit = edit.replace('.', '_');
+ edit = edit.replace('(', '_');
+ edit = edit.replace(')', '_');
+ edit = edit.replace('/', '_');
+ edit = edit.replace('\\', '_');
+ edit = edit.replace(':', '_');
+ edit = edit.replace('\'', '_');
+ edit = edit.replace('-', '_');
+ edit = edit.replace("%", "percentage");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("#", "number");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("$", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("{", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("}", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ return edit;
+ }
+
+ private static String removeSpaces( String normal ) {
+ return normal.replace(' ', '_');
+ }
+
+ private static String removeDuplicate( String normal ) {
+ if (normal.indexOf('(') < 0 || normal.indexOf(')') != normal.length() - 1) return normal;
+ String firstPart = normal.substring(0, normal.indexOf('(')).trim();
+ String secondPart = normal.substring(normal.indexOf('(') + 1, normal.length() - 1).trim();
+ if (firstPart.equals(secondPart) || secondPart.equals("null")) return firstPart; //$NON-NLS-1$
+ return normal;
+ }
+
+ /**
+ * @param normal
+ * @return
+ */
+ private static String removeLeadingUnderscore( String normal ) {
+ while (normal.indexOf('_') == 0) {
+ normal = normal.substring(1);
+ }
+ return normal;
+ }
+
+}
\ No newline at end of file
Copied: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Relationship.java (from rev 1798, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Relationship.java)
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Relationship.java (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Relationship.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,21 @@
+package com.metamatrix.connector.salesforce;
+
+public interface Relationship {
+
+ void setParentTable(String name);
+
+ void setChildTable(String childSObject);
+
+ void setForeignKeyField(String field);
+
+ void setCascadeDelete(boolean cascadeDelete);
+
+ public boolean isCascadeDelete();
+
+ public String getChildTable();
+
+ public String getForeignKeyField();
+
+ public String getParentTable();
+
+}
Copied: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/RelationshipImpl.java (from rev 1798, trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/RelationshipImpl.java)
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/RelationshipImpl.java (rev 0)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/RelationshipImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,40 @@
+package com.metamatrix.connector.salesforce;
+
+public class RelationshipImpl implements Relationship {
+ boolean cascadeDelete;
+ public String childTablename;
+ public String parentTableName;
+ public String foreignKeyField;
+
+ public void setCascadeDelete(boolean delete) {
+ cascadeDelete = delete;
+ }
+
+ public boolean isCascadeDelete() {
+ return cascadeDelete;
+ }
+
+ public void setChildTable(String childTable) {
+ childTablename = childTable;
+ }
+
+ public String getChildTable() {
+ return childTablename;
+ }
+
+ public String getForeignKeyField() {
+ return foreignKeyField;
+ }
+
+ public void setForeignKeyField(String foreignKeyField) {
+ this.foreignKeyField = foreignKeyField;
+ }
+
+ public String getParentTable() {
+ return parentTableName;
+ }
+
+ public void setParentTable(String parentTableName) {
+ this.parentTableName = parentTableName;
+ }
+}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/SalesForceManagedConnectionFactory.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -37,6 +37,7 @@
private URL URL;
private long sourceConnectionTestInterval = -1;
private int sourceConnectionTimeout = -1;
+ private boolean auditModelFields = false;
public String getUsername() {
return username;
@@ -83,6 +84,12 @@
public void setSourceConnectionTimeout(Integer sourceConnectionTimeout) {
this.sourceConnectionTimeout = sourceConnectionTimeout.intValue();
}
+ public void setModelAuditFields(Boolean modelAuditFields) {
+ this.auditModelFields = modelAuditFields.booleanValue();
+ }
+ public boolean isModelAuditFields() {
+ return this.auditModelFields;
+ }
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -90,5 +97,5 @@
sb.append(" ConnectorStateClass=").append(this.connectorStateClass);
sb.append(" URL=").append(this.URL);
return sb.toString();
- }
+ }
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -28,6 +28,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.MetadataProvider;
import org.teiid.connector.api.ProcedureExecution;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.UpdateExecution;
@@ -35,9 +36,11 @@
import org.teiid.connector.language.ICommand;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.language.IQueryCommand;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.salesforce.Messages;
+import com.metamatrix.connector.salesforce.MetadataProcessor;
import com.metamatrix.connector.salesforce.SalesForceManagedConnectionFactory;
import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
import com.metamatrix.connector.salesforce.execution.DataPayload;
@@ -49,10 +52,12 @@
import com.metamatrix.connector.salesforce.execution.UpdateExecutionImpl;
import com.metamatrix.connector.salesforce.execution.UpdatedResult;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.sforce.soap.partner.DescribeGlobalResult;
+import com.sforce.soap.partner.DescribeSObjectResult;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.sobject.SObject;
-public class SalesforceConnection extends BasicConnection {
+public class SalesforceConnection extends BasicConnection implements MetadataProvider {
private SalesForceManagedConnectionFactory connectorEnv;
private ConnectionImpl connection;
@@ -161,4 +166,19 @@
objects, objects.length);
return result;
}
+
+ public DescribeGlobalResult getObjects() throws ConnectorException {
+ return connection.getObjects();
+ }
+
+ public DescribeSObjectResult getObjectMetaData(String objectName) throws ConnectorException {
+ return connection.getObjectMetaData(objectName);
+ }
+
+ @Override
+ public void getConnectorMetadata(MetadataFactory metadataFactory)
+ throws ConnectorException {
+ MetadataProcessor processor = new MetadataProcessor(this,metadataFactory, connectorEnv);
+ processor.processMetadata();
+ }
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -48,6 +48,8 @@
import com.sforce.soap.partner.CallOptions;
import com.sforce.soap.partner.DeleteResult;
import com.sforce.soap.partner.DeletedRecord;
+import com.sforce.soap.partner.DescribeGlobalResult;
+import com.sforce.soap.partner.DescribeSObjectResult;
import com.sforce.soap.partner.GetDeletedResult;
import com.sforce.soap.partner.GetUpdatedResult;
import com.sforce.soap.partner.LoginResult;
@@ -340,4 +342,26 @@
throw new ConnectorException(e, e.getMessage());
}
}
+
+ public DescribeGlobalResult getObjects() throws ConnectorException {
+ try {
+ return binding.describeGlobal();
+ } catch (RemoteException e) {
+ ConnectorException ce = new ConnectorException(e.getCause().getMessage());
+ ce.initCause(e.getCause());
+ throw ce;
+ }
+ }
+
+ public DescribeSObjectResult getObjectMetaData(String objectName) throws ConnectorException {
+ try {
+ return binding.describeSObject(objectName);
+ } catch (InvalidSObjectFault e) {
+ throw new ConnectorException(e.getExceptionMessage());
+ } catch (UnexpectedErrorFault e) {
+ throw new ConnectorException(e.getMessage());
+ } catch (RemoteException e) {
+ throw new ConnectorException(e, e.getMessage());
+ }
+ }
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -64,7 +64,10 @@
String val;
if(value instanceof ILiteral) {
ILiteral literalValue = (ILiteral)value;
- val = this.stripQutes(literalValue.getValue().toString());
+ val = literalValue.getValue().toString();
+ if(null != val && !val.isEmpty()) {
+ val = this.stripQutes(val);
+ }
} else {
val = value.toString();
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -51,7 +51,7 @@
private int idIndex = -1; // index of the ID select symbol.
protected List<ISelectSymbol> selectSymbols;
protected StringBuffer limitClause = new StringBuffer();
- private Boolean supportsRetrieve;
+ private Boolean objectSupportsRetrieve;
public SelectVisitor(RuntimeMetadata metadata) {
super(metadata);
@@ -113,7 +113,7 @@
if(fromItem instanceof IGroup) {
table = ((IGroup)fromItem).getMetadataObject();
String supportsQuery = (String)table.getProperties().get(Constants.SUPPORTS_QUERY);
- supportsRetrieve = Boolean.valueOf((String)table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
+ objectSupportsRetrieve = Boolean.valueOf((String)table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
if (!Boolean.valueOf(supportsQuery)) {
throw new ConnectorException(table.getNameInSource() + " "
+ Messages.getString("CriteriaVisitor.query.not.supported"));
@@ -230,7 +230,7 @@
}
public boolean canRetrieve() {
- return supportsRetrieve && hasOnlyIDCriteria();
+ return objectSupportsRetrieve && hasOnlyIDCriteria();
}
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -121,8 +121,15 @@
<config-property-name>SourceConnectionTimeout</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>120000</config-property-value>
- </config-property>
+ </config-property>
+ <config-property>
+ <description>{$display:"Audit Model Fields",$advanced:"true"}</description>
+ <config-property-name>ModelAuditFields</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>false</config-property-value>
+ </config-property>
+
<connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
<connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
<connection-interface>org.teiid.connector.api.Connection</connection-interface>
Modified: branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorException;
@@ -80,7 +81,7 @@
private boolean caching = false;
- private Map<String, SQLXML> responses = new HashMap<String, SQLXML>();
+ private Map<String, SQLXML> responses = new ConcurrentHashMap<String, SQLXML>();
public XMLConnectorStateImpl() {
setPreprocess(true);
Modified: branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -47,7 +47,7 @@
/**
*/
-public class ObjectExecutionHelper implements SQLReservedWords {
+public class ObjectExecutionHelper {
private static final String ESCAPED_QUOTE = "''"; //$NON-NLS-1$
private static final TimeZone LOCAL_TIME_ZONE = TimeZone.getDefault();
@@ -58,7 +58,7 @@
* @return a SQL-safe string
*/
protected String escapeString(String str) {
- return StringUtil.replaceAll(str, QUOTE, ESCAPED_QUOTE);
+ return StringUtil.replaceAll(str, SQLReservedWords.QUOTE, ESCAPED_QUOTE);
}
/**
Copied: branches/JCA/console/.settings (from rev 1798, trunk/console/.settings)
Deleted: branches/JCA/console/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/console/.settings/org.eclipse.jdt.core.prefs 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/console/.settings/org.eclipse.jdt.core.prefs 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,5 +0,0 @@
-#Wed Nov 25 10:51:47 CST 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
Copied: branches/JCA/console/.settings/org.eclipse.jdt.core.prefs (from rev 1798, trunk/console/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- branches/JCA/console/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ branches/JCA/console/.settings/org.eclipse.jdt.core.prefs 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,5 @@
+#Wed Nov 25 10:51:47 CST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
Deleted: branches/JCA/console/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- trunk/console/.settings/org.maven.ide.eclipse.prefs 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/console/.settings/org.maven.ide.eclipse.prefs 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,9 +0,0 @@
-#Wed Jan 20 12:26:36 CST 2010
-activeProfiles=
-eclipse.preferences.version=1
-fullBuildGoals=process-test-resources
-includeModules=true
-resolveWorkspaceProjects=true
-resourceFilterGoals=process-resources resources\:testResources
-skipCompilerPlugin=true
-version=1
Copied: branches/JCA/console/.settings/org.maven.ide.eclipse.prefs (from rev 1798, trunk/console/.settings/org.maven.ide.eclipse.prefs)
===================================================================
--- branches/JCA/console/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ branches/JCA/console/.settings/org.maven.ide.eclipse.prefs 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,9 @@
+#Wed Jan 20 12:26:36 CST 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=true
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Modified: branches/JCA/console/src/assembly/assemble-artifacts.xml
===================================================================
--- branches/JCA/console/src/assembly/assemble-artifacts.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/assembly/assemble-artifacts.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -4,7 +4,7 @@
<property name="embedded.temp.dir" value="${temp.dir}/embedded"/>
<!-- this contains jars to be included in the embedded war -->
- <property name="embedded.jar" value="${basedir}/target/distribution/jbedsp-embedded-plugin-${product.version}.jar"/>
+ <property name="embedded.jar" value="${basedir}/target/distribution/teiid-embedded-plugin-${product.version}.jar"/>
<property name="enterprise.temp.dir" value="${temp.dir}/enterprise"/>
<!-- this is the plugin to be deployed to JON that get sent to the agent -->
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -91,14 +91,7 @@
}
}
- public interface Host {
- public final static String TYPE = "Runtime.Host"; //$NON-NLS-1$
-
- public static interface Operations {
- public final static String GET_HOSTS = "getHosts"; //$NON-NLS-1$
-
- }
- }
+
public interface Process {
@@ -160,6 +153,27 @@
}
public interface Resource {
+
+ public interface VDB {
+ public final static String TYPE = "teiid"; //$NON-NLS-1$
+ public final static String SUBTYPE = "vdb"; //$NON-NLS-1$
+
+
+ public static interface Operations {
+
+ }
+ }
+
+ public interface Model {
+ public final static String TYPE = "teiid"; //$NON-NLS-1$
+ public final static String SUBTYPE = "model"; //$NON-NLS-1$
+
+
+ public static interface Operations {
+
+ }
+ }
+
public interface Service {
public final static String TYPE = "Resource.Service"; //$NON-NLS-1$
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Connector;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Connector.Operations;
-
-
-/**
- * MetaMatrix Connector component class
- *
- */
-public class ConnectorComponent extends Facet {
-
- private final Log LOG = LogFactory.getLog(ConnectorComponent.class);
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Connector.TYPE;
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
- if (name.equals(Operations.STOP_CONNECTOR)){
- Boolean stopNow = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW).getBooleanValue();
- argumentMap.put(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW, stopNow);
- }
- //Need identifier for all Connector operations
- String key = ConnectionConstants.IDENTIFIER;
- argumentMap.put(key, getComponentIdentifier());
-
- }
-
- @Override
- public void getValues(MeasurementReport arg0,
- Set<MeasurementScheduleRequest> arg1) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
-// @Override
-// public OperationResult invokeOperation(String name,
-// Configuration configuration) {
-// Map valueMap = new HashMap();
-// Connection conn = null;
-//
-// Set operationDefinitionSet = this.resourceContext.getResourceType()
-// .getOperationDefinitions();
-//
-// ExecutedOperationResult result = initResult(name, operationDefinitionSet);
-//
-// setValueMap(name, configuration, valueMap);
-//
-// execute(conn, result, getComponentType(), name, valueMap);
-//
-// return ((ExecutedOperationResultImpl) result).getOperationResult();
-//
-
-// Connection conn = null;
-// Map valueMap = new HashMap();
-// MMOperationResult result = null;
-//
-// // Add "stop now" value if we are attempting to stop a connector
-// if (name.equals(ComponentType.Operation.STOP_CONNECTOR)) {
-// Boolean stopNow = configuration.getSimple(
-// ConnectionConstants.ComponentType.Operation.Value.STOP_NOW)
-// .getBooleanValue();
-// valueMap.put(
-// ConnectionConstants.ComponentType.Operation.Value.STOP_NOW,
-// stopNow);
-// }
-//
-// valueMap.put(ConnectionConstants.IDENTIFIER, getComponentIdentifier());
-//
-// try {
-// conn = getConnection();
-//
-// if (!conn.isValid()) {
-// return null;
-// }
-// // Object operationReturnObject =
-// conn.executeOperation(result,
-// getComponentType(), name, valueMap);
-//
-//
-// } catch (Exception e) {
-// final String msg = "Failed to invoke operation [" + name + "]. Cause: " + e; //$NON-NLS-1$ //$NON-NLS-2$
-// LOG.error(msg);
-// throw new RuntimeException(msg);
-// } finally {
-// conn.close();
-// }
-//
-// return (OperationResult)result;
-// }
-}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Collection;
-
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-
-
-/**
- * Discovery component used to discover the monitored connector bindings
- *
- */
-public class ConnectorDiscoveryComponent extends NodeChildrenDiscoveryComponent {
-
- Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
- return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Connector.TYPE, parent.getComponentIdentifier());
- }
-
-
-}
\ No newline at end of file
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -55,11 +55,9 @@
import org.teiid.rhq.admin.utils.SingletonConnectionManager;
import org.teiid.rhq.comm.Component;
import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
import org.teiid.rhq.comm.ConnectionException;
import org.teiid.rhq.comm.ExecutedResult;
import org.teiid.rhq.comm.VMComponent;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
@@ -112,31 +110,6 @@
*/
public void start(ResourceContext context) {
resourceContext = context;
-
-
- systemKey = resourceContext.getPluginConfiguration()
- .getSimpleProperties().get(Component.SYSTEM_KEY)
- .getStringValue();
- name = resourceContext.getPluginConfiguration().getSimpleProperties()
- .get(Component.NAME).getStringValue();
-
- // because the system may not be up, name and
- // identifier may be null at initial creation
- // and will be updated when the system becomes available.
- if (name == null)
- name = "NotSet"; //$NON-NLS-1$
-
- identifier = resourceContext.getPluginConfiguration()
- .getSimpleProperties().get(Component.IDENTIFIER)
- .getStringValue();
- if (identifier == null)
- identifier = "";//$NON-NLS-1$
- if (resourceContext.getPluginConfiguration().getSimpleProperties().get(
- VMComponent.PORT) != null) {
- port = resourceContext.getPluginConfiguration()
- .getSimpleProperties().get(VMComponent.PORT)
- .getStringValue();
- }
}
/**
@@ -244,31 +217,9 @@
*/
public AvailabilityType getAvailability() {
- if (!connMgr.hasServersDefined()) {
- this.isAvailable = false;
- return AvailabilityType.DOWN;
-
- }
- Connection connection = null;
- try {
-
- LOG.debug("Checking availability of " + identifier); //$NON-NLS-1$
- connection = getConnection();
- if (connection.isAvailable(getComponentType(), identifier)) {
- LOG.info("Availability of " + identifier + " is up"); //$NON-NLS-1$ //$NON-NLS-2$
- this.isAvailable = true;
- return AvailabilityType.UP;
- }
- } catch (InvalidPluginConfigurationException ipce) {
- // dont log anything, already done when getconnection is called
- } catch (Throwable err) {
- LOG.error("Unknown exception occured when checking availability for resource " + identifier, err); //$NON-NLS-1$
- } finally {
- connection.close();
- }
- LOG.error("Availability of " + identifier + " is down"); //$NON-NLS-1$ //$NON-NLS-2$
- this.isAvailable = false;
- return AvailabilityType.DOWN;
+ LOG.debug("Checking availability of " + identifier); //$NON-NLS-1$
+
+ return AvailabilityType.UP;
}
/**
@@ -339,9 +290,9 @@
// start with.
// note that it is empty, so we're assuming there are no required
// configs in the plugin descriptor.
- resourceConfiguration = new Configuration();
+ resourceConfiguration = this.resourceContext.getPluginConfiguration();
}
-
+
Configuration config = resourceConfiguration;
return config;
@@ -438,4 +389,6 @@
*/
public void deleteResource() {
}
+
+
}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host;
-
-
-/**
- * Component class for the MetaMatrix Host Controller process.
- *
- */
-public class HostComponent extends Facet {
- private final Log LOG = LogFactory
- .getLog(HostComponent.class);
-
-
- public static final String CONNECTOR_ADDRESS_CONFIG_PROPERTY = "connectorAddress"; //$NON-NLS-1$
-
- public static final String CONNECTION_TYPE = "type"; //$NON-NLS-1$
-
- public static final String PARENT_TYPE = "PARENT"; //$NON-NLS-1$
-
- public static final String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
-
-
- private String install_dir;
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Host.TYPE;
- }
-
-
-
- String getInstallDirectory() {
-
- if (install_dir != null) {
- return install_dir;
- }
- install_dir = resourceContext.getPluginConfiguration()
- .getSimpleProperties().get(INSTALL_DIR)
- .getStringValue();
-
- return install_dir;
- }
-
-
- /**
- * The plugin container will call this method when your resource component
- * has been scheduled to collect some measurements now. It is within this
- * method that you actually talk to the managed resource and collect the
- * measurement data that is has emitted.
- *
- * @see MeasurementFacet#getValues(MeasurementReport, Set)
- */
- public void getValues(MeasurementReport report,
- Set<MeasurementScheduleRequest> requests) {
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
-
- // TODO: based on the request information, you must collect the
- // requested measurement(s)
- // you can use the name of the measurement to determine what you
- // actually need to collect
- try {
- Number value = new Integer(1); // dummy measurement value -
- // this should come from the
- // managed resource
- report.addData(new MeasurementDataNumeric(request, value
- .doubleValue()));
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- }
- }
-
- return;
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
- if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
- String key = ConnectionConstants.IDENTIFIER;
- argumentMap.put(key, getComponentIdentifier());
- }
-
- }
-
- /**
- * The plugin container will call this method and it needs to obtain the
- * current configuration of the managed resource. Your plugin will obtain
- * the managed resource's configuration in your own custom way and populate
- * the returned Configuration object with the managed resource's
- * configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- *
- */
- @Override
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
- Configuration config = this.getResourceConfiguration() ;
- if (config == null) {
- // for this example, we will create a simple dummy configuration to
- // start with.
- // note that it is empty, so we're assuming there are no required
- // configs in the plugin descriptor.
- config = new Configuration();
- }
-
- Properties props;
- try {
- props = getConnection().getProperties(this.getComponentType(), this.getComponentIdentifier());
- } catch (ConnectionException e) {
- LOG.error("Failed to obtain host properties for [" + this.getComponentIdentifier() //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- throw new InvalidPluginConfigurationException(e);
- }
-
- if (props != null && props.size() > 0) {
- Iterator it=props.keySet().iterator();
- while(it.hasNext()) {
- String k = (String)it.next();
-
- config.put(new PropertySimple(k, props.get(k)));
-
- }
-
- }
-
-
- this.setResourceConfiguration(config);
- return this.getResourceConfiguration();
- }
-
-}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Collection;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-
-
-/**
- * Discovery component for the MetaMatrix Host controller process
- *
- */
-public class HostDiscoveryComponent extends NodeChildrenDiscoveryComponent {
-
-
- @Override
- Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
- return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Host.TYPE, "*");
- }
-
- @Override
- protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
- String installdir = component.getProperty(HostComponent.INSTALL_DIR);
- configuration.put(new PropertySimple(HostComponent.INSTALL_DIR,
- installdir));
- }
-
-
-}
\ No newline at end of file
Copied: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelComponent.java (from rev 1798, trunk/console/src/main/java/org/teiid/rhq/plugin/ModelComponent.java)
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelComponent.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.rhq.plugin;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.teiid.rhq.comm.ConnectionConstants;
+
+
+/**
+ * Component class for the MetaMatrix Host Controller process.
+ *
+ */
+public class ModelComponent extends Facet {
+ private final Log LOG = LogFactory
+ .getLog(ModelComponent.class);
+
+
+ /**
+ * @see org.teiid.rhq.plugin.Facet#getComponentType()
+ * @since 1.0
+ */
+ @Override
+ String getComponentType() {
+ return ConnectionConstants.ComponentType.Resource.Model.TYPE;
+ }
+
+ /**
+ * The plugin container will call this method when your resource component
+ * has been scheduled to collect some measurements now. It is within this
+ * method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report,
+ Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the
+ // requested measurement(s)
+ // you can use the name of the measurement to determine what you
+ // actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value -
+ // this should come from the
+ // managed resource
+ report.addData(new MeasurementDataNumeric(request, value
+ .doubleValue()));
+ } catch (Exception e) {
+ LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+ + "]. Cause: " + e); //$NON-NLS-1$
+ }
+ }
+
+ return;
+ }
+
+ protected void setOperationArguments(String name, Configuration configuration,
+ Map argumentMap) {
+
+ if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
+ String key = ConnectionConstants.IDENTIFIER;
+ argumentMap.put(key, getComponentIdentifier());
+ }
+
+ }
+
+}
\ No newline at end of file
Copied: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelDiscoveryComponent.java (from rev 1798, trunk/console/src/main/java/org/teiid/rhq/plugin/ModelDiscoveryComponent.java)
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelDiscoveryComponent.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ModelDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,150 @@
+/*
+ * 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.rhq.plugin;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+
+/**
+ * Discovery component for the MetaMatrix Host controller process
+ *
+ */
+public class ModelDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext discoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+ PropertyList list = discoveryContext.getParentResourceContext().getPluginConfiguration().getList("models");
+
+ Iterator<Property> listIter = list.getList().iterator();
+
+ while(listIter.hasNext()){
+ PropertyMap propertyMap = (PropertyMap)listIter.next();
+
+ String modelName = ((PropertySimple)propertyMap.getMap().get("name")).getStringValue();
+
+ ManagedComponent model = ProfileServiceUtil
+ .getManagedComponent(new ComponentType(
+ PluginConstants.ComponentType.Model.TYPE,
+ PluginConstants.ComponentType.Model.SUBTYPE),
+ modelName);
+
+ /**
+ *
+ * A discovered resource must have a unique key, that must stay the same
+ * when the resource is discovered the next time
+ */
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ modelName, // Resource Key
+ modelName, // Resource Name
+ null, // Version TODO can we get that from discovery ?
+ PluginConstants.ComponentType.Model.DESCRIPTION, // Description
+ discoveryContext.getDefaultPluginConfiguration(), // Plugin Config
+ null // Process info from a process scan
+ );
+
+ // modelURI, connectorBindingNames, source, visible, modelType, visibility, supportsMultiSourceBindings,
+ // name, path, uuid, properties
+ String name = ((SimpleValueSupport)model.getProperty("name").getValue()).getValue().toString();
+ String path = ((SimpleValueSupport)model.getProperty("path").getValue()).getValue().toString();
+ String modelURI = ((SimpleValueSupport)model.getProperty("modelURI").getValue()).getValue().toString();
+ String source = ((SimpleValueSupport)model.getProperty("source").getValue()).getValue().toString();
+ String visible = ((SimpleValueSupport)model.getProperty("visible").getValue()).getValue().toString();
+ String modelType = ((SimpleValueSupport)model.getProperty("modelType").getValue()).getValue().toString();
+ String supportsMultiSourceBindings = ((SimpleValueSupport)model.getProperty("supportsMultiSourceBindings").getValue()).getValue().toString();
+
+ Configuration c = detail.getPluginConfiguration();
+
+ getConnectors(model, c);
+
+ c.put(new PropertySimple("name", name));
+ c.put(new PropertySimple("path", path));
+ c.put(new PropertySimple("modelURI", modelURI));
+ c.put(new PropertySimple("source", source));
+ c.put(new PropertySimple("visible", visible));
+ c.put(new PropertySimple("modelType", modelType));
+ c.put(new PropertySimple("supportsMultiSourceBindings", supportsMultiSourceBindings));
+
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered Teiid Model: " + modelName);
+ }
+
+ return discoveredResources;
+ }
+
+ /**
+ * @param mcVdb
+ * @param configuration
+ */
+ private void getConnectors(ManagedComponent model, Configuration configuration) {
+ //Get Connector(s) from Model
+ ManagedProperty property = model.getProperty("connectorBindingNames");
+ CollectionValueSupport valueSupport = (CollectionValueSupport) property.getValue();
+ MetaValue[] metaValues = valueSupport.getElements();
+
+ PropertyList connectorsList = new PropertyList("connectors");
+ configuration.put(connectorsList);
+
+ for (MetaValue value : metaValues) {
+ SimpleValueSupport simpleValueSupport = (SimpleValueSupport) value;
+ String connectorName = (String)simpleValueSupport.getValue();
+
+ PropertyMap connector = new PropertyMap("connector", new PropertySimple("name", connectorName));
+ connectorsList.add(connector);
+ }
+ }
+
+}
\ No newline at end of file
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -50,47 +50,18 @@
private final Log LOG = LogFactory.getLog(PlatformComponent.class);
/**
- * Property is used to identify an unreachable system
- */
- protected static final String UNREACHABLE_NAME = "UNREACHABLE_PLATFORM"; //$NON-NLS-1$
-
- /**
* @see org.teiid.rhq.plugin.Facet#getComponentType()
* @since 4.3
*/
@Override
String getComponentType() {
- return ConnectionConstants.ComponentType.PLATFORM;
+ return null;
}
@Override
public AvailabilityType getAvailability() {
- if (!connMgr.hasServersDefined()) {
- this.isAvailable = false;
- return AvailabilityType.DOWN;
-
- }
- Connection connection = null;
- try {
-
- LOG.debug("Checking availability of " + this.getComponentIdentifier()); //$NON-NLS-1$
- connection = getConnection();
- if (connection.isAlive()) {
- LOG.info("Availability of " + this.getComponentIdentifier() + " is up"); //$NON-NLS-1$ //$NON-NLS-2$
- this.isAvailable = true;
- return AvailabilityType.UP;
- }
- } catch (InvalidPluginConfigurationException ipce) {
- // dont log anything, already done when getconnection is called
- } catch (Throwable err) {
- LOG.error("Unknown exception occured when checking availability for resource " + this.getComponentIdentifier(), err); //$NON-NLS-1$
- } finally {
- connection.close();
- }
- LOG.error("Availability of " + this.getComponentIdentifier() + " is down"); //$NON-NLS-1$ //$NON-NLS-2$
- this.isAvailable = false;
- return AvailabilityType.DOWN;
+ return AvailabilityType.UP;
}
@@ -112,7 +83,6 @@
public void stop() {
// TODO Auto-generated method stub
super.stop();
- connMgr.shutdown();
}
@Override
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -24,14 +24,10 @@
import java.util.HashSet;
import java.util.Set;
-import javax.naming.InitialContext;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.profileservice.spi.ProfileService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
@@ -39,18 +35,13 @@
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
* This is the parent node for a MetaMatrix system
*/
public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent {
-
- private static final Log LOG = LogFactory
- .getLog(PlatformDiscoveryComponent.class);
-
- public static final String p = "connectorAddress"; //$NON-NLS-1$
-
private final Log log = LogFactory.getLog(this.getClass());
/**
@@ -66,25 +57,14 @@
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
- InitialContext ic = new InitialContext();
- ProfileService ps = (ProfileService) ic.lookup(PluginConstants.PROFILE_SERVICE);
+ ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
+ new ComponentType(PluginConstants.ComponentType.Runtime.TYPE,
+ PluginConstants.ComponentType.Runtime.SUBTYPE),
+ PluginConstants.ComponentType.Runtime.TEIID_RUNTIME_ENGINE);
- ManagementView vm = ps.getViewManager();
- vm.load();
- ComponentType type = new ComponentType(PluginConstants.CONNECTION_FACTORY_TYPE, PluginConstants.NO_TX_SUBTYPE);
- ManagedComponent mc = vm.getComponent(PluginConstants.TEIID_RUNTIME_ENGINE,
- type);
-
- /*
- * Currently this uses a hardcoded remote address for access to the
- * MBean server This needs to be switched to check if we e.g. run inside
- * a JBossAS to which we have a connection already that we can reuse.
- */
- Configuration c = new Configuration(); // TODO get from
- // defaultPluginConfig
-
+ Configuration c = new Configuration();
String managerName = mc.getName();
-
+
c.put(new PropertySimple("objectName", managerName));
/**
*
@@ -94,9 +74,9 @@
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
managerName, // Resource Key
- PluginConstants.TEIID_ENGINE_RESOURCE_NAME, // Resource Name
+ PluginConstants.ComponentType.Runtime.TEIID_ENGINE_RESOURCE_NAME, // Resource Name
null, // Version TODO can we get that from discovery ?
- PluginConstants.TEIID_ENGINE_RESOURCE_DESCRIPTION, // Description
+ PluginConstants.ComponentType.Runtime.TEIID_ENGINE_RESOURCE_DESCRIPTION, // Description
c, // Plugin Config
null // Process info from a process scan
);
@@ -105,6 +85,6 @@
discoveredResources.add(detail);
log.info("Discovered Teiid instance: " + managerName);
return discoveredResources;
-
+
}
}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,316 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.event.EventContext;
-import org.rhq.core.pluginapi.event.EventPoller;
-import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Process;
-import org.teiid.rhq.plugin.log.JBEDSPErrorLogEntryProcessor;
-
-
-/**
- *
- * MetaMatrix server component class. This class represents the node for the
- * MMProcess.
- *
- */
-public class ProcessComponent extends Facet {
- private final Log LOG = LogFactory.getLog(ProcessComponent.class);
-
-
- public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED = "enabled"; //$NON-NLS-1$
- public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY = "minimumSeverity"; //$NON-NLS-1$
- public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern"; //$NON-NLS-1$
- public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH = "errorLogFilePath"; //$NON-NLS-1$
- public static final String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
-
- private static final String ERROR_LOG_ENTRY_EVENT_TYPE = "errorLogEntry"; //$NON-NLS-1$
-
-
-
- private EventContext eventContext;
- private File errorLogFile;
-
-
- /**
- * @see org.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.ResourceContext)
- */
- @Override
- public void start(ResourceContext context) {
- super.start(context);
-
- this.eventContext = resourceContext.getEventContext();
-
- // startEventPollers();
- }
-
- /**
- * @see org.teiid.rhq.plugin.Facet#stop()
- */
- @Override
- public void stop() {
- stopEventPollers();
- super.stop();
-
- }
-
- public AvailabilityType getAvailability() {
-
- return AvailabilityType.UP;
- }
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Process.TYPE;
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
- if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
- String key = ConnectionConstants.IDENTIFIER;
- argumentMap.put(key, getComponentIdentifier());
- }
-
- }
-
-
- @Override
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) throws Exception {
- Connection conn = null;
- Map valueMap = new HashMap();
-
- try{
- conn = getConnection();
- if (!conn.isValid()) {
- return;
- }
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
- LOG.info("Measurement name = " + name); //$NON-NLS-1$
-
- Object metricReturnObject = conn.getMetric(getComponentType(), this.getComponentIdentifier(), name, valueMap);
-
- try {
- if (request.getName().equals(ComponentType.Metric.HIGH_WATER_MARK)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double)metricReturnObject));
- }
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- throw(e);
- }
- }
- }finally{
- conn.close();
- }
-
- }
-
-
- /**
- * The plugin container will call this method and it needs to obtain the
- * current configuration of the managed resource. Your plugin will obtain
- * the managed resource's configuration in your own custom way and populate
- * the returned Configuration object with the managed resource's
- * configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- *
- */
- @Override
- public Configuration loadResourceConfiguration() {
- // here we simulate the loading of the managed resource's configuration
- Configuration config = this.getResourceConfiguration() ;
- if (config == null) {
- // for this example, we will create a simple dummy configuration to
- // start with.
- // note that it is empty, so we're assuming there are no required
- // configs in the plugin descriptor.
- config = new Configuration();
- }
-
- Properties props;
- try {
- props = getConnection().getProperties(this.getComponentType(), this.getComponentIdentifier());
- } catch (ConnectionException e) {
- LOG.error("Failed to obtain process properties for [" + this.getComponentIdentifier() //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- throw new InvalidPluginConfigurationException(e);
- }
-
- if (props != null && props.size() > 0) {
- Iterator it=props.keySet().iterator();
- while(it.hasNext()) {
- String k = (String)it.next();
-
- config.put(new PropertySimple(k, props.get(k)));
-
- }
-
- }
-
-
- this.setResourceConfiguration(config);
- return this.getResourceConfiguration();
- }
-
-
- protected static String deriveFileName(final String identifier) {
-
- String startFileName = identifier.substring(0, identifier.indexOf("|")); //$NON-NLS-1$
- String endFileName = identifier.substring(identifier.indexOf("|")+1, identifier.length()); //$NON-NLS-1$
-
- startFileName = replaceAll(startFileName, ".", "_"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- String logfilename = startFileName.toLowerCase() + "_" + endFileName + ".log"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- return logfilename;
-
- }
-
- private void startEventPollers() {
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- Boolean enabled = Boolean.valueOf(pluginConfig.getSimpleValue(
- PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED, null)); //$NON-NLS-1$
- if (enabled) {
-
- String installdir = pluginConfig.getSimpleValue(
- INSTALL_DIR, null); //$NON-NLS-1$
- if (installdir == null) {
- throw new InvalidPluginConfigurationException(
- "Installation directory could not be determined in order for the process to monitor the log files"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- String logFileName = deriveFileName(this.getComponentIdentifier());
-
- String relativelogname = pluginConfig.getSimpleValue(
- PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH,
- "/log/" + logFileName); //$NON-NLS-1$
-
- errorLogFile = new File(installdir + "/" + relativelogname); //$NON-NLS-1$
-
- LOG.info("Start event polling on logfile: " + errorLogFile.getAbsolutePath()); //$NON-NLS-1$
-
- JBEDSPErrorLogEntryProcessor processor = new JBEDSPErrorLogEntryProcessor(
- ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile);
- String includesPatternString = pluginConfig.getSimpleValue(
- PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN, null);
- if (includesPatternString != null) {
- try {
- Pattern includesPattern = Pattern
- .compile(includesPatternString);
- processor.setIncludesPattern(includesPattern);
- } catch (PatternSyntaxException e) {
- throw new InvalidPluginConfigurationException(
- "Includes pattern [" + includesPatternString + "] is not a valid regular expression."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- String minimumSeverityString = pluginConfig.getSimpleValue(
- PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY, null);
- if (minimumSeverityString != null) {
- EventSeverity minimumSeverity = EventSeverity
- .valueOf(minimumSeverityString.toUpperCase());
- processor.setMinimumSeverity(minimumSeverity);
- }
- EventPoller poller = new LogFileEventPoller(this.eventContext,
- ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile, processor);
- this.eventContext.registerEventPoller(poller, 30, errorLogFile
- .getPath());
- }
- }
-
- private void stopEventPollers() {
-// Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
-// File errorLogFile =
-// resolvePathRelativeToServerRoot(pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH,
-// DEFAULT_ERROR_LOG_PATH));
- this.eventContext.unregisterEventPoller(ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile.getPath());
- }
-
-
- /*
- * Replace all occurrences of the search string with the replace string
- * in the source string. If any of the strings is null or the search string
- * is zero length, the source string is returned.
- * @param source the source string whose contents will be altered
- * @param search the string to search for in source
- * @param replace the string to substitute for search if present
- * @return source string with *all* occurrences of the search string
- * replaced with the replace string
- */
- private static String replaceAll(String source, String search, String replace) {
- if (source != null && search != null && search.length() > 0 && replace != null) {
- int start = source.indexOf(search);
- if (start > -1) {
- StringBuffer newString = new StringBuffer(source);
- replaceAll(newString, search, replace);
- return newString.toString();
- }
- }
- return source;
- }
-
- private static void replaceAll(StringBuffer source, String search, String replace) {
- if (source != null && search != null && search.length() > 0 && replace != null) {
- int start = source.toString().indexOf(search);
- while (start > -1) {
- int end = start + search.length();
- source.replace(start, end, replace);
- start = source.toString().indexOf(search, start + replace.length());
- }
- }
- }
-
-
-}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Collection;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.VMComponent;
-
-
-
-/**
- *
- * The discovery component class for the MetaMatrix server node
- *
- */
-public class ProcessDiscoveryComponent extends NodeChildrenDiscoveryComponent {
-
-
- Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
- return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Process.TYPE, parent.getComponentIdentifier());
- }
-
- protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
- configuration.put(new PropertySimple(VMComponent.PORT, ((VMComponent)component).getPort()));
-
- }
-}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Metrics;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Operations;
-
-
-/**
- *
- */
-public class SystemComponent extends Facet {
- private final Log LOG = LogFactory.getLog(SystemComponent.class);
-
- /**
- * Property is used to identify an unreachable system
- */
- protected static final String UNREACHABLE_NAME = "UNREACHABLE_SYSTEM"; //$NON-NLS-1$
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 4.3
- */
- @Override
- String getComponentType() {
- return ConnectionConstants.ComponentType.Runtime.System.TYPE;
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map valueMap) {
-
- // Parameter logic for System Operations
- if (name.equals(Query.GET_QUERIES) ||
- name.equals(Operations.GET_LONGRUNNINGQUERIES)) {
- Boolean includeSourceQueries = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES).getBooleanValue();
- Integer long_running_value = getResourceConfiguration().getSimple(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT).getIntegerValue();
- valueMap.put(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES, includeSourceQueries);
- valueMap.put(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT, long_running_value);
- }else if (name.equals(Operations.BOUNCE_SYSTEM)) {
- Boolean waitUntilFinished = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED).getBooleanValue();
- valueMap.put(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED, waitUntilFinished);
- }else if (name.equals(ConnectionConstants.ComponentType.Operation.KILL_REQUEST)) {
- String key = ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID;
- valueMap.put(key, configuration.getSimple(key).getStringValue());
- }else if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES) ) {
- String key = ConnectionConstants.IDENTIFIER;
- valueMap.put(key, getComponentIdentifier());
- }
-
- }
-
-
- @Override
- public void getValues(MeasurementReport report,
- Set<MeasurementScheduleRequest> requests) throws Exception {
-
- // because the sytsem object will be created before the use actually connects, checks have to be
- // made not to perform actions that will require a connection before its available
- if (!this.isAvailable()) {
- return;
- }
-
- Connection conn = null;
- Map valueMap = new HashMap();
-
- try {
- conn = getConnection();
- if (!conn.isValid()) {
- return;
- }
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
- LOG.debug("Measurement name = " + name); //$NON-NLS-1$
-
- //Initialize any parameters to be used in the retrieval of metric values
- if (request.getName().equals(Metrics.LONG_RUNNING_QUERIES)) {
- Integer value = getResourceConfiguration().getSimple(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT).getIntegerValue();
- valueMap.put(ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
- }
-
- Object metricReturnObject = conn.getMetric(getComponentType(),
- this.getComponentIdentifier(),
- name,
- valueMap);
-
- try {
- if (request.getName().equals(
- Metrics.QUERY_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request.getName().equals(
- Metrics.SESSION_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request.getName().equals(
- Metrics.LONG_RUNNING_QUERIES)) {
- report.addData(new MeasurementDataNumeric(
- request, (Double) metricReturnObject));
- }
- }
- }
-
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- // throw(e);
- }
- }
- } finally {
- if (conn != null) {
- conn.close();
- }
- }
- }
-
-//
-// @Override
-// public void updateResourceConfiguration(ConfigurationUpdateReport report) {
-//
-// Properties props = System.getProperties();
-//
-// Iterator<PropertySimple> pluginPropIter = report.getConfiguration().getSimpleProperties().values().iterator();
-//
-// while (pluginPropIter.hasNext()){
-// PropertySimple pluginProp = pluginPropIter.next();
-// props.put(pluginProp.getName(), pluginProp.getStringValue());
-// }
-//
-// SingletonConnectionManager.getInstance().initialize(props);
-// super.updateResourceConfiguration(report);
-//
-// }
-
-}
\ No newline at end of file
Copied: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java (from rev 1798, trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java)
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,94 @@
+/*
+ * 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.rhq.plugin;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.teiid.rhq.comm.ConnectionConstants;
+
+
+/**
+ * Component class for a Teiid VDB
+ *
+ */
+public class VDBComponent extends Facet {
+ private final Log LOG = LogFactory
+ .getLog(VDBComponent.class);
+
+ /**
+ * The plugin container will call this method when your resource component
+ * has been scheduled to collect some measurements now. It is within this
+ * method that you actually talk to the managed resource and collect the
+ * measurement data that is has emitted.
+ *
+ * @see MeasurementFacet#getValues(MeasurementReport, Set)
+ */
+ public void getValues(MeasurementReport report,
+ Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+
+ // TODO: based on the request information, you must collect the
+ // requested measurement(s)
+ // you can use the name of the measurement to determine what you
+ // actually need to collect
+ try {
+ Number value = new Integer(1); // dummy measurement value -
+ // this should come from the
+ // managed resource
+ report.addData(new MeasurementDataNumeric(request, value
+ .doubleValue()));
+ } catch (Exception e) {
+ LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+ + "]. Cause: " + e); //$NON-NLS-1$
+ }
+ }
+
+ return;
+ }
+
+ protected void setOperationArguments(String name, Configuration configuration,
+ Map argumentMap) {
+
+ if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
+ String key = ConnectionConstants.IDENTIFIER;
+ //argumentMap.put(key, getComponentIdentifier());
+ }
+
+ }
+
+ @Override
+ String getComponentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
+
Copied: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java (from rev 1798, trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java)
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,142 @@
+/*
+ * 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.rhq.plugin;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+
+/**
+ * Discovery component for VDs
+ *
+ */
+public class VDBDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext discoveryContext)
+ throws InvalidPluginConfigurationException, Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+ Set<ManagedComponent> vdbs = ProfileServiceUtil
+ .getManagedComponents(new ComponentType(
+ PluginConstants.ComponentType.VDB.TYPE,
+ PluginConstants.ComponentType.VDB.SUBTYPE));
+
+ for (ManagedComponent mcVdb : vdbs) {
+
+ String vdbName = ((SimpleValueSupport) mcVdb.getProperty("name")
+ .getValue()).getValue().toString();
+ String vdbVersion = ((SimpleValueSupport) mcVdb.getProperty("version")
+ .getValue()).getValue().toString();
+ //TODO: Correct this after deploying proper VDB/Metadata
+ String vdbDescription = "description"; // mcVdb.getProperty("description");
+ String vdbStatus = "active"; // mcVdb.getProperty("status");
+ String vdbURL = "url"; // mcVdb.getProperty("url");
+
+ /**
+ *
+ * A discovered resource must have a unique key, that must stay the
+ * same when the resource is discovered the next time
+ */
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ vdbName, // Resource Key
+ vdbName, // Resource Name
+ vdbVersion, // Version
+ PluginConstants.ComponentType.VDB.DESCRIPTION, // Description
+ discoveryContext.getDefaultPluginConfiguration(), // Plugin Config
+ null // Process info from a process scan
+ );
+
+ //Get plugin config map for models
+ Configuration configuration = detail.getPluginConfiguration();
+
+ configuration.put(new PropertySimple("name", vdbName));
+ configuration.put(new PropertySimple("version", vdbVersion));
+ configuration.put(new PropertySimple("description", vdbDescription));
+ configuration.put(new PropertySimple("status", vdbStatus));
+ configuration.put(new PropertySimple("url", vdbURL));
+
+ getModels(mcVdb, configuration);
+
+ detail.setPluginConfiguration(configuration);
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered Teiid VDB: " + vdbName);
+ }
+
+ return discoveredResources;
+ }
+
+ /**
+ * @param mcVdb
+ * @param configuration
+ */
+ private void getModels(ManagedComponent mcVdb, Configuration configuration) {
+ //Get models from VDB
+ ManagedProperty property = mcVdb.getProperty("models");
+ CollectionValueSupport valueSupport = (CollectionValueSupport) property.getValue();
+ MetaValue[] metaValues = valueSupport.getElements();
+
+ PropertyList modelsList = new PropertyList("models");
+ configuration.put(modelsList);
+
+ for (MetaValue value : metaValues) {
+ GenericValueSupport genValueSupport = (GenericValueSupport) value;
+ ManagedObjectImpl managedObject = (ManagedObjectImpl)genValueSupport.getValue();
+ String modelName = managedObject.getName();
+ String type = ((SimpleValueSupport) managedObject.getProperty("modelType").getValue()).getValue().toString();
+ String visibility = ((SimpleValueSupport) managedObject.getProperty("visible").getValue()).getValue().toString();
+ String path = ((SimpleValueSupport) managedObject.getProperty("path").getValue()).getValue().toString();
+
+ PropertyMap model = new PropertyMap("model", new PropertySimple("name", modelName),
+ new PropertySimple("type", type), new PropertySimple("path", path),
+ new PropertySimple("visibility", visibility));
+ modelsList.add(model);
+ }
+ }
+
+
+}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -21,215 +21,189 @@
*/
package org.teiid.rhq.plugin.util;
-
-/**
- * These are the Constants that used in conjunction with using the
+/**
+ * These are the Constants that used in conjunction with using the
+ *
* @since 5.5.3
*/
public interface PluginConstants {
-
+
/**
- * These are properties required for connecting to the profile service and getting a handle
- * to a specific component related to Teiid.
- */
-
- // The system key is the value used to obtain a connection.
+ * These are properties required for connecting to the profile service and
+ * getting a handle to a specific component related to Teiid.
+ */
+
+ // The system key is the value used to obtain a connection.
// In embedded, its a predefined value
// In enterprise, its the installation directory
- public final static String PROFILE_SERVICE = "ProfileService"; //$NON-NLS-1$
- public final static String CONNECTION_FACTORY_TYPE = "ConnectionFactory"; //$NON-NLS-1$
- public final static String NO_TX_SUBTYPE = "NoTx"; //$NON-NLS-1$
- public final static String TEIID_RUNTIME_ENGINE = "teiid-runtime-engine"; //$NON-NLS-1$
- public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Service Runtime Engine"; //$NON-NLS-1$
- public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "JBoss Enterprise Data Service Runtime Engine"; //$NON-NLS-1$
-// public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
+ // public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
- /**
- * These are global properties used by all components
- */
- /*
- * This is the key for the fully qualified identifier.
- * For Runtime components it should be the deployedcomponent full name
- * For Resource components it should be the Service Defn full name
- * for adding to the value maps for metrics and operations.
- */
- public final static String IDENTIFIER = "identifier"; //$NON-NLS-1$
-
+ /**
+ * These are global properties used by all components
+ */
+ public final static String PROFILE_SERVICE = "ProfileService"; //$NON-NLS-1$
+
+ /**
+ * These properties are exposed via the #getProperty method call.
+ */
+ public static String SYSTEM_NAME = "cluster.name"; //$NON-NLS-1$
+ public static String SYSTEM_NAME_IDENTIFIER = "JGroups"; //$NON-NLS-1$
- /**
- * These properties are exposed via the #getProperty method call.
- */
- public static String SYSTEM_NAME = "cluster.name"; //$NON-NLS-1$
- public static String SYSTEM_NAME_IDENTIFIER = "JGroups"; //$NON-NLS-1$
-
- /**
- * Use these component type names when calling Connection related methods
- * that require the type.
- * @since 1.0
- */
- public interface ComponentType {
- public final static String PLATFORM = "Platform"; //$NON-NLS-1$
-
- public interface Runtime {
-
- public interface System {
- public final static String TYPE = "Runtime.System"; //$NON-NLS-1$
+ /**
+ * Use these component type names when calling Connection related methods
+ * that require the type.
+ *
+ * @since 1.0
+ */
+ public interface ComponentType {
+
+ public interface Runtime {
- public static interface Operations {
+ public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
+ public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
+ public final static String TEIID_RUNTIME_ENGINE = "teiid/runtime-engine"; //$NON-NLS-1$
+ public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Service Runtime Engine"; //$NON-NLS-1$
+ public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "JBoss Enterprise Data Service Runtime Engine"; //$NON-NLS-1$
- public final static String BOUNCE_SYSTEM = "bounceSystem"; //$NON-NLS-1$
- public final static String GET_LONGRUNNINGQUERIES = "listLongRunningQueries"; //$NON-NLS-1$
-
- }
-
- public static interface Metrics {
- public final static String QUERY_COUNT = "queryCount"; //$NON-NLS-1$
- public final static String SESSION_COUNT = "sessionCount"; //$NON-NLS-1$
- public final static String LONG_RUNNING_QUERIES = "longRunningQueries"; //$NON-NLS-1$
-
- }
- }
-
- public interface Host {
- public final static String TYPE = "Runtime.Host"; //$NON-NLS-1$
+ public static interface Operations {
- public static interface Operations {
- public final static String GET_HOSTS = "getHosts"; //$NON-NLS-1$
-
- }
- }
-
- public interface Process {
+ public final static String BOUNCE_SYSTEM = "bounceSystem"; //$NON-NLS-1$
+ public final static String GET_LONGRUNNINGQUERIES = "listLongRunningQueries"; //$NON-NLS-1$
- public final static String TYPE = "Runtime.Process"; //$NON-NLS-1$
- public static interface Operations {
-
- }
-
- }
-
-
- public interface Connector {
+ }
- public final static String TYPE = "Runtime.Connector"; //$NON-NLS-1$
- public static interface Operations {
+ public static interface Metrics {
- public final static String RESTART_CONNECTOR = "restart"; //$NON-NLS-1$
- public final static String STOP_CONNECTOR = "stop"; //$NON-NLS-1$
-
- }
-
- }
-
-// public interface Service {
-//
-// public final static String TYPE = "Runtime.Service"; //$NON-NLS-1$
-// public static interface Operations {
-//
-// public final static String RESTART_SERVICE = "restart"; //$NON-NLS-1$
-// public final static String STOP_SERVICE = "stop"; //$NON-NLS-1$
-//
-// }
-//
-// }
-
- public interface Session {
+ public final static String QUERY_COUNT = "queryCount"; //$NON-NLS-1$
+ public final static String SESSION_COUNT = "sessionCount"; //$NON-NLS-1$
+ public final static String LONG_RUNNING_QUERIES = "longRunningQueries"; //$NON-NLS-1$
- public final static String TYPE = "Runtime.Sesssion"; //$NON-NLS-1$
- public static interface Query {
+ }
+ }
- public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
- }
-
+ public interface VDB {
-
- }
-
- public interface Queries {
+ public final static String TYPE = "teiid"; //$NON-NLS-1$
+ public final static String SUBTYPE = "vdb"; //$NON-NLS-1$
+ public final static String NAME = "Enterprise Virtual Database"; //$NON-NLS-1$
+ public final static String DESCRIPTION = "JBoss Enterprise Virtual Database (VDB)"; //$NON-NLS-1$
- public final static String TYPE = "Runtime.Queries"; //$NON-NLS-1$
- public static interface Query {
+ }
+
+ public interface Model {
- public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
- }
-
+ public final static String TYPE = "teiid"; //$NON-NLS-1$
+ public final static String SUBTYPE = "model"; //$NON-NLS-1$
+ public final static String NAME = "Model"; //$NON-NLS-1$
+ public final static String DESCRIPTION = "Model used to map to a source"; //$NON-NLS-1$
-
- }
-
- }
- public interface Resource {
- public interface Service {
+ }
- public final static String TYPE = "Resource.Service"; //$NON-NLS-1$
- public static interface Operations {
-
- }
-
- public static interface Query {
-
- }
-
- }
- public interface Connector {
- public final static String TYPE = "Resource.Connector"; //$NON-NLS-1$
- public static interface Operations {
-
- }
-
- }
- }
-
- public interface Security {
-
- }
- /**
- * Use these metric names when calling getValues() on the connection
- * interface.
- * @since 1.0
- */
- public interface Metric {
- public final static String HIGH_WATER_MARK = "highWatermark"; //$NON-NLS-1$
-
- }
-
- /**
- * Use these operation names when calling executeOperation() on the connection
- * interface.
- * @since 1.0
- */
- public static interface Operation {
- public final static String KILL_REQUEST = "killRequest"; //$NON-NLS-1$
- public final static String GET_VDBS = "listVDBs"; //$NON-NLS-1$
-
- public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
-
- /**
- * Use these value names when calling executeOperation() on the connection
- * interface. These will correlate with parameters used in operations.
- * @since 1.0
- */
- public static interface Value {
- public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
- public final static String WAIT_UNTIL_FINISHED = "waitUntilFinished"; //$NON-NLS-1$
-
- public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries"; //$NON-NLS-1$
-
- public final static String LONG_RUNNING_QUERY_LIMIT = "longRunningQueryLimit"; //$NON-NLS-1$
-
- public final static String FIELD_LIST = "fieldList"; //$NON-NLS-1$
-
- public final static String REQUEST_ID = "requestID"; //$NON-NLS-1$
-
- public final static String NAME = "Name"; //$NON-NLS-1$
- public final static String VALUE = "Value"; //$NON-NLS-1$
-
- }
-
- }
-
- }
-
- }
+ public interface Connector {
+
+ public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
+ public final static String SUBTYPE_NOTX = "NoTx"; //$NON-NLS-1$
+ public final static String SUBTYPE_TX = "Tx"; //$NON-NLS-1$
+ public final static String NAME = "Enterprise Connector"; //$NON-NLS-1$
+ public final static String DESCRIPTION = "JBoss Enterprise Connector Binding"; //$NON-NLS-1$
+
+ public static interface Operations {
+
+ public final static String RESTART_CONNECTOR = "restart"; //$NON-NLS-1$
+ public final static String STOP_CONNECTOR = "stop"; //$NON-NLS-1$
+
+ }
+
+ }
+
+ public interface Session {
+
+ public final static String TYPE = "Runtime.Sesssion"; //$NON-NLS-1$
+
+ public static interface Query {
+
+ public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
+ }
+ }
+
+ public interface Queries {
+
+ public final static String TYPE = "Runtime.Queries"; //$NON-NLS-1$
+
+ public static interface Query {
+
+ public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+ }
+ }
+
+ public interface Service {
+
+ public final static String TYPE = "Resource.Service"; //$NON-NLS-1$
+
+ public static interface Operations {
+
+ }
+
+ public static interface Query {
+
+ }
+
+ }
+
+ }
+
+ public interface Security {
+
+ }
+
+ /**
+ * Use these metric names when calling getValues() on the connection
+ * interface.
+ *
+ * @since 1.0
+ */
+ public interface Metric {
+ public final static String HIGH_WATER_MARK = "highWatermark"; //$NON-NLS-1$
+
+ }
+
+ /**
+ * Use these operation names when calling executeOperation() on the
+ * connection interface.
+ *
+ * @since 1.0
+ */
+ public static interface Operation {
+ public final static String KILL_REQUEST = "killRequest"; //$NON-NLS-1$
+ public final static String GET_VDBS = "listVDBs"; //$NON-NLS-1$
+
+ public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
+
+ /**
+ * Use these value names when calling executeOperation() on the
+ * connection interface. These will correlate with parameters used in
+ * operations.
+ *
+ * @since 1.0
+ */
+ public static interface Value {
+ public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$
+ public final static String WAIT_UNTIL_FINISHED = "waitUntilFinished"; //$NON-NLS-1$
+
+ public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries"; //$NON-NLS-1$
+
+ public final static String LONG_RUNNING_QUERY_LIMIT = "longRunningQueryLimit"; //$NON-NLS-1$
+
+ public final static String FIELD_LIST = "fieldList"; //$NON-NLS-1$
+
+ public final static String REQUEST_ID = "requestID"; //$NON-NLS-1$
+
+ public final static String NAME = "Name"; //$NON-NLS-1$
+ public final static String VALUE = "Value"; //$NON-NLS-1$
+
+ }
+
+ }
+}
Copied: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java (from rev 1798, trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java)
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,71 @@
+package org.teiid.rhq.plugin.util;
+
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.profileservice.spi.ProfileService;
+
+public class ProfileServiceUtil {
+
+ /**
+ * Get the passed in {@link ManagedComponent}
+ *
+ * @return {@link ManagedComponent}
+ * @throws NamingException
+ * @throws Exception
+ */
+ public static ManagedComponent getManagedComponent(
+ ComponentType componentType, String componentName)
+ throws NamingException, Exception {
+ ProfileService ps = getProfileService();
+ ManagementView mv = getManagementView(ps);
+
+ ManagedComponent mc = mv.getComponent(componentName, componentType);
+ return mc;
+ }
+
+ /**
+ * Get the {@link ManagedComponent} for the {@link ComponentType} and sub
+ * type.
+ *
+ * @return Set of {@link ManagedComponent}s
+ * @throws NamingException
+ * @throws Exception
+ */
+ public static Set<ManagedComponent> getManagedComponents(
+ ComponentType componentType) throws NamingException, Exception {
+ ProfileService ps = getProfileService();
+ ManagementView mv = getManagementView(ps);
+
+ Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
+
+ return mcSet;
+ }
+
+ /**
+ * @param {@link ManagementView}
+ * @return
+ */
+ private static ManagementView getManagementView(ProfileService ps) {
+ ManagementView mv = ps.getViewManager();
+ mv.load();
+ return mv;
+ }
+
+ /**
+ * @return {@link ProfileService}
+ * @throws NamingException
+ */
+ private static ProfileService getProfileService() throws NamingException {
+ InitialContext ic = new InitialContext();
+ ProfileService ps = (ProfileService) ic
+ .lookup(PluginConstants.PROFILE_SERVICE);
+ return ps;
+ }
+
+}
Modified: branches/JCA/console/src/resources/embedded/META-INF/rhq-plugin.xml
===================================================================
--- branches/JCA/console/src/resources/embedded/META-INF/rhq-plugin.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/console/src/resources/embedded/META-INF/rhq-plugin.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,38 +1,117 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- * 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.
- */-->
+ <!--
+ * 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. */
+ -->
<plugin name="TeiidPlugin" displayName="Teiid Plugin" package="org.teiid.rhq.plugin"
version="2.0.0" description="Supports management and monitoring of JBoss Teiid"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
- <depends plugin="JMX" useClasses="true"/>
+ <depends plugin="JMX" />
+ <depends plugin="JBossAS5" useClasses="true" />
- <server name="Teiid Data Services" description="Teiid Datasources" class="PlatformComponent"
- discovery="PlatformDiscoveryComponent" createDeletePolicy="both">
+ <server name="Data Services" description="JBoss Enterprise Data Services"
+ class="PlatformComponent" discovery="PlatformDiscoveryComponent"
+ createDeletePolicy="both">
+
+
+ <runs-inside>
+ <parent-resource-type name="JBossAS Server"
+ plugin="JBossAS5" />
+ </runs-inside>
+
+ <service name="Virtual Database VDB(s)"
+ description="JBoss Enterprise Data Services Virtual Databases" class="VDBComponent"
+ discovery="VDBDiscoveryComponent" createDeletePolicy="both">
+
+ <resource-configuration>
+ <c:group name="general" displayName="General"
+ hiddenByDefault="false">
+ <c:simple-property name="name" type="string"
+ description="The Virtual Database Name" />
+ <c:simple-property name="version" type="string"
+ description="The Virtual Database Version" />
+ <c:simple-property name="description" type="string"
+ description="The Virtual Database Description" />
+ <c:simple-property name="status" type="string"
+ description="The Virtual Database Status" />
+ <c:simple-property name="url" type="string"
+ description="The Virtual Database URL" />
+ </c:group>
+ <c:group name="models" displayName="Models" hiddenByDefault="false">
+ <c:list-property name="models" description="The models for this VDB.">
+ <c:map-property name="model">
+ <c:simple-property name="name" displayName="Name"
+ description="Name of the model" required="true" />
+ <c:simple-property name="type" displayName="Type"
+ description="Type of model" required="true" />
+ <c:simple-property name="path" displayName="Path"
+ description="Path to the model" required="false" />
+ <c:simple-property name="visibility"
+ displayName="Visible" description="Visbility of the model"
+ required="false" />
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+
+ <service name="Models" description="Models that map to a datasource"
+ class="ModelComponent" discovery="ModelDiscoveryComponent"
+ createDeletePolicy="both">
+ <resource-configuration>
+ <c:group name="general" displayName="General"
+ hiddenByDefault="false">
+ <c:simple-property name="name" type="string"
+ description="The model name" readOnly="true" />
+ <c:simple-property name="type" type="string"
+ description="The model type. e.g. Source or Virtual" readOnly="true" />
+ <c:simple-property name="path" type="string"
+ description="The model path" readOnly="true" />
+ <c:simple-property name="modelURI" type="string"
+ description="The model URI" readOnly="true" />
+ <c:simple-property name="source" type="string"
+ description="True if this is a physical source model" readOnly="true" />
+ <c:simple-property name="visible" type="string"
+ description="True if the model is visible" readOnly="true" />
+ <c:simple-property name="modelType" type="string"
+ description="Type for this model" readOnly="true" />
+ <c:simple-property name="supportsMultiSourceBindings"
+ type="string" description="True if this models supports multiple source bindings"
+ readOnly="true" />
+ </c:group>
+ <c:group name="connectors" displayName="Connectors"
+ hiddenByDefault="false">
+ <c:list-property name="connectors"
+ description="The connector(s) for this Model">
+ <c:map-property name="connector">
+ <c:simple-property name="name" displayName="Name"
+ description="Connector for this model" required="true" />
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+
+ </service>
+
+ </service>
+
</server>
</plugin>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide (from rev 1798, trunk/documentation/caching-guide)
Deleted: branches/JCA/documentation/caching-guide/pom.xml
===================================================================
--- trunk/documentation/caching-guide/pom.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,70 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.jboss.teiid.documentation</groupId>
- <artifactId>documentation</artifactId>
- <version>7.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>caching-guide</artifactId>
- <packaging>jdocbook</packaging>
- <name>Teiid Caching Guide</name>
- <description>The Teiid Caching Guide</description>
- <build>
- <plugins>
- <plugin>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.1.2</version>
- <extensions>true</extensions>
- <dependencies>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossorg-docbook-xslt</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossorg-jdocbook-style</artifactId>
- <version>1.1.0</version>
- <type>jdocbook-style</type>
- </dependency>
- </dependencies>
- <configuration>
- <sourceDocumentName>DataCaching.xml</sourceDocumentName>
- <imageResource>
- <directory>${basedir}/src/main/docbook/en-US</directory>
- <excludes>
- <exclude>*.xml</exclude>
- <exclude>**/*.xml</exclude>
- <exclude>*.zargo</exclude>
- <exclude>**/*.zargo</exclude>
- </excludes>
- </imageResource>
- <formats>
- <format>
- <formatName>pdf</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
- <finalName>caching_guide.pdf</finalName>
- </format>
- <!-- <format>
- <formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format> -->
- <format>
- <formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
- <finalName>index.html</finalName>
- </format>
- </formats>
- <options>
- <xincludeSupported>true</xincludeSupported>
- <localeSeparator>-</localeSeparator>
- <useRelativeImageUris>false</useRelativeImageUris>
- </options>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/pom.xml (from rev 1798, trunk/documentation/caching-guide/pom.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/pom.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,70 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.jboss.teiid.documentation</groupId>
+ <artifactId>documentation</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>caching-guide</artifactId>
+ <packaging>jdocbook</packaging>
+ <name>Teiid Caching Guide</name>
+ <description>The Teiid Caching Guide</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.2</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>DataCaching.xml</sourceDocumentName>
+ <imageResource>
+ <directory>${basedir}/src/main/docbook/en-US</directory>
+ <excludes>
+ <exclude>*.xml</exclude>
+ <exclude>**/*.xml</exclude>
+ <exclude>*.zargo</exclude>
+ <exclude>**/*.zargo</exclude>
+ </excludes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>caching_guide.pdf</finalName>
+ </format>
+ <!-- <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format> -->
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <localeSeparator>-</localeSeparator>
+ <useRelativeImageUris>false</useRelativeImageUris>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src (from rev 1798, trunk/documentation/caching-guide/src)
Copied: branches/JCA/documentation/caching-guide/src/main (from rev 1798, trunk/documentation/caching-guide/src/main)
Copied: branches/JCA/documentation/caching-guide/src/main/docbook (from rev 1798, trunk/documentation/caching-guide/src/main/docbook)
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US)
Deleted: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,53 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!--
-
- JBoss, Home of Professional Open Source.
- Copyright (C) 2008 Red Hat, Inc.
- Licensed to Red Hat, Inc. under one or more contributor
- license agreements. See the copyright.txt file in the
- distribution for a full listing of individual contributors.
-
- 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.
-
--->
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-
-<book>
- <bookinfo>
- <title>Teiid - Scalable Information Integration</title>
- <subtitle>Teiid Caching Guide</subtitle>
- <releaseinfo>&versionNumber;
- </releaseinfo>
- <productnumber>&versionNumber;
- </productnumber>
- <issuenum>1</issuenum>
- <copyright>
- <year>©rightYear;
- </year>
- <holder>©rightHolder;
- </holder>
- </copyright>
- <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </bookinfo>
- <toc />
- <xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-</book>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/DataCaching.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,53 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+
+ JBoss, Home of Professional Open Source.
+ Copyright (C) 2008 Red Hat, Inc.
+ Licensed to Red Hat, Inc. under one or more contributor
+ license agreements. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ 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.
+
+-->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+
+<book>
+ <bookinfo>
+ <title>Teiid - Scalable Information Integration</title>
+ <subtitle>Teiid Caching Guide</subtitle>
+ <releaseinfo>&versionNumber;
+ </releaseinfo>
+ <productnumber>&versionNumber;
+ </productnumber>
+ <issuenum>1</issuenum>
+ <copyright>
+ <year>©rightYear;
+ </year>
+ <holder>©rightHolder;
+ </holder>
+ </copyright>
+ <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </bookinfo>
+ <toc />
+ <xi:include href="content/overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/matviews.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/resultset.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/codetable.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+</book>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/content)
Deleted: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,156 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="codetable">
- <title>Code Table Caching</title>
- <para>MetaMatrix provides a means of caching small, frequently used
- tables of data. This is referred to as “code table caching” or
- “reference data caching”.</para>
- <para>Code table caching is done by using the lookup scalar function,
- provided as a standard function with MetaMatrix. The lookup function
- provides a way to get a value out of a table when a key value is
- provided. The function automatically caches all the values in the
- referenced table for the specified key/value pairs. The cache is
- created the first time it is used in a particular MetaMatrix process.
- Subsequent lookups against the same table using the same key and
- value columns will use the cached information.</para>
- <para>This caching solution is appropriate for integration of
- “reference data” with transactional or operational data. Reference
- data are static data sets – typically small – which are used very
- frequently in most enterprise applications. Examples are ISO country
- codes, state codes, and different types of financial instrument
- identifiers. </para>
- <sect1>
- <title>Support Summary</title>
- <orderedlist>
- <listitem>
- <para>Caching of small, frequently accessed tables</para>
- </listitem>
- <listitem>
- <para>Administrative clearing of cached tables through command line
- utility</para>
- </listitem>
- </orderedlist>
- </sect1>
- <sect1>
- <title>User Interaction</title>
- <para>This caching mechanism is automatically invoked when the lookup
- scalar function is used. Each time this function is called with a
- unique combination of referenced table, key element, and returned
- element (the first 3 arguments to the function), the MetaMatrix
- System caches the entire contents of the table being accessed.
- Subsequent lookup function uses with the same combination of
- parameters uses the cached table data.</para>
- <para>Note that the use of the lookup function automatically performs
- caching; there is no option to use the lookup function and not
- perform caching. Once the values for a particular lookup are cached,
- they will be used until the cache is cleared through the Console.
- </para>
- <para>Specification:</para>
- <para>The following provides information on the use of the lookup
- function.</para>
- <informaltable frame="all">
- <tgroup cols="3">
- <thead>
- <row>
- <entry>
- <para>Function</para>
- </entry>
- <entry>
- <para>Definition</para>
- </entry>
- <entry>
- <para>Datatype Constraint</para>
- </entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <para>LOOKUP(codeGroup, returnElement, keyElement, keyValue)
- </para>
- </entry>
- <entry>
- <para>In the lookup group codeGroup, find the row where
- keyElement has the value keyValue and return the associated
- returnElement.</para>
- </entry>
- <entry>
- <para>codeGroup, returnElement, and keyElement must be string
- literals containing metadata identifiers, keyValue datatype must
- match datatype of the keyElement, return datatype matches that
- of returnElement</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>See the MetaMatrix Query Support Booklet for more information on
- use of the lookup function.</para>
- <para>Examples (can be used wherever scalar literal can be in query):
- </para>
- <para>lookup(‘ISOCountryCodes, ‘CountryName’, ‘CountryCode’, ‘US’)
- </para>
- <para>lookup(‘StatePostalCodes, ‘StateDisplayName’, ‘PostalCode’,
- ‘63131’) </para>
- <para>lookup(‘EmpIDs’, ‘Name’, ‘ID’, ‘m204815’) </para>
- </sect1>
- <sect1>
- <title>Cache Configuration</title>
- <para>Cached lookup groups might consume significant memory. You can
- limit the number and maximum size of these code groups by setting
- properties of the Query Service through the MetaMatrix Console.
- </para>
- <para>The following are the properties that can be set at the query
- service level to control reference data caching.</para>
- <para />
- </sect1>
- <sect1>
- <title>Cache Characteristics</title>
- <para>Cache Persistence Mechanism</para>
- <para>Reference tables are persisted in object caches local to
- individual Java processes (virtual machines or VMs). They are
- cached in the VM of the individual query services running on host
- machines. </para>
- <para>Cache Loading Policy</para>
- <para>When a user calls the lookup function for a unique combination
- of table, key element, and returned element, the MetaMatrix System
- caches all key-value pairs of that table for the specified elements.
- </para>
- <para>The MetaMatrix System uses this cached map for all queries, in
- all sessions, that later access this lookup group.</para>
- <para>Cache Operational Policy</para>
- <para>Cached tables are never proactively cleared. They can only be
- cleared through using the svcmgr utility script.</para>
- </sect1>
- <sect1>
- <title>Cache Administration</title>
- <para>The lookup cache can be cleared using the svcmgr utility script.
- To clear cached code tables, set expertmode on, and then pass in the
- clearCodeTableCaches argument.</para>
- </sect1>
- <sect1>
- <title>Limitations</title>
- <orderedlist>
- <listitem>
- <para>Cached code tables are not tied to specific virtual databases.
- This may result in an error when the same model is used in
- multiple virtual databases while it has bindings to different
- sources of data. This may pose a security issue if a cached code
- table is loaded in the context of one user but then accessed by
- another user who should not have access to that data. [defect
- 11629]</para>
- </listitem>
- <listitem>
- <para>The use of the lookup function automatically performs caching;
- there is no option to use the lookup function and not perform
- caching. [defect 14445]</para>
- </listitem>
- </orderedlist>
- <para>Cached code tables are never proactively cleared by the Server.
- If a lot of code tables are loaded, or large code tables are loaded,
- the Server’s available memory could be exceeded.</para>
- </sect1>
-</chapter>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/codetable.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,156 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="codetable">
+ <title>Code Table Caching</title>
+ <para>MetaMatrix provides a means of caching small, frequently used
+ tables of data. This is referred to as “code table caching” or
+ “reference data caching”.</para>
+ <para>Code table caching is done by using the lookup scalar function,
+ provided as a standard function with MetaMatrix. The lookup function
+ provides a way to get a value out of a table when a key value is
+ provided. The function automatically caches all the values in the
+ referenced table for the specified key/value pairs. The cache is
+ created the first time it is used in a particular MetaMatrix process.
+ Subsequent lookups against the same table using the same key and
+ value columns will use the cached information.</para>
+ <para>This caching solution is appropriate for integration of
+ “reference data” with transactional or operational data. Reference
+ data are static data sets – typically small – which are used very
+ frequently in most enterprise applications. Examples are ISO country
+ codes, state codes, and different types of financial instrument
+ identifiers. </para>
+ <sect1>
+ <title>Support Summary</title>
+ <orderedlist>
+ <listitem>
+ <para>Caching of small, frequently accessed tables</para>
+ </listitem>
+ <listitem>
+ <para>Administrative clearing of cached tables through command line
+ utility</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>User Interaction</title>
+ <para>This caching mechanism is automatically invoked when the lookup
+ scalar function is used. Each time this function is called with a
+ unique combination of referenced table, key element, and returned
+ element (the first 3 arguments to the function), the MetaMatrix
+ System caches the entire contents of the table being accessed.
+ Subsequent lookup function uses with the same combination of
+ parameters uses the cached table data.</para>
+ <para>Note that the use of the lookup function automatically performs
+ caching; there is no option to use the lookup function and not
+ perform caching. Once the values for a particular lookup are cached,
+ they will be used until the cache is cleared through the Console.
+ </para>
+ <para>Specification:</para>
+ <para>The following provides information on the use of the lookup
+ function.</para>
+ <informaltable frame="all">
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>
+ <para>Function</para>
+ </entry>
+ <entry>
+ <para>Definition</para>
+ </entry>
+ <entry>
+ <para>Datatype Constraint</para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>LOOKUP(codeGroup, returnElement, keyElement, keyValue)
+ </para>
+ </entry>
+ <entry>
+ <para>In the lookup group codeGroup, find the row where
+ keyElement has the value keyValue and return the associated
+ returnElement.</para>
+ </entry>
+ <entry>
+ <para>codeGroup, returnElement, and keyElement must be string
+ literals containing metadata identifiers, keyValue datatype must
+ match datatype of the keyElement, return datatype matches that
+ of returnElement</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para />
+ <para>See the MetaMatrix Query Support Booklet for more information on
+ use of the lookup function.</para>
+ <para>Examples (can be used wherever scalar literal can be in query):
+ </para>
+ <para>lookup(‘ISOCountryCodes, ‘CountryName’, ‘CountryCode’, ‘US’)
+ </para>
+ <para>lookup(‘StatePostalCodes, ‘StateDisplayName’, ‘PostalCode’,
+ ‘63131’) </para>
+ <para>lookup(‘EmpIDs’, ‘Name’, ‘ID’, ‘m204815’) </para>
+ </sect1>
+ <sect1>
+ <title>Cache Configuration</title>
+ <para>Cached lookup groups might consume significant memory. You can
+ limit the number and maximum size of these code groups by setting
+ properties of the Query Service through the MetaMatrix Console.
+ </para>
+ <para>The following are the properties that can be set at the query
+ service level to control reference data caching.</para>
+ <para />
+ </sect1>
+ <sect1>
+ <title>Cache Characteristics</title>
+ <para>Cache Persistence Mechanism</para>
+ <para>Reference tables are persisted in object caches local to
+ individual Java processes (virtual machines or VMs). They are
+ cached in the VM of the individual query services running on host
+ machines. </para>
+ <para>Cache Loading Policy</para>
+ <para>When a user calls the lookup function for a unique combination
+ of table, key element, and returned element, the MetaMatrix System
+ caches all key-value pairs of that table for the specified elements.
+ </para>
+ <para>The MetaMatrix System uses this cached map for all queries, in
+ all sessions, that later access this lookup group.</para>
+ <para>Cache Operational Policy</para>
+ <para>Cached tables are never proactively cleared. They can only be
+ cleared through using the svcmgr utility script.</para>
+ </sect1>
+ <sect1>
+ <title>Cache Administration</title>
+ <para>The lookup cache can be cleared using the svcmgr utility script.
+ To clear cached code tables, set expertmode on, and then pass in the
+ clearCodeTableCaches argument.</para>
+ </sect1>
+ <sect1>
+ <title>Limitations</title>
+ <orderedlist>
+ <listitem>
+ <para>Cached code tables are not tied to specific virtual databases.
+ This may result in an error when the same model is used in
+ multiple virtual databases while it has bindings to different
+ sources of data. This may pose a security issue if a cached code
+ table is loaded in the context of one user but then accessed by
+ another user who should not have access to that data. [defect
+ 11629]</para>
+ </listitem>
+ <listitem>
+ <para>The use of the lookup function automatically performs caching;
+ there is no option to use the lookup function and not perform
+ caching. [defect 14445]</para>
+ </listitem>
+ </orderedlist>
+ <para>Cached code tables are never proactively cleared by the Server.
+ If a lot of code tables are loaded, or large code tables are loaded,
+ the Server’s available memory could be exceeded.</para>
+ </sect1>
+</chapter>
\ No newline at end of file
Deleted: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,529 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="matviews">
- <title>Materialized Views</title>
- <para>MetaMatrix supports Materialized Views. These are Relational
- virtual tables and views (‘virtual groups’) for which the
- transformations are pre-computed and the results are stored in an
- external database. When queries are issued against these virtual
- groups through the MetaMatrix Server, the cached results are used.
- This saves the cost of accessing all the underlying data sources and
- re-computing the virtual group transforms each time a query is
- executed against the group. </para>
- <para>This strategy is appropriate when the underlying data does not
- change rapidly, or when it is acceptable to retrieve data that is
- “stale” within some period of time, or when it is preferred for
- end-user queries to access staged data rather than placing additional
- query load on operational sources. MetaMatrix provides a utility to
- refresh materialized tables. This utility uses the MetaMatrix batched
- update functionality.</para>
- <sect1>
- <title>Support Summary</title>
- <orderedlist>
- <listitem>
- <para>Caching of relational table or view records (pre-computing all
- transformations)</para>
- </listitem>
- <listitem>
- <para>Model-based definition of virtual groups to cache</para>
- </listitem>
- <listitem>
- <para>User ability to override use of materialized view cache for
- specific queries</para>
- </listitem>
- <listitem>
- <para>Administrative utility to initially load and refresh cached
- data</para>
- </listitem>
- </orderedlist>
- </sect1>
- <sect1>
- <title>User Interaction</title>
- <para>When client applications issue queries against a Relational
- table or view that has been defined as a materialized view, the
- MetaMatrix query engine automatically routes that query to obtain the
- results from the cache database. </para>
- <para>Individual queries may override the use of materialized views by
- specifying OPTION NOCACHE on the query. This parameter must specify
- one or more virtual groups to override (separated by commas, spaces
- optional). If no virtual groups are specified, then it is the same
- as if the override option is not specified. Note that only virtual
- groups specified in the user or transformation query (in the FROM
- clause) can be specified to be overridden. If there are materialized
- virtual groups below that level (referenced in transformations), then
- the materialized view for those tables will be used. </para>
- <para>Examples:</para>
- <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3
- </para>
- <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</para>
- <para>The second query is equivalent to:</para>
- <para>SELECT * from vg1, vg2, vg3 WHERE OPTION NOCACHE vg1, vg2, vg3
- </para>
- <para>The materialization override option may be specified in virtual
- group transformation definitions. In that way, transformations can
- specify to always use real-time data obtained directly from a source.
- The use of caching and non-caching can be mixed in transformation
- definitions, just as with user queries.</para>
- </sect1>
- <sect1>
- <title>Cache Configuration</title>
- <para>Materialized View Definition</para>
- <para>Materialized views are defined in the MetaBase Modeler by
- setting the materialized property on a table or view in a relational
- model. Setting this property's value to true (the default is false)
- allows the data generated for this virtual table to be treated as a
- materialized view. </para>
- <para>The Name In Source property for this table determines the name
- of the physical Materialized Views tables. If left blank the default
- naming scheme of MV10000001 is used, otherwise the name provided is
- used.</para>
- <para />
- <para>Virtual Database Definition</para>
- <para>Materialized views are relational tables (or views) in one or
- more models that have their materialized property set to true. When
- a set of virtual relational models containing materialized views is
- bundled into a virtual database (VDB) in the MetaBase Modeler, a
- physical relational model is automatically created and put into that
- VDB to represent the physical cache. The physical model is given the
- well-known name Materialization. The physical cache model will
- contain one physical table for each virtual group marked as a
- materialized view. </para>
- <para>Note that if no virtual groups are marked as materialized views,
- then the Materialization physical cache model will not be created or
- included in the VDB.</para>
- <para>Virtual Database Deployment </para>
- <para>When deploying a virtual database (VDB) in the MetaMatrix
- Console, the MetaMatrix administrator must define connector bindings
- for all physical models in the VDB. This is true for the well-known
- materialization cache model also. In the New VDB or New VDB Version
- wizard, the materialization model will show up in the Connector
- Binding definition panel. The administrator should select the
- appropriate JDBC connector for the data source where the materialized
- view cache will reside. </para>
- <para>When deploying a VDB containing materialized views, the
- MetaMatrix administrator will be presented with the option to save
- administration scripts to the local file system. This is in the New
- VDB, New VDB Version, and Import VDB wizards. The administrator
- should save the scripts to a location where they can be accessed by a
- database administrator responsible for creating, loading, and
- refreshing the cache database. See Cache Administration section.
- </para>
- <para>This is a summary of what an administrator must do when
- deploying a VDB containing materialized views:</para>
- <orderedlist>
- <listitem>
- <para>Define connector binding from the materialization model to the
- physical cache database.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>This defines the DBMS type, subsequently used to save cache
- creation and loading scripts appropriate for that database type
- </para>
- </listitem>
- <listitem>
- <para>The username and password used in the connector binding must
- have privileges for the cache database </para>
- </listitem>
- <listitem>
- <para>The cache database may not exist at this point, in which case
- the connector binding cannot be started, and the VDB cannot be
- activated.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Define username and password for creating and manipulating
- (swapping and truncating) cache tables in the cache database.
- </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>The username and password must directly connect to a schema or
- catalog in the database that is appropriate for the VDB version.
- This cache may be used by multiple VDB versions, but this is in
- general not recommended.</para>
- </listitem>
- <listitem>
- <para>This username and password will be used for executing the
- Create, Truncate, and Swap scripts.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Define username and password for connecting to MetaMatrix, to
- issue insert commands against the virtual groups during loading and
- reloading.</para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>This user information is not necessarily the same as the user
- information used in the connector binding, although it can be.
- </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>Save DDL scripts to the file system. </para>
- </listitem>
- </orderedlist>
- <orderedlist>
- <listitem>
- <para>The administrator specifies the location to save the files.
- </para>
- </listitem>
- <listitem>
- <para>The location should be accessible to the DBA or the scheduling
- process that will execute the scripts against the database</para>
- </listitem>
- <listitem>
- <para>Four scripts will be saved with names appropriate to the VDB
- and version.</para>
- </listitem>
- </orderedlist>
- <para>Cache Characteristics</para>
- <para>Cache Persistence Mechanism</para>
- <para>Materialized views cache their data in an external database
- system. This database may be the same as the database used as the
- MetaMatrix repository, or it may be a different one. In general it
- is recommended that the MetaMatrix repository not be used for
- materialized view caching, as heavy use could impact the performance
- of other core functionality of the MetaMatrix Server. </para>
- <para>The following DBMS systems are supported for this purpose:
- </para>
- <orderedlist>
- <listitem>
- <para>Oracle 8i or 9i or 10g</para>
- </listitem>
- <listitem>
- <para>SQL Server 2000</para>
- </listitem>
- <listitem>
- <para>DB2 8</para>
- </listitem>
- </orderedlist>
- <para>Cache Operational Policy</para>
- <para>Since the actual physical cache for materialized views is
- maintained external to the MetaMatrix system, there is no pre-defined
- policy for clearing and managing the cache. These policies will be
- defined and enforced by administrators of the MetaMatrix system.
- </para>
- <para>Cache Administration</para>
- <para>The cache used by materialized views is administered external to
- MetaMatrix. This provides a great deal of flexibility on how that
- cache is managed, refreshed, backed up, and otherwise administered
- along with other enterprise sources.</para>
- <para>Administrator Responsibilities</para>
- <para>These are the responsibilities of administrators with respect to
- MetaMatrix’s materialized view data caching.</para>
- <informaltable frame="all">
- <tgroup cols="3">
- <colspec colnum="1" colname="c1" />
- <colspec colnum="2" colname="c2" />
- <colspec colnum="3" colname="c3" />
- <tbody>
- <row>
- <entry>
- <para>Operation</para>
- </entry>
- <entry>
- <para>Run Against</para>
- </entry>
- <entry>
- <para>Required Rights for Cache Database</para>
- </entry>
- <entry>
- <para>Required Rights for MetaMatrix</para>
- </entry>
- <entry>
- <para>Scripts Used</para>
- </entry>
- <entry>
- <para>Frequency</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Create cache database</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>None</para>
- </entry>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>Once per VDB version</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Initially populate cache </para>
- </entry>
- <entry>
- <para>Cache database and MetaMatrix</para>
- </entry>
- <entry>
- <para>Alter, Insert</para>
- </entry>
- <entry>
- <para>CRUD</para>
- </entry>
- <entry>
- <para>Truncate</para>
- <para>Load</para>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Once per VDB version</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Refresh cache </para>
- </entry>
- <entry>
- <para>Cache database and MetaMatrix</para>
- </entry>
- <entry>
- <para>Alter, Insert </para>
- </entry>
- <entry>
- <para>CRUD </para>
- </entry>
- <entry>
- <para>Truncate</para>
- <para>Load</para>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Desired cache refresh rate</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>The refresh cache operation is recurring, basically at whatever
- frequency is appropriate for maintaining the desired data “freshness”
- for the VDB version. This operation can be scheduled to execute the
- MetaMatrix scripts, using standard scheduling mechanisms such as cron
- on UNIX or the Windows scheduler.</para>
- <para>The truncate and swap scripts are used in the initial load. The
- truncate is a no-op in this case, and the swap happens because data
- is always loaded to the staging table, which must then be swapped
- with the real cache table. </para>
- <para>MetaMatrix Administrative Scripts</para>
- <para>To perform the administrative operations, MetaMatrix provides a
- set of 4 scripts. Here is a summary of the scripts. All the scripts
- use a similar template for their file names:
- VDBName_VDBVersion_Name.ddl).</para>
- <informaltable frame="all">
- <tgroup cols="5">
- <tbody>
- <row>
- <entry>
- <para>Script Base Name</para>
- </entry>
- <entry>
- <para>Use</para>
- </entry>
- <entry>
- <para>Description</para>
- </entry>
- <entry>
- <para>Run Against</para>
- </entry>
- <entry>
- <para>User Info</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Create</para>
- </entry>
- <entry>
- <para>Creation</para>
- </entry>
- <entry>
- <para>Create tables for cache</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Truncate</para>
- </entry>
- <entry>
- <para>Reload</para>
- </entry>
- <entry>
- <para>Truncate temporary table when inserting new records</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Load</para>
- </entry>
- <entry>
- <para>Load or reload </para>
- </entry>
- <entry>
- <para>Execute queries against materialized virtual groups, insert
- results into cache</para>
- </entry>
- <entry>
- <para>MetaMatrix</para>
- </entry>
- <entry>
- <para>Access user</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Swap</para>
- </entry>
- <entry>
- <para>Reload</para>
- </entry>
- <entry>
- <para>Swap temporary table with cache table after new records
- inserted</para>
- </entry>
- <entry>
- <para>Cache database</para>
- </entry>
- <entry>
- <para>Script user</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>In addition to these scripts, MetaMatrix provides a connection
- properties file with encrypted passwords.</para>
- <para>Materialized Database Creation</para>
- <para>The cache for materialized views is maintained in a separate
- database system. Therefore, tables must be defined in the database
- to hold the cached information for the materialized views in a VDB.
- Materialized views are scoped to a specific VDB version. Therefore,
- the cache tables should in general be segregated in the cache
- database by VDB and version. It is the responsibility of the
- MetaMatrix and database administrators to ensure that the database is
- defined appropriately for the VDB version, and to ensure that two
- users are created with the appropriate privileges:</para>
- <orderedlist>
- <listitem>
- <para>Script user – Used when executing Create/Truncate/Swap scripts
- [note used for Load scripts, since that executes directly against
- MetaMatrix with MetaMatrix user info]. Requires create/load/alter
- privileges against the materialized view tables in the database.
- </para>
- </listitem>
- <listitem>
- <para>Access user – Used in connector binding definition both when
- reading the cache for user queries, and when refreshing the cache
- using the Load script. Requires read and insert privileges against
- the materialized view tables in the database. </para>
- </listitem>
- </orderedlist>
- <para>MetaMatrix provides a DDL script to create all the materialized
- tables for a VDB. This script is DBMS-specific. When deploying a
- VDB, the type of the DBMS is determined from the connector binding
- used for the materialization physical model, and the appropriate
- script for that DBMS is extracted from the VDB and saved to the local
- file system. </para>
- <para>Script name: <VDBName>_<VDBVersion>_Create.ddl
- </para>
- <para>Example for “CustomerInfo” VDB, version 7:
- CustomerInfo_7_Create.ddl </para>
- <para>The create script is a standard DDL script that can be executed
- against the DBMS system using whatever mechanisms it supports. The
- script must be executed against a database schema/catalog with the
- appropriate privileges as specified in the MetaMatrix Console. </para>
- <para>Materialized Database Loading</para>
- <para>MetaMatrix provides a set of 3 scripts to initially populate and
- subsequently reload (“refresh”) all the materialized tables for a
- VDB. These scripts are DBMS-specific. They are extracted from the
- VDB when deploying that VDB, and saved by an administrator to the
- local file system. These scripts all assume that the cache tables
- have been created, using the “Create” script described above.</para>
- <para>These three scripts do the following for each materialized view:
- </para>
- <orderedlist>
- <listitem>
- <para>Truncate records in a temporary table (executed directly
- against DBMS)</para>
- </listitem>
- <listitem>
- <para>Load – execute query against virtual group, and insert into
- temporary table (executed against MetaMatrix)</para>
- </listitem>
- <listitem>
- <para>Swap temporary table with cache table (executed directly
- against DBMS)</para>
- </listitem>
- </orderedlist>
- <para>The second script uses the MetaMatrix batched inserts
- functionality. Therefore, the MetaMatrix Server must be running, and
- the VDB must be deployed and activated. The queries that are
- executed all use the “cache override” option, so that the
- transformations are executed. </para>
- <para>The first and third scripts execute DBMS-specific operations, to
- more efficiently update the cache records. These scripts are
- standard DDL scripts that can be executed against the DBMS system
- using whatever mechanisms it supports. The scripts must be executed
- against a database schema/catalog with the appropriate privileges as
- specified in the MetaMatrix Console. </para>
- <para>The three scripts can be executed together to perform initial
- loading and subsequent refresh. This can be done using the
- loadscript.cmd (.sh on UNIX) command script, located in the server
- materializedviews directory. This script can be used to schedule
- database loading activities. </para>
- </sect1>
- <sect1>
- <title>Limitations</title>
- <orderedlist>
- <listitem>
- <para>Materialization works only with Relational tables and views.
- It does not work with Data Access virtual groups or procedures.
- </para>
- </listitem>
- <listitem>
- <para>A user cannot specify OPTION NOCACHE on virtual groups that
- are not at the top level (in the user query). The design does not
- currently support this.</para>
- </listitem>
- </orderedlist>
- </sect1>
- <sect1>
- <title>Outstanding Issues</title>
- <para>Specifying OPTION NOCACHE within a transformation query is the
- same as specifying it a user query – the identified virtual groups
- will always be re-computed in the context of the virtual group
- containing the transformation query with the override option.</para>
- </sect1>
-</chapter>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/matviews.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,529 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="matviews">
+ <title>Materialized Views</title>
+ <para>MetaMatrix supports Materialized Views. These are Relational
+ virtual tables and views (‘virtual groups’) for which the
+ transformations are pre-computed and the results are stored in an
+ external database. When queries are issued against these virtual
+ groups through the MetaMatrix Server, the cached results are used.
+ This saves the cost of accessing all the underlying data sources and
+ re-computing the virtual group transforms each time a query is
+ executed against the group. </para>
+ <para>This strategy is appropriate when the underlying data does not
+ change rapidly, or when it is acceptable to retrieve data that is
+ “stale” within some period of time, or when it is preferred for
+ end-user queries to access staged data rather than placing additional
+ query load on operational sources. MetaMatrix provides a utility to
+ refresh materialized tables. This utility uses the MetaMatrix batched
+ update functionality.</para>
+ <sect1>
+ <title>Support Summary</title>
+ <orderedlist>
+ <listitem>
+ <para>Caching of relational table or view records (pre-computing all
+ transformations)</para>
+ </listitem>
+ <listitem>
+ <para>Model-based definition of virtual groups to cache</para>
+ </listitem>
+ <listitem>
+ <para>User ability to override use of materialized view cache for
+ specific queries</para>
+ </listitem>
+ <listitem>
+ <para>Administrative utility to initially load and refresh cached
+ data</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>User Interaction</title>
+ <para>When client applications issue queries against a Relational
+ table or view that has been defined as a materialized view, the
+ MetaMatrix query engine automatically routes that query to obtain the
+ results from the cache database. </para>
+ <para>Individual queries may override the use of materialized views by
+ specifying OPTION NOCACHE on the query. This parameter must specify
+ one or more virtual groups to override (separated by commas, spaces
+ optional). If no virtual groups are specified, then it is the same
+ as if the override option is not specified. Note that only virtual
+ groups specified in the user or transformation query (in the FROM
+ clause) can be specified to be overridden. If there are materialized
+ virtual groups below that level (referenced in transformations), then
+ the materialized view for those tables will be used. </para>
+ <para>Examples:</para>
+ <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3
+ </para>
+ <para>SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE</para>
+ <para>The second query is equivalent to:</para>
+ <para>SELECT * from vg1, vg2, vg3 WHERE OPTION NOCACHE vg1, vg2, vg3
+ </para>
+ <para>The materialization override option may be specified in virtual
+ group transformation definitions. In that way, transformations can
+ specify to always use real-time data obtained directly from a source.
+ The use of caching and non-caching can be mixed in transformation
+ definitions, just as with user queries.</para>
+ </sect1>
+ <sect1>
+ <title>Cache Configuration</title>
+ <para>Materialized View Definition</para>
+ <para>Materialized views are defined in the MetaBase Modeler by
+ setting the materialized property on a table or view in a relational
+ model. Setting this property's value to true (the default is false)
+ allows the data generated for this virtual table to be treated as a
+ materialized view. </para>
+ <para>The Name In Source property for this table determines the name
+ of the physical Materialized Views tables. If left blank the default
+ naming scheme of MV10000001 is used, otherwise the name provided is
+ used.</para>
+ <para />
+ <para>Virtual Database Definition</para>
+ <para>Materialized views are relational tables (or views) in one or
+ more models that have their materialized property set to true. When
+ a set of virtual relational models containing materialized views is
+ bundled into a virtual database (VDB) in the MetaBase Modeler, a
+ physical relational model is automatically created and put into that
+ VDB to represent the physical cache. The physical model is given the
+ well-known name Materialization. The physical cache model will
+ contain one physical table for each virtual group marked as a
+ materialized view. </para>
+ <para>Note that if no virtual groups are marked as materialized views,
+ then the Materialization physical cache model will not be created or
+ included in the VDB.</para>
+ <para>Virtual Database Deployment </para>
+ <para>When deploying a virtual database (VDB) in the MetaMatrix
+ Console, the MetaMatrix administrator must define connector bindings
+ for all physical models in the VDB. This is true for the well-known
+ materialization cache model also. In the New VDB or New VDB Version
+ wizard, the materialization model will show up in the Connector
+ Binding definition panel. The administrator should select the
+ appropriate JDBC connector for the data source where the materialized
+ view cache will reside. </para>
+ <para>When deploying a VDB containing materialized views, the
+ MetaMatrix administrator will be presented with the option to save
+ administration scripts to the local file system. This is in the New
+ VDB, New VDB Version, and Import VDB wizards. The administrator
+ should save the scripts to a location where they can be accessed by a
+ database administrator responsible for creating, loading, and
+ refreshing the cache database. See Cache Administration section.
+ </para>
+ <para>This is a summary of what an administrator must do when
+ deploying a VDB containing materialized views:</para>
+ <orderedlist>
+ <listitem>
+ <para>Define connector binding from the materialization model to the
+ physical cache database.</para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>This defines the DBMS type, subsequently used to save cache
+ creation and loading scripts appropriate for that database type
+ </para>
+ </listitem>
+ <listitem>
+ <para>The username and password used in the connector binding must
+ have privileges for the cache database </para>
+ </listitem>
+ <listitem>
+ <para>The cache database may not exist at this point, in which case
+ the connector binding cannot be started, and the VDB cannot be
+ activated.</para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>Define username and password for creating and manipulating
+ (swapping and truncating) cache tables in the cache database.
+ </para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>The username and password must directly connect to a schema or
+ catalog in the database that is appropriate for the VDB version.
+ This cache may be used by multiple VDB versions, but this is in
+ general not recommended.</para>
+ </listitem>
+ <listitem>
+ <para>This username and password will be used for executing the
+ Create, Truncate, and Swap scripts.</para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>Define username and password for connecting to MetaMatrix, to
+ issue insert commands against the virtual groups during loading and
+ reloading.</para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>This user information is not necessarily the same as the user
+ information used in the connector binding, although it can be.
+ </para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>Save DDL scripts to the file system. </para>
+ </listitem>
+ </orderedlist>
+ <orderedlist>
+ <listitem>
+ <para>The administrator specifies the location to save the files.
+ </para>
+ </listitem>
+ <listitem>
+ <para>The location should be accessible to the DBA or the scheduling
+ process that will execute the scripts against the database</para>
+ </listitem>
+ <listitem>
+ <para>Four scripts will be saved with names appropriate to the VDB
+ and version.</para>
+ </listitem>
+ </orderedlist>
+ <para>Cache Characteristics</para>
+ <para>Cache Persistence Mechanism</para>
+ <para>Materialized views cache their data in an external database
+ system. This database may be the same as the database used as the
+ MetaMatrix repository, or it may be a different one. In general it
+ is recommended that the MetaMatrix repository not be used for
+ materialized view caching, as heavy use could impact the performance
+ of other core functionality of the MetaMatrix Server. </para>
+ <para>The following DBMS systems are supported for this purpose:
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>Oracle 8i or 9i or 10g</para>
+ </listitem>
+ <listitem>
+ <para>SQL Server 2000</para>
+ </listitem>
+ <listitem>
+ <para>DB2 8</para>
+ </listitem>
+ </orderedlist>
+ <para>Cache Operational Policy</para>
+ <para>Since the actual physical cache for materialized views is
+ maintained external to the MetaMatrix system, there is no pre-defined
+ policy for clearing and managing the cache. These policies will be
+ defined and enforced by administrators of the MetaMatrix system.
+ </para>
+ <para>Cache Administration</para>
+ <para>The cache used by materialized views is administered external to
+ MetaMatrix. This provides a great deal of flexibility on how that
+ cache is managed, refreshed, backed up, and otherwise administered
+ along with other enterprise sources.</para>
+ <para>Administrator Responsibilities</para>
+ <para>These are the responsibilities of administrators with respect to
+ MetaMatrix’s materialized view data caching.</para>
+ <informaltable frame="all">
+ <tgroup cols="3">
+ <colspec colnum="1" colname="c1" />
+ <colspec colnum="2" colname="c2" />
+ <colspec colnum="3" colname="c3" />
+ <tbody>
+ <row>
+ <entry>
+ <para>Operation</para>
+ </entry>
+ <entry>
+ <para>Run Against</para>
+ </entry>
+ <entry>
+ <para>Required Rights for Cache Database</para>
+ </entry>
+ <entry>
+ <para>Required Rights for MetaMatrix</para>
+ </entry>
+ <entry>
+ <para>Scripts Used</para>
+ </entry>
+ <entry>
+ <para>Frequency</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Create cache database</para>
+ </entry>
+ <entry>
+ <para>Cache database</para>
+ </entry>
+ <entry>
+ <para>Create</para>
+ </entry>
+ <entry>
+ <para>None</para>
+ </entry>
+ <entry>
+ <para>Create</para>
+ </entry>
+ <entry>
+ <para>Once per VDB version</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Initially populate cache </para>
+ </entry>
+ <entry>
+ <para>Cache database and MetaMatrix</para>
+ </entry>
+ <entry>
+ <para>Alter, Insert</para>
+ </entry>
+ <entry>
+ <para>CRUD</para>
+ </entry>
+ <entry>
+ <para>Truncate</para>
+ <para>Load</para>
+ <para>Swap</para>
+ </entry>
+ <entry>
+ <para>Once per VDB version</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Refresh cache </para>
+ </entry>
+ <entry>
+ <para>Cache database and MetaMatrix</para>
+ </entry>
+ <entry>
+ <para>Alter, Insert </para>
+ </entry>
+ <entry>
+ <para>CRUD </para>
+ </entry>
+ <entry>
+ <para>Truncate</para>
+ <para>Load</para>
+ <para>Swap</para>
+ </entry>
+ <entry>
+ <para>Desired cache refresh rate</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para />
+ <para>The refresh cache operation is recurring, basically at whatever
+ frequency is appropriate for maintaining the desired data “freshness”
+ for the VDB version. This operation can be scheduled to execute the
+ MetaMatrix scripts, using standard scheduling mechanisms such as cron
+ on UNIX or the Windows scheduler.</para>
+ <para>The truncate and swap scripts are used in the initial load. The
+ truncate is a no-op in this case, and the swap happens because data
+ is always loaded to the staging table, which must then be swapped
+ with the real cache table. </para>
+ <para>MetaMatrix Administrative Scripts</para>
+ <para>To perform the administrative operations, MetaMatrix provides a
+ set of 4 scripts. Here is a summary of the scripts. All the scripts
+ use a similar template for their file names:
+ VDBName_VDBVersion_Name.ddl).</para>
+ <informaltable frame="all">
+ <tgroup cols="5">
+ <tbody>
+ <row>
+ <entry>
+ <para>Script Base Name</para>
+ </entry>
+ <entry>
+ <para>Use</para>
+ </entry>
+ <entry>
+ <para>Description</para>
+ </entry>
+ <entry>
+ <para>Run Against</para>
+ </entry>
+ <entry>
+ <para>User Info</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Create</para>
+ </entry>
+ <entry>
+ <para>Creation</para>
+ </entry>
+ <entry>
+ <para>Create tables for cache</para>
+ </entry>
+ <entry>
+ <para>Cache database</para>
+ </entry>
+ <entry>
+ <para>Script user</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Truncate</para>
+ </entry>
+ <entry>
+ <para>Reload</para>
+ </entry>
+ <entry>
+ <para>Truncate temporary table when inserting new records</para>
+ </entry>
+ <entry>
+ <para>Cache database</para>
+ </entry>
+ <entry>
+ <para>Script user</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Load</para>
+ </entry>
+ <entry>
+ <para>Load or reload </para>
+ </entry>
+ <entry>
+ <para>Execute queries against materialized virtual groups, insert
+ results into cache</para>
+ </entry>
+ <entry>
+ <para>MetaMatrix</para>
+ </entry>
+ <entry>
+ <para>Access user</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Swap</para>
+ </entry>
+ <entry>
+ <para>Reload</para>
+ </entry>
+ <entry>
+ <para>Swap temporary table with cache table after new records
+ inserted</para>
+ </entry>
+ <entry>
+ <para>Cache database</para>
+ </entry>
+ <entry>
+ <para>Script user</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para />
+ <para>In addition to these scripts, MetaMatrix provides a connection
+ properties file with encrypted passwords.</para>
+ <para>Materialized Database Creation</para>
+ <para>The cache for materialized views is maintained in a separate
+ database system. Therefore, tables must be defined in the database
+ to hold the cached information for the materialized views in a VDB.
+ Materialized views are scoped to a specific VDB version. Therefore,
+ the cache tables should in general be segregated in the cache
+ database by VDB and version. It is the responsibility of the
+ MetaMatrix and database administrators to ensure that the database is
+ defined appropriately for the VDB version, and to ensure that two
+ users are created with the appropriate privileges:</para>
+ <orderedlist>
+ <listitem>
+ <para>Script user – Used when executing Create/Truncate/Swap scripts
+ [note used for Load scripts, since that executes directly against
+ MetaMatrix with MetaMatrix user info]. Requires create/load/alter
+ privileges against the materialized view tables in the database.
+ </para>
+ </listitem>
+ <listitem>
+ <para>Access user – Used in connector binding definition both when
+ reading the cache for user queries, and when refreshing the cache
+ using the Load script. Requires read and insert privileges against
+ the materialized view tables in the database. </para>
+ </listitem>
+ </orderedlist>
+ <para>MetaMatrix provides a DDL script to create all the materialized
+ tables for a VDB. This script is DBMS-specific. When deploying a
+ VDB, the type of the DBMS is determined from the connector binding
+ used for the materialization physical model, and the appropriate
+ script for that DBMS is extracted from the VDB and saved to the local
+ file system. </para>
+ <para>Script name: <VDBName>_<VDBVersion>_Create.ddl
+ </para>
+ <para>Example for “CustomerInfo” VDB, version 7:
+ CustomerInfo_7_Create.ddl </para>
+ <para>The create script is a standard DDL script that can be executed
+ against the DBMS system using whatever mechanisms it supports. The
+ script must be executed against a database schema/catalog with the
+ appropriate privileges as specified in the MetaMatrix Console. </para>
+ <para>Materialized Database Loading</para>
+ <para>MetaMatrix provides a set of 3 scripts to initially populate and
+ subsequently reload (“refresh”) all the materialized tables for a
+ VDB. These scripts are DBMS-specific. They are extracted from the
+ VDB when deploying that VDB, and saved by an administrator to the
+ local file system. These scripts all assume that the cache tables
+ have been created, using the “Create” script described above.</para>
+ <para>These three scripts do the following for each materialized view:
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>Truncate records in a temporary table (executed directly
+ against DBMS)</para>
+ </listitem>
+ <listitem>
+ <para>Load – execute query against virtual group, and insert into
+ temporary table (executed against MetaMatrix)</para>
+ </listitem>
+ <listitem>
+ <para>Swap temporary table with cache table (executed directly
+ against DBMS)</para>
+ </listitem>
+ </orderedlist>
+ <para>The second script uses the MetaMatrix batched inserts
+ functionality. Therefore, the MetaMatrix Server must be running, and
+ the VDB must be deployed and activated. The queries that are
+ executed all use the “cache override” option, so that the
+ transformations are executed. </para>
+ <para>The first and third scripts execute DBMS-specific operations, to
+ more efficiently update the cache records. These scripts are
+ standard DDL scripts that can be executed against the DBMS system
+ using whatever mechanisms it supports. The scripts must be executed
+ against a database schema/catalog with the appropriate privileges as
+ specified in the MetaMatrix Console. </para>
+ <para>The three scripts can be executed together to perform initial
+ loading and subsequent refresh. This can be done using the
+ loadscript.cmd (.sh on UNIX) command script, located in the server
+ materializedviews directory. This script can be used to schedule
+ database loading activities. </para>
+ </sect1>
+ <sect1>
+ <title>Limitations</title>
+ <orderedlist>
+ <listitem>
+ <para>Materialization works only with Relational tables and views.
+ It does not work with Data Access virtual groups or procedures.
+ </para>
+ </listitem>
+ <listitem>
+ <para>A user cannot specify OPTION NOCACHE on virtual groups that
+ are not at the top level (in the user query). The design does not
+ currently support this.</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>Outstanding Issues</title>
+ <para>Specifying OPTION NOCACHE within a transformation query is the
+ same as specifying it a user query – the identified virtual groups
+ will always be re-computed in the context of the virtual group
+ containing the transformation query with the override option.</para>
+ </sect1>
+</chapter>
\ No newline at end of file
Deleted: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,187 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="overview">
- <title>Overview</title>
- <para>Teiid provides three capabilities for caching
- data: materialized views, result set caching, and code table caching.
- These can be used to significantly improve performance in many
- situations. </para>
- <para>Following is a summary comparison of these three data caching
- options.</para>
- <informaltable frame="all">
- <tgroup cols="4">
- <tbody>
- <row>
- <entry>
- <para />
- </entry>
- <entry>
- <para>Materialized Views</para>
- </entry>
- <entry>
- <para>Result Set Caching</para>
- </entry>
- <entry>
- <para>Code Table Caching</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Best For</para>
- </entry>
- <entry>
- <para>Complex transformations</para>
- </entry>
- <entry>
- <para>Complex frequently issued user queries</para>
- </entry>
- <entry>
- <para>Key based lookups on small, frequently accessed tables</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Data Change Rate</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- <entry>
- <para>Static</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Data Size</para>
- </entry>
- <entry>
- <para>Any size</para>
- </entry>
- <entry>
- <para>Small-Medium</para>
- </entry>
- <entry>
- <para>Small</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Defined By</para>
- </entry>
- <entry>
- <para>External scripts</para>
- </entry>
- <entry>
- <para>Query execution</para>
- </entry>
- <entry>
- <para>Scalar function (lookup) execution</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Scope</para>
- </entry>
- <entry>
- <para>VDB</para>
- </entry>
- <entry>
- <para>VDB or session</para>
- </entry>
- <entry>
- <para>VDB within Query service</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Key</para>
- </entry>
- <entry>
- <para />
- </entry>
- <entry>
- <para>Based upon the user query</para>
- </entry>
- <entry>
- <para>VDB + table + key column + value column</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Removal Policy</para>
- </entry>
- <entry>
- <para>None (discretion of administrator)</para>
- </entry>
- <entry>
- <para>Least-recently used removed first</para>
- </entry>
- <entry>
- <para>None (discretion of administrator)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Configuration</para>
- </entry>
- <entry>
- <para>Model properties</para>
- </entry>
- <entry>
- <para>DQP Configuration</para>
- </entry>
- <entry>
- <para>DQP Configuration</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Cache Administration</para>
- </entry>
- <entry>
- <para>External to Teiid</para>
- </entry>
- <entry>
- <para></para>
- </entry>
- <entry>
- <para></para>
- </entry>
- </row>
- <row>
- <entry>
- <para>Access Method</para>
- </entry>
- <entry>
- <para>Query against materialized view</para>
- </entry>
- <entry>
- <para>Query with caching enabled</para>
- </entry>
- <entry>
- <para>Query containing scalar “lookup” function</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>User Override?</para>
- </entry>
- <entry>
- <para>Yes</para>
- </entry>
- <entry>
- <para>Yes</para>
- </entry>
- <entry>
- <para>No – must explicitly specify whether to use</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
-</chapter>
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/overview.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,187 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="overview">
+ <title>Overview</title>
+ <para>Teiid provides three capabilities for caching
+ data: materialized views, result set caching, and code table caching.
+ These can be used to significantly improve performance in many
+ situations. </para>
+ <para>Following is a summary comparison of these three data caching
+ options.</para>
+ <informaltable frame="all">
+ <tgroup cols="4">
+ <tbody>
+ <row>
+ <entry>
+ <para />
+ </entry>
+ <entry>
+ <para>Materialized Views</para>
+ </entry>
+ <entry>
+ <para>Result Set Caching</para>
+ </entry>
+ <entry>
+ <para>Code Table Caching</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Best For</para>
+ </entry>
+ <entry>
+ <para>Complex transformations</para>
+ </entry>
+ <entry>
+ <para>Complex frequently issued user queries</para>
+ </entry>
+ <entry>
+ <para>Key based lookups on small, frequently accessed tables</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Data Change Rate</para>
+ </entry>
+ <entry>
+ <para>Static</para>
+ </entry>
+ <entry>
+ <para>Static</para>
+ </entry>
+ <entry>
+ <para>Static</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Data Size</para>
+ </entry>
+ <entry>
+ <para>Any size</para>
+ </entry>
+ <entry>
+ <para>Small-Medium</para>
+ </entry>
+ <entry>
+ <para>Small</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Defined By</para>
+ </entry>
+ <entry>
+ <para>External scripts</para>
+ </entry>
+ <entry>
+ <para>Query execution</para>
+ </entry>
+ <entry>
+ <para>Scalar function (lookup) execution</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Scope</para>
+ </entry>
+ <entry>
+ <para>VDB</para>
+ </entry>
+ <entry>
+ <para>VDB or session</para>
+ </entry>
+ <entry>
+ <para>VDB within Query service</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Key</para>
+ </entry>
+ <entry>
+ <para />
+ </entry>
+ <entry>
+ <para>Based upon the user query</para>
+ </entry>
+ <entry>
+ <para>VDB + table + key column + value column</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Removal Policy</para>
+ </entry>
+ <entry>
+ <para>None (discretion of administrator)</para>
+ </entry>
+ <entry>
+ <para>Least-recently used removed first</para>
+ </entry>
+ <entry>
+ <para>None (discretion of administrator)</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Configuration</para>
+ </entry>
+ <entry>
+ <para>Model properties</para>
+ </entry>
+ <entry>
+ <para>DQP Configuration</para>
+ </entry>
+ <entry>
+ <para>DQP Configuration</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Cache Administration</para>
+ </entry>
+ <entry>
+ <para>External to Teiid</para>
+ </entry>
+ <entry>
+ <para></para>
+ </entry>
+ <entry>
+ <para></para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>Access Method</para>
+ </entry>
+ <entry>
+ <para>Query against materialized view</para>
+ </entry>
+ <entry>
+ <para>Query with caching enabled</para>
+ </entry>
+ <entry>
+ <para>Query containing scalar “lookup” function</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>User Override?</para>
+ </entry>
+ <entry>
+ <para>Yes</para>
+ </entry>
+ <entry>
+ <para>Yes</para>
+ </entry>
+ <entry>
+ <para>No – must explicitly specify whether to use</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+</chapter>
Deleted: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml
===================================================================
--- trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,254 +0,0 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-<chapter id="resultset">
- <title>Result Set Caching</title>
- <para>MetaMatrix provides the capability to store the results of
- specific queries. MetaMatrix can be configured to store the results
- for end-user queries, or to cache the results of atomic queries issued
- to data sources in response to end-user queries, or both. When the
- exact same user query is submitted to the MetaMatrix Server, the
- cached results will be returned. Similarly, if the exact same atomic
- query is encountered while processing an end-user query, the cached
- results will be used in processing that query, even if the end-user
- query is different than the original one. These caching techniques
- can yield significant performance gains if users of the system submit
- the same queries often, or if user queries result in the same queries
- being issued to the underlying data sources.</para>
- <para>Result set caching will cache result sets based on an exact match
- of the incoming SQL string. It only applies to SELECT and EXEC
- statements; it does not apply to SELECT INTO statements, or INSERT,
- UPDATE, and DELETE statements.</para>
- <sect1>
- <title>Support Summary</title>
- <orderedlist>
- <listitem>
- <para>Caching of end-user queries (on a per-query service basis)
- </para>
- </listitem>
- <listitem>
- <para>Caching of data source queries (on a per-connector binding
- basis)</para>
- </listitem>
- <listitem>
- <para>Scoping of caching to either VDB or session level</para>
- </listitem>
- <listitem>
- <para>Caching of XML result sets</para>
- </listitem>
- <listitem>
- <para>Users explicitly state whether to use a result set cache or
- not (if available)</para>
- </listitem>
- <listitem>
- <para>Administrative clearing of caches</para>
- </listitem>
- </orderedlist>
- </sect1>
- <sect1>
- <title>User Interaction</title>
- <para>End users or client applications explicitly state whether to use
- result set caching for each query. This can be done by setting the
- JDBC ResultSetCacheMode execution property to true to enable the use
- of caching for that statement, or false to disable it. The default
- is true. Note that if this property is set to true, it only has an
- effect if caching has been enabled in the Server. </para>
- <para>Specification of result set caching for ODBC and SOAP is through
- extra URL properties, on a per-connection basis. </para>
- <para>Each query is re-checked for authorization for the user’s
- permissions, regardless of whether or not the query results have been
- cached.</para>
- </sect1>
- <sect1>
- <title>Cache Configuration</title>
- <para>Result set caching in the MetaMatrix Server is configured in the
- MetaMatrix Console. By default, result set caching is disabled.
- When enabled, the default caching scope is restricted to a
- particular VDB.</para>
- <para>Result set caching can be enabled and configured in two places:
- </para>
- <orderedlist>
- <listitem>
- <para>End-user queries – In Configuration Deployment panel,
- QueryEngine PSC, QueryService properties (per MetaMatrix process)
- </para>
- </listitem>
- <listitem>
- <para>Data source queries – In Configuration Connector Binding
- panel, properties</para>
- </listitem>
- </orderedlist>
- <para>The following are the properties that can be set at the query
- service and connector binding levels.</para>
- <informaltable frame="all">
- <tgroup cols="4">
- <tbody>
- <row>
- <entry>
- <para>Property</para>
- </entry>
- <entry>
- <para>Description</para>
- </entry>
- <entry>
- <para>Type</para>
- </entry>
- <entry>
- <para>Default</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Enabled</para>
- </entry>
- <entry>
- <para>Enable result set caching for the source</para>
- </entry>
- <entry>
- <para>Boolean</para>
- </entry>
- <entry>
- <para>false</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Maximum Age</para>
- </entry>
- <entry>
- <para>Maximum time before the cache is automatically cleared
- </para>
- </entry>
- <entry>
- <para>Integer – millsec</para>
- </entry>
- <entry>
- <para>0 (no limit)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Maximum Size</para>
- </entry>
- <entry>
- <para>Maximum size the cache will be allowed to grow to before
- objects are removed</para>
- </entry>
- <entry>
- <para>Integer – MB </para>
- </entry>
- <entry>
- <para>0 (no limit)</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>ResultSet Cache Scope</para>
- </entry>
- <entry>
- <para>Whether caching is restricted to a specific session
- (‘session’) or a specific VDB version (‘vdb’)</para>
- </entry>
- <entry>
- <para>String</para>
- </entry>
- <entry>
- <para>vdb</para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <para />
- <para>End-User Cache Configuration</para>
- <para>End-user query result caching is controlled in properties for
- the individual Query Services in each PSC. These properties can be
- accessed in the Configuration Deployment panel, by selecting the
- QueryEngine PSC, then selecting an individual QueryService. The
- properties are shown at the bottom. </para>
- <para>
- <inlinegraphic fileref="embedded:graphics3" width="5.3866inch"
- depth="3.5646inch" />
- </para>
- <para>Data Source Cache Configuration</para>
- <para>Data source caching is controlled in properties for the
- individual connector bindings for each source. These properties can
- be accessed on the Configuration Connector Bindings panel, by
- selecting an individual connector binding and selecting the
- Properties tab. Note that these are all optional properties. Check
- the Include Optional Properties setting to see these properties.
- </para>
- </sect1>
- <sect1>
- <title>Cache Characteristics</title>
- <para>Cache Persistence Mechanism</para>
- <para>Result sets are persisted in object caches local to individual
- Java processes (virtual machines or VMs). User query result sets
- are cached in the VM of the individual query services running on host
- machines. Data source query results are cached in the VM of the
- individual connector bindings running on host machines. </para>
- <para>Cache Operational Policy</para>
- <para>Objects are removed from the cache on a least frequently used
- basis. When the cache reaches approximately 90% of its maximum size
- (as defined by the ResultSet Cache Maximum Size property), query
- result sets are removed to bring the cache back down to the 80%
- threshold.</para>
- </sect1>
- <sect1>
- <title>Cache Administration</title>
- <para>Result set caching is administered using the servershell script
- under the <server install>/util directory. This script is
- called servershell.cmd on Windows systems, and servershell.sh on Unix
- systems. </para>
- <para>The following administrative operations can be performed for all
- caches of a given type, by specifying the appropriate parameters on
- the script’s command-line:</para>
- <orderedlist>
- <listitem>
- <para>Clear cache options</para>
- </listitem>
- <listitem>
- <para>clearQueryServiceResultSetCaches – clears all the result set
- caches in all the query services</para>
- </listitem>
- <listitem>
- <para>clearConnectorServiceResultSetCaches – clears all the result
- set caches in all the connector services</para>
- </listitem>
- </orderedlist>
- <para>These can be listed in help by executing the script with the
- command-line argument expertmode on. </para>
- </sect1>
- <sect1>
- <title>Limitations</title>
- <orderedlist>
- <listitem>
- <para>BLOBs and CLOBs cannot be cached. Therefore, any query
- retrieving BLOB or CLOB information will not be cached. </para>
- </listitem>
- <listitem>
- <para>Caches are not distributed; they are bound to a particular
- MetaMatrix process. So, if the same query is routed to two
- different host machines, the query will be executed twice, and
- cached independently on each machine. </para>
- </listitem>
- <listitem>
- <para>Result set caching is not transactional and should not be used
- in the scope of XA transactions. Transactions depend on (and
- enforce) consistency of data, and cached data cannot be guaranteed
- to be consistent with the data store’s data.</para>
- </listitem>
- <listitem>
- <para>ResultSet Cache Scope property values are not constrained, so
- users may type in the incorrect values (only vdb and session are
- allowed). [defect 14444]</para>
- </listitem>
- </orderedlist>
- </sect1>
- <sect1>
- <title>Outstanding Issues</title>
- <para>Specification of result set caching for ODBC and SOAP is through
- extra URL properties, on a per-connection basis.</para>
- </sect1>
-</chapter>
\ No newline at end of file
Copied: branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml (from rev 1798, trunk/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml)
===================================================================
--- branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml (rev 0)
+++ branches/JCA/documentation/caching-guide/src/main/docbook/en-US/content/resultset.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,254 @@
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+<chapter id="resultset">
+ <title>Result Set Caching</title>
+ <para>MetaMatrix provides the capability to store the results of
+ specific queries. MetaMatrix can be configured to store the results
+ for end-user queries, or to cache the results of atomic queries issued
+ to data sources in response to end-user queries, or both. When the
+ exact same user query is submitted to the MetaMatrix Server, the
+ cached results will be returned. Similarly, if the exact same atomic
+ query is encountered while processing an end-user query, the cached
+ results will be used in processing that query, even if the end-user
+ query is different than the original one. These caching techniques
+ can yield significant performance gains if users of the system submit
+ the same queries often, or if user queries result in the same queries
+ being issued to the underlying data sources.</para>
+ <para>Result set caching will cache result sets based on an exact match
+ of the incoming SQL string. It only applies to SELECT and EXEC
+ statements; it does not apply to SELECT INTO statements, or INSERT,
+ UPDATE, and DELETE statements.</para>
+ <sect1>
+ <title>Support Summary</title>
+ <orderedlist>
+ <listitem>
+ <para>Caching of end-user queries (on a per-query service basis)
+ </para>
+ </listitem>
+ <listitem>
+ <para>Caching of data source queries (on a per-connector binding
+ basis)</para>
+ </listitem>
+ <listitem>
+ <para>Scoping of caching to either VDB or session level</para>
+ </listitem>
+ <listitem>
+ <para>Caching of XML result sets</para>
+ </listitem>
+ <listitem>
+ <para>Users explicitly state whether to use a result set cache or
+ not (if available)</para>
+ </listitem>
+ <listitem>
+ <para>Administrative clearing of caches</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>User Interaction</title>
+ <para>End users or client applications explicitly state whether to use
+ result set caching for each query. This can be done by setting the
+ JDBC ResultSetCacheMode execution property to true to enable the use
+ of caching for that statement, or false to disable it. The default
+ is true. Note that if this property is set to true, it only has an
+ effect if caching has been enabled in the Server. </para>
+ <para>Specification of result set caching for ODBC and SOAP is through
+ extra URL properties, on a per-connection basis. </para>
+ <para>Each query is re-checked for authorization for the user’s
+ permissions, regardless of whether or not the query results have been
+ cached.</para>
+ </sect1>
+ <sect1>
+ <title>Cache Configuration</title>
+ <para>Result set caching in the MetaMatrix Server is configured in the
+ MetaMatrix Console. By default, result set caching is disabled.
+ When enabled, the default caching scope is restricted to a
+ particular VDB.</para>
+ <para>Result set caching can be enabled and configured in two places:
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>End-user queries – In Configuration Deployment panel,
+ QueryEngine PSC, QueryService properties (per MetaMatrix process)
+ </para>
+ </listitem>
+ <listitem>
+ <para>Data source queries – In Configuration Connector Binding
+ panel, properties</para>
+ </listitem>
+ </orderedlist>
+ <para>The following are the properties that can be set at the query
+ service and connector binding levels.</para>
+ <informaltable frame="all">
+ <tgroup cols="4">
+ <tbody>
+ <row>
+ <entry>
+ <para>Property</para>
+ </entry>
+ <entry>
+ <para>Description</para>
+ </entry>
+ <entry>
+ <para>Type</para>
+ </entry>
+ <entry>
+ <para>Default</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>ResultSet Cache Enabled</para>
+ </entry>
+ <entry>
+ <para>Enable result set caching for the source</para>
+ </entry>
+ <entry>
+ <para>Boolean</para>
+ </entry>
+ <entry>
+ <para>false</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>ResultSet Cache Maximum Age</para>
+ </entry>
+ <entry>
+ <para>Maximum time before the cache is automatically cleared
+ </para>
+ </entry>
+ <entry>
+ <para>Integer – millsec</para>
+ </entry>
+ <entry>
+ <para>0 (no limit)</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>ResultSet Cache Maximum Size</para>
+ </entry>
+ <entry>
+ <para>Maximum size the cache will be allowed to grow to before
+ objects are removed</para>
+ </entry>
+ <entry>
+ <para>Integer – MB </para>
+ </entry>
+ <entry>
+ <para>0 (no limit)</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>ResultSet Cache Scope</para>
+ </entry>
+ <entry>
+ <para>Whether caching is restricted to a specific session
+ (‘session’) or a specific VDB version (‘vdb’)</para>
+ </entry>
+ <entry>
+ <para>String</para>
+ </entry>
+ <entry>
+ <para>vdb</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para />
+ <para>End-User Cache Configuration</para>
+ <para>End-user query result caching is controlled in properties for
+ the individual Query Services in each PSC. These properties can be
+ accessed in the Configuration Deployment panel, by selecting the
+ QueryEngine PSC, then selecting an individual QueryService. The
+ properties are shown at the bottom. </para>
+ <para>
+ <inlinegraphic fileref="embedded:graphics3" width="5.3866inch"
+ depth="3.5646inch" />
+ </para>
+ <para>Data Source Cache Configuration</para>
+ <para>Data source caching is controlled in properties for the
+ individual connector bindings for each source. These properties can
+ be accessed on the Configuration Connector Bindings panel, by
+ selecting an individual connector binding and selecting the
+ Properties tab. Note that these are all optional properties. Check
+ the Include Optional Properties setting to see these properties.
+ </para>
+ </sect1>
+ <sect1>
+ <title>Cache Characteristics</title>
+ <para>Cache Persistence Mechanism</para>
+ <para>Result sets are persisted in object caches local to individual
+ Java processes (virtual machines or VMs). User query result sets
+ are cached in the VM of the individual query services running on host
+ machines. Data source query results are cached in the VM of the
+ individual connector bindings running on host machines. </para>
+ <para>Cache Operational Policy</para>
+ <para>Objects are removed from the cache on a least frequently used
+ basis. When the cache reaches approximately 90% of its maximum size
+ (as defined by the ResultSet Cache Maximum Size property), query
+ result sets are removed to bring the cache back down to the 80%
+ threshold.</para>
+ </sect1>
+ <sect1>
+ <title>Cache Administration</title>
+ <para>Result set caching is administered using the servershell script
+ under the <server install>/util directory. This script is
+ called servershell.cmd on Windows systems, and servershell.sh on Unix
+ systems. </para>
+ <para>The following administrative operations can be performed for all
+ caches of a given type, by specifying the appropriate parameters on
+ the script’s command-line:</para>
+ <orderedlist>
+ <listitem>
+ <para>Clear cache options</para>
+ </listitem>
+ <listitem>
+ <para>clearQueryServiceResultSetCaches – clears all the result set
+ caches in all the query services</para>
+ </listitem>
+ <listitem>
+ <para>clearConnectorServiceResultSetCaches – clears all the result
+ set caches in all the connector services</para>
+ </listitem>
+ </orderedlist>
+ <para>These can be listed in help by executing the script with the
+ command-line argument expertmode on. </para>
+ </sect1>
+ <sect1>
+ <title>Limitations</title>
+ <orderedlist>
+ <listitem>
+ <para>BLOBs and CLOBs cannot be cached. Therefore, any query
+ retrieving BLOB or CLOB information will not be cached. </para>
+ </listitem>
+ <listitem>
+ <para>Caches are not distributed; they are bound to a particular
+ MetaMatrix process. So, if the same query is routed to two
+ different host machines, the query will be executed twice, and
+ cached independently on each machine. </para>
+ </listitem>
+ <listitem>
+ <para>Result set caching is not transactional and should not be used
+ in the scope of XA transactions. Transactions depend on (and
+ enforce) consistency of data, and cached data cannot be guaranteed
+ to be consistent with the data store’s data.</para>
+ </listitem>
+ <listitem>
+ <para>ResultSet Cache Scope property values are not constrained, so
+ users may type in the incorrect values (only vdb and session are
+ allowed). [defect 14444]</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>Outstanding Issues</title>
+ <para>Specification of result set caching for ODBC and SOAP is through
+ extra URL properties, on a per-connection basis.</para>
+ </sect1>
+</chapter>
\ No newline at end of file
Modified: branches/JCA/documentation/reference/src/main/docbook/en-US/content/architecture.xml
===================================================================
--- branches/JCA/documentation/reference/src/main/docbook/en-US/content/architecture.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/documentation/reference/src/main/docbook/en-US/content/architecture.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -51,8 +51,7 @@
<para>Session – the Session service manages active
session information. Active sessions are stored in a
distributed cache and shared between Session services in each
- VM. Sessions are also persisted in the server repository
- database. </para>
+ VM.</para>
</listitem>
<listitem>
<para>Membership – the Membership service manages
Modified: branches/JCA/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- branches/JCA/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -755,7 +755,7 @@
<para>ASCII(x)</para>
</entry>
<entry>
- <para>Provide ASCII value of the left most character in x. The empty string will as input will return null.</para>
+ <para>Provide ASCII value of the left most character in x. The empty string will as input will return null. <footnoteref linkend="nonAscii"/></para>
</entry>
<entry>
<para>return type is integer</para>
@@ -766,7 +766,11 @@
<para>CHR(x) CHAR(x)</para>
</entry>
<entry>
- <para>Provide the character for ASCII value x</para>
+ <para>Provide the character for ASCII value x
+ <footnote label="1" id="nonAscii"><para>Non-ASCII range characters or integers used in these functions
+ may produce different results or exceptions depending on where the function is evalutated (Teiid vs. source).
+ Teiid's uses Java default int to char and char to int conversions, which operates over UTF16 values.</para></footnote>
+ </para>
</entry>
<entry>
<para>x in {integer}</para>
Copied: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java (from rev 1798, trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java)
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java (rev 0)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,41 @@
+/*
+ * 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 com.metamatrix.common.buffer;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+
+public interface BatchManager {
+
+ public interface ManagedBatch {
+
+ TupleBatch getBatch(boolean cache, String[] types) throws MetaMatrixComponentException;
+
+ void remove();
+
+ }
+
+ ManagedBatch createManagedBatch(TupleBatch batch) throws MetaMatrixComponentException;
+
+ void remove();
+
+}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -48,48 +48,17 @@
FINAL
}
+ public static int DEFAULT_CONNECTOR_BATCH_SIZE = 2048;
+ public static int DEFAULT_PROCESSOR_BATCH_SIZE = 1024;
+ public static int DEFAULT_MAX_PROCESSING_BATCHES = 8;
+
/**
- * Optional property - the max size of a batch sent between connector and query service.
- * Making batches larger reduces communication overhead between connector and query service
- * but increases the granularity of memory management on those batches. This value should
- * be a positive integer and defaults to 1000.
+ * The BufferManager may maintain at least this many batch references in memory.
+ *
+ * Up to 2x this value may be held by soft references.
*/
- public static final String CONNECTOR_BATCH_SIZE = "metamatrix.buffer.connectorBatchSize"; //$NON-NLS-1$
- /**
- * Optional property - the max size of a batch sent internally within the query processor.
- * In general, these batches should be smaller than the connector batch size as there are
- * no communication costs with these batches. Smaller batches typically allow a user to
- * get their first results quicker and allow fine-grained buffer management on intermediate
- * results. This value should be a positive integer and defaults to 100.
- */
- public static final String PROCESSOR_BATCH_SIZE = "metamatrix.buffer.processorBatchSize"; //$NON-NLS-1$
- /**
- * Optional property - this value specifies the location to store temporary buffers to
- * large to fit in memory. Temporary buffer files will be created and destroyed in this
- * directory. This value should be a string specifying an absolute directory path.
- */
- public static final String BUFFER_STORAGE_DIRECTORY = "metamatrix.buffer.storageDirectory"; //$NON-NLS-1$
- /**
- * Optional property - this values specifies how many open file descriptors should be cached
- * in the storage directory. Increasing this value in heavy load may improve performance
- * but will use more file descriptors, which are a limited system resource. The default
- * is 32.
- */
- public static final String MAX_OPEN_FILES = "metamatrix.buffer.maxOpenFiles"; //$NON-NLS-1$
- /**
- * Optional property - this values specifies the maximum size in MegaBytes that a buffer file can reach.
- * The default is 2048 MB (i.e. 2GB).
- */
- public static final String MAX_FILE_SIZE = "metamatrix.buffer.maxFileSize"; //$NON-NLS-1$
- /**
- * Optional property - the max number of batches to process at once in algorithms such as sorting.
- */
- public static final String MAX_PROCESSING_BATCHES = "metamatrix.buffer.maxProcessingBatches"; //$NON-NLS-1$
+ public static int DEFAULT_RESERVE_BUFFERS = 64;
- public static int DEFAULT_CONNECTOR_BATCH_SIZE = 2048;
- public static int DEFAULT_PROCESSOR_BATCH_SIZE = 1024;
- public static int DEFAULT_MAX_PROCESSING_BATCHES = 16;
-
/**
* Get the batch size to use during query processing.
* @return Batch size (# of rows)
@@ -105,8 +74,35 @@
TupleBuffer createTupleBuffer(List elements, String groupName, TupleSourceType tupleSourceType)
throws MetaMatrixComponentException;
+ /**
+ * Return the maximum number of batches that can be temporarily held potentially
+ * across even a blocked exception.
+ * @return
+ */
int getMaxProcessingBatches();
+ /**
+ * Creates a new {@link FileStore}. See {@link FileStore#setCleanupReference(Object)} to
+ * automatically cleanup the underlying resources.
+ * @param name
+ * @return
+ */
FileStore createFileStore(String name);
+ /**
+ * Reserve up to count buffers for use. Wait will cause the process to block until
+ * all of the requested or half of the total buffers are available.
+ * @param count
+ * @param wait
+ * @return
+ * @throws MetaMatrixComponentException
+ */
+ int reserveBuffers(int count, boolean wait) throws MetaMatrixComponentException;
+
+ /**
+ * Releases the buffers reserved by a call to {@link BufferManager#reserveBuffers(int, boolean)}
+ * @param count
+ */
+ void releaseBuffers(int count);
+
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -59,13 +59,22 @@
@Override
public void write(byte[] b, int off, int len) throws IOException {
- if (count + len <= buffer.length) {
- System.arraycopy(b, off, buffer, count, len);
- count += len;
+ if (len > buffer.length) {
+ flushBuffer();
+ writeDirect(b, off, len);
return;
}
+ int bufferedLength = Math.min(len, buffer.length - count);
+ if (count < buffer.length) {
+ System.arraycopy(b, off, buffer, count, bufferedLength);
+ count += bufferedLength;
+ if (bufferedLength == len) {
+ return;
+ }
+ }
flushBuffer();
- writeDirect(b, off, len);
+ System.arraycopy(b, off + bufferedLength, buffer, count, len - bufferedLength);
+ count += len - bufferedLength;
}
private void writeDirect(byte[] b, int off, int len) throws IOException {
@@ -77,7 +86,7 @@
}
}
- private void flushBuffer() throws IOException {
+ public void flushBuffer() throws IOException {
if (count > 0) {
writeDirect(buffer, 0, count);
count = 0;
@@ -119,6 +128,9 @@
}
}
+ private boolean removed;
+ private long len;
+
public void setCleanupReference(Object o) {
REFERENCES.add(new CleanupReference(o, this));
for (int i = 0; i < 10; i++) {
@@ -131,8 +143,10 @@
}
}
- private boolean removed;
-
+ public synchronized long getLength() {
+ return len;
+ }
+
public int read(long fileOffset, byte[] b, int offSet, int length)
throws MetaMatrixComponentException {
if (removed) {
@@ -155,18 +169,21 @@
} while (n < length);
}
- public long write(byte[] bytes) throws MetaMatrixComponentException {
- return write(bytes, 0, bytes.length);
+ public void write(byte[] bytes) throws MetaMatrixComponentException {
+ write(bytes, 0, bytes.length);
}
- public long write(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
+ public synchronized long write(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
if (removed) {
throw new MetaMatrixComponentException("already removed"); //$NON-NLS-1$
}
- return writeDirect(bytes, offset, length);
+ writeDirect(bytes, offset, length);
+ long result = len;
+ len += length;
+ return result;
}
- protected abstract long writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException;
+ protected abstract void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException;
public void remove() {
if (!this.removed) {
@@ -177,9 +194,9 @@
protected abstract void removeDirect();
- public InputStream createInputStream() {
+ public InputStream createInputStream(final long start) {
return new InputStream() {
- private long offset;
+ private long offset = start;
@Override
public int read() throws IOException {
Deleted: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/ManagedBatch.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/ManagedBatch.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/ManagedBatch.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer;
-
-import java.lang.ref.SoftReference;
-
-class ManagedBatch {
-
- private int beginRow;
- private SoftReference<TupleBatch> batchReference;
- private long offset;
- private int length;
-
- /**
- * Constructor for ManagedBatch.
- */
- public ManagedBatch(TupleBatch batch) {
- this.beginRow = batch.getBeginRow();
- this.batchReference = new SoftReference<TupleBatch>(batch);
- }
-
- /**
- * Get the begin row, must be >= 1
- * @return Begin row
- */
- public int getBeginRow() {
- return this.beginRow;
- }
-
- public String toString() {
- return "ManagedBatch[" + beginRow + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public TupleBatch getBatch() {
- return this.batchReference.get();
- }
-
- public void setBatchReference(TupleBatch batch) {
- this.batchReference = new SoftReference<TupleBatch>(batch);
- }
-
- public int getLength() {
- return length;
- }
-
- public long getOffset() {
- return offset;
- }
-
- public void setLength(int length) {
- this.length = length;
- }
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-
-}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,13 +22,11 @@
package com.metamatrix.common.buffer;
-import java.util.Properties;
-
import com.metamatrix.api.exception.MetaMatrixComponentException;
public interface StorageManager {
- void initialize(Properties props) throws MetaMatrixComponentException;
+ void initialize() throws MetaMatrixComponentException;
FileStore createFileStore(String name);
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -40,8 +40,10 @@
* This object is immutable and Serializable;
*/
public class TupleBatch implements Externalizable {
-
- private int rowOffset;
+
+ private static final long serialVersionUID = 6304443387337336957L;
+
+ private int rowOffset;
private List[] tuples;
// Optional state
@@ -140,10 +142,18 @@
this.terminationFlag = terminationFlag;
}
+ public String[] getDataTypes() {
+ return types;
+ }
+
public void setDataTypes(String[] types) {
this.types = types;
}
+ public boolean containsRow(int row) {
+ return rowOffset <= row && getEndRow() >= row;
+ }
+
/**
* Return a String describing this object
* @param String representation of this TupleBatch
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,19 +22,13 @@
package com.metamatrix.common.buffer;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -42,15 +36,15 @@
import com.metamatrix.common.types.Streamable;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.sql.symbol.Expression;
public class TupleBuffer {
class TupleSourceImpl implements IndexedTupleSource {
- private SoftReference<TupleBatch> currentBatch;
private int currentRow = 1;
private int mark = 1;
private List<?> currentTuple;
+ private TupleBatch batch;
@Override
public int getCurrentIndex() {
@@ -80,47 +74,30 @@
private List<?> getCurrentTuple() throws MetaMatrixComponentException,
BlockedException {
- TupleBatch batch = getBatch();
- if(batch.getRowCount() == 0) {
- // Check if last
- if(isFinal) {
- currentBatch = null;
- return null;
- }
- throw BlockedException.INSTANCE;
- }
-
- return batch.getTuple(currentRow);
+ if (currentRow <= rowCount) {
+ if (forwardOnly) {
+ if (batch == null || currentRow > batch.getEndRow()) {
+ batch = getBatch(currentRow);
+ }
+ return batch.getTuple(currentRow);
+ }
+ //TODO: determine if we should directly hold a soft reference here
+ return getRow(currentRow);
+ }
+ if(isFinal) {
+ return null;
+ }
+ throw BlockedException.INSTANCE;
}
@Override
public void closeSource()
throws MetaMatrixComponentException{
- currentBatch = null;
+ batch = null;
mark = 1;
reset();
}
- // Retrieves the necessary batch based on the currentRow
- TupleBatch getBatch() throws MetaMatrixComponentException{
- TupleBatch batch = null;
- if (currentBatch != null) {
- batch = currentBatch.get();
- }
- if (batch != null) {
- if (currentRow <= batch.getEndRow() && currentRow >= batch.getBeginRow()) {
- return batch;
- }
- currentBatch = null;
- }
-
- batch = TupleBuffer.this.getBatch(currentRow);
- if (batch != null) {
- currentBatch = new SoftReference<TupleBatch>(batch);
- }
- return batch;
- }
-
@Override
public boolean hasNext() throws MetaMatrixComponentException {
if (this.currentTuple != null) {
@@ -149,34 +126,56 @@
this.currentTuple = null;
}
}
+
+ @Override
+ public int available() {
+ return rowCount - currentRow + 1;
+ }
}
+
+ /**
+ * Gets the data type names for each of the input expressions, in order.
+ * @param expressions List of Expressions
+ * @return
+ * @since 4.2
+ */
+ public static String[] getTypeNames(List expressions) {
+ if (expressions == null) {
+ return null;
+ }
+ String[] types = new String[expressions.size()];
+ for (ListIterator i = expressions.listIterator(); i.hasNext();) {
+ Expression expr = (Expression)i.next();
+ types[i.previousIndex()] = DataTypeManager.getDataTypeName(expr.getType());
+ }
+ return types;
+ }
private static final AtomicLong LOB_ID = new AtomicLong();
//construction state
- private StorageManager manager;
+ private BatchManager manager;
private String tupleSourceID;
private List<?> schema;
private String[] types;
private int batchSize;
- private FileStore store;
-
private int rowCount;
private boolean isFinal;
- private TreeMap<Integer, ManagedBatch> batches = new TreeMap<Integer, ManagedBatch>();
+ private TreeMap<Integer, BatchManager.ManagedBatch> batches = new TreeMap<Integer, BatchManager.ManagedBatch>();
private ArrayList<List<?>> batchBuffer;
- private AtomicInteger referenceCount = new AtomicInteger(1);
+ private boolean removed;
+ private boolean forwardOnly;
//lob management
private Map<String, Streamable<?>> lobReferences; //references to contained lobs
private boolean lobs = true;
- public TupleBuffer(StorageManager manager, String id, List<?> schema, String[] types, int batchSize) {
+ public TupleBuffer(BatchManager manager, String id, List<?> schema, int batchSize) {
this.manager = manager;
this.tupleSourceID = id;
this.schema = schema;
- this.types = types;
+ this.types = getTypeNames(schema);
this.batchSize = batchSize;
if (types != null) {
int i = 0;
@@ -201,129 +200,122 @@
}
batchBuffer.add(tuple);
if (batchBuffer.size() == batchSize) {
- saveBatch(false);
+ saveBatch(false, false);
}
}
+
+ /**
+ * Adds the given batch preserving row offsets.
+ * @param batch
+ * @throws MetaMatrixComponentException
+ */
+ public void addTupleBatch(TupleBatch batch, boolean save) throws MetaMatrixComponentException {
+ Assertion.assertTrue(this.rowCount < batch.getBeginRow());
+ if (this.rowCount != batch.getBeginRow() - 1) {
+ saveBatch(false, true);
+ this.rowCount = batch.getBeginRow() - 1;
+ }
+ if (save) {
+ for (List<?> tuple : batch.getAllTuples()) {
+ addTuple(tuple);
+ }
+ }
+ }
+
+ public void purge() {
+ if (this.batchBuffer != null) {
+ this.batchBuffer = null;
+ }
+ for (BatchManager.ManagedBatch batch : this.batches.values()) {
+ batch.remove();
+ }
+ this.batches.clear();
+ }
+
+ /**
+ * Force the persistence of any rows held in memory.
+ * @throws MetaMatrixComponentException
+ */
+ public void saveBatch() throws MetaMatrixComponentException {
+ this.saveBatch(false, false);
+ }
- public void saveBatch(boolean finalBatch) throws MetaMatrixComponentException {
+ void saveBatch(boolean finalBatch, boolean force) throws MetaMatrixComponentException {
Assertion.assertTrue(!this.isRemoved());
- if (batchBuffer == null || batchBuffer.isEmpty()) {
+ if (batchBuffer == null || batchBuffer.isEmpty() || (!force && batchBuffer.size() < Math.max(1, batchSize / 32))) {
return;
}
- List<?> rows = batchBuffer==null?Collections.emptyList():batchBuffer;
- TupleBatch writeBatch = new TupleBatch(rowCount - rows.size() + 1, rows);
+ TupleBatch writeBatch = new TupleBatch(rowCount - batchBuffer.size() + 1, batchBuffer);
if (finalBatch) {
writeBatch.setTerminationFlag(true);
}
- ManagedBatch mbatch = new ManagedBatch(writeBatch);
- if (this.store == null) {
- this.store = this.manager.createFileStore(this.tupleSourceID);
- this.store.setCleanupReference(this);
- }
- byte[] bytes = convertToBytes(writeBatch);
- mbatch.setLength(bytes.length);
- mbatch.setOffset(this.store.write(bytes));
- this.batches.put(mbatch.getBeginRow(), mbatch);
+ writeBatch.setDataTypes(types);
+ BatchManager.ManagedBatch mbatch = manager.createManagedBatch(writeBatch);
+ this.batches.put(writeBatch.getBeginRow(), mbatch);
batchBuffer = null;
}
- /**
- * Convert from an object to a byte array
- * @param object Object to convert
- * @return Byte array
- */
- private byte[] convertToBytes(TupleBatch batch) throws MetaMatrixComponentException {
- ObjectOutputStream oos = null;
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- oos = new ObjectOutputStream(baos);
-
- batch.setDataTypes(types);
- batch.writeExternal(oos);
- oos.flush();
- return baos.toByteArray();
-
- } catch(IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStorageManager.batch_error")); //$NON-NLS-1$
- } finally {
- if(oos != null) {
- try {
- oos.close();
- } catch(IOException e) {
- }
- }
- }
- }
-
public void close() throws MetaMatrixComponentException {
- //if there is only a single batch, let it stay in memory
- if (!this.batches.isEmpty()) {
- saveBatch(true);
- }
+ saveBatch(true, false);
this.isFinal = true;
}
+
+ List<?> getRow(int row) throws MetaMatrixComponentException {
+ if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
+ return this.batchBuffer.get(row - rowCount + this.batchBuffer.size() - 1);
+ }
+ TupleBatch batch = getBatch(row);
+ return batch.getTuple(row);
+ }
+ /**
+ * Get the batch containing the given row.
+ * NOTE: the returned batch may be empty or may begin with a row other
+ * than the one specified.
+ * @param row
+ * @return
+ * @throws MetaMatrixComponentException
+ */
public TupleBatch getBatch(int row) throws MetaMatrixComponentException {
+ TupleBatch result = null;
if (row > rowCount) {
- TupleBatch batch = new TupleBatch(rowCount + 1, new List[] {});
- if (isFinal) {
- batch.setTerminationFlag(true);
+ result = new TupleBatch(rowCount + 1, new List[] {});
+ } else if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
+ result = new TupleBatch(rowCount - this.batchBuffer.size() + 1, batchBuffer);
+ if (forwardOnly) {
+ this.batchBuffer = null;
}
- return batch;
+ } else {
+ if (this.batchBuffer != null && !this.batchBuffer.isEmpty()) {
+ //this is just a sanity check to ensure we're not holding too many
+ //hard references to batches.
+ saveBatch(isFinal, false);
+ }
+ Map.Entry<Integer, BatchManager.ManagedBatch> entry = batches.floorEntry(row);
+ Assertion.isNotNull(entry);
+ BatchManager.ManagedBatch batch = entry.getValue();
+ result = batch.getBatch(!forwardOnly, types);
+ if (lobs && result.getDataTypes() == null) {
+ correctLobReferences(result.getAllTuples());
+ }
+ result.setDataTypes(types);
+ if (forwardOnly) {
+ batches.remove(entry.getKey());
+ }
}
- if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
- return new TupleBatch(rowCount - this.batchBuffer.size() + 1, batchBuffer);
+ if (isFinal && result.getEndRow() == rowCount) {
+ result.setTerminationFlag(true);
}
- if (this.batchBuffer != null && !this.batchBuffer.isEmpty()) {
- saveBatch(isFinal);
- }
- Map.Entry<Integer, ManagedBatch> entry = batches.floorEntry(row);
- Assertion.isNotNull(entry);
- ManagedBatch batch = entry.getValue();
- TupleBatch result = batch.getBatch();
- if (result != null) {
- return result;
- }
- try {
- byte[] bytes = new byte[batch.getLength()];
- this.store.readFully(batch.getOffset(), bytes, 0, bytes.length);
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
-
- result = new TupleBatch();
- result.setDataTypes(types);
- result.readExternal(ois);
- } catch(IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", tupleSourceID)); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", tupleSourceID)); //$NON-NLS-1$
- }
- if (lobs) {
- correctLobReferences(result.getAllTuples());
- }
- batch.setBatchReference(result);
return result;
}
public void remove() {
- int count = this.referenceCount.getAndDecrement();
- if (count == 0) {
- if (this.store != null) {
- this.store.remove();
- this.store = null;
- }
- if (this.batchBuffer != null) {
- this.batchBuffer = null;
- }
- this.batches.clear();
+ if (!removed) {
+ this.manager.remove();
+ purge();
}
}
- public boolean addReference() {
- int count = this.referenceCount.addAndGet(1);
- return count > 1;
- }
-
public int getRowCount() {
return rowCount;
}
@@ -393,6 +385,10 @@
}
}
+ public void setForwardOnly(boolean forwardOnly) {
+ this.forwardOnly = forwardOnly;
+ }
+
/**
* Create a new iterator for this buffer
* @return
@@ -403,11 +399,11 @@
@Override
public String toString() {
- return this.tupleSourceID.toString();
+ return this.tupleSourceID;
}
public boolean isRemoved() {
- return this.referenceCount.get() <= 0;
+ return removed;
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -60,5 +60,11 @@
*/
void closeSource()
throws MetaMatrixComponentException;
+
+ /**
+ * Returns an estimate of the number of rows that can be read without blocking.
+ * @return
+ */
+ int available();
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,18 +22,38 @@
package com.metamatrix.common.buffer.impl;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
-import java.util.ListIterator;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
import javax.xml.transform.Source;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BatchManager;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.StorageManager;
+import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleBuffer;
+import com.metamatrix.common.buffer.BatchManager.ManagedBatch;
+import com.metamatrix.common.buffer.FileStore.FileStoreOutputStream;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.InputStreamFactory;
@@ -47,30 +67,286 @@
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.xml.XMLUtil;
-import com.metamatrix.query.sql.symbol.Expression;
/**
* <p>Default implementation of BufferManager.</p>
- * Responsible for creating/tracking TupleBuffers and providing access to the StorageManager
+ * Responsible for creating/tracking TupleBuffers and providing access to the StorageManager.
+ * </p>
+ * The buffering strategy attempts to purge batches from the least recently used TupleBuffer
+ * from before (which wraps around circularly) the last used batch. This attempts to compensate
+ * for our tendency to read buffers in a forward manner. If our processing algorithms are changed
+ * to use alternating ascending/descending access, then the buffering approach could be replaced
+ * with a simple LRU.
+ *
+ * TODO: allow for cached stores to use lru - (result set/mat view)
*/
public class BufferManagerImpl implements BufferManager, StorageManager {
+
+ private static final int IO_BUFFER_SIZE = 1 << 14;
+
+ /**
+ * Holder for active batches
+ */
+ private class TupleBufferInfo {
+ TreeMap<Integer, ManagedBatchImpl> batches = new TreeMap<Integer, ManagedBatchImpl>();
+ Integer lastUsed = null;
+
+ ManagedBatchImpl removeBatch(int row) {
+ ManagedBatchImpl result = batches.remove(row);
+ if (result != null) {
+ activeBatchCount--;
+ if (toPersistCount > 0) {
+ toPersistCount--;
+ }
+ }
+ return result;
+ }
+ }
+
+ private final class ManagedBatchImpl implements ManagedBatch {
+ final private String id;
+ final private FileStore store;
+
+ private long offset = -1;
+ private boolean persistent;
+ private volatile TupleBatch pBatch;
+ private Reference<TupleBatch> batchReference;
+ private int beginRow;
+
+ public ManagedBatchImpl(String id, FileStore store, TupleBatch batch) throws MetaMatrixComponentException {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Add batch to BufferManager", batchAdded.incrementAndGet()); //$NON-NLS-1$
+ this.id = id;
+ this.store = store;
+ this.pBatch = batch;
+ this.beginRow = batch.getBeginRow();
+ addToCache(false);
+ persistBatchReferences();
+ }
+ private void addToCache(boolean update) {
+ synchronized (activeBatches) {
+ activeBatchCount++;
+ TupleBufferInfo tbi = null;
+ if (update) {
+ tbi = activeBatches.remove(this.id);
+ } else {
+ tbi = activeBatches.get(this.id);
+ }
+ if (tbi == null) {
+ tbi = new TupleBufferInfo();
+ update = true;
+ }
+ if (update) {
+ activeBatches.put(this.id, tbi);
+ }
+ Assertion.isNull(tbi.batches.put(this.beginRow, this));
+ }
+ }
+
+ @Override
+ public TupleBatch getBatch(boolean cache, String[] types) throws MetaMatrixComponentException {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readAttempts.incrementAndGet(), "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
+ synchronized (activeBatches) {
+ TupleBufferInfo tbi = activeBatches.remove(this.id);
+ if (tbi != null) {
+ boolean put = true;
+ if (!cache) {
+ tbi.removeBatch(this.beginRow);
+ if (tbi.batches.isEmpty()) {
+ put = false;
+ }
+ }
+ if (put) {
+ tbi.lastUsed = this.beginRow;
+ activeBatches.put(this.id, tbi);
+ }
+ }
+ }
+ synchronized (this) {
+ if (this.batchReference != null && this.pBatch == null) {
+ TupleBatch result = this.batchReference.get();
+ if (result != null) {
+ if (!cache) {
+ softCache.remove(this);
+ this.batchReference.clear();
+ }
+ referenceHit.getAndIncrement();
+ return result;
+ }
+ }
+
+ TupleBatch batch = this.pBatch;
+ if (batch != null){
+ return batch;
+ }
+ }
+ persistBatchReferences();
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Reading batch from disk", readCount.incrementAndGet()); //$NON-NLS-1$
+ synchronized (this) {
+ try {
+ ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(store.createInputStream(this.offset), IO_BUFFER_SIZE));
+ TupleBatch batch = new TupleBatch();
+ batch.setDataTypes(types);
+ batch.readExternal(ois);
+ batch.setDataTypes(null);
+ if (cache) {
+ this.pBatch = batch;
+ addToCache(true);
+ }
+ return batch;
+ } catch(IOException e) {
+ throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public void persistBatchReferences() throws MetaMatrixComponentException {
+ ManagedBatchImpl mb = null;
+ boolean createSoft = false;
+ /*
+ * If we are over our limit, collect half of the batches.
+ */
+ synchronized (activeBatches) {
+ if (activeBatchCount > reserveBatches && toPersistCount == 0) {
+ toPersistCount = activeBatchCount / 2;
+ }
+ }
+ while (true) {
+ synchronized (activeBatches) {
+ if (activeBatchCount == 0 || toPersistCount == 0) {
+ toPersistCount = 0;
+ break;
+ }
+ Iterator<TupleBufferInfo> iter = activeBatches.values().iterator();
+ TupleBufferInfo tbi = iter.next();
+ Map.Entry<Integer, ManagedBatchImpl> entry = null;
+ if (tbi.lastUsed != null) {
+ entry = tbi.batches.floorEntry(tbi.lastUsed - 1);
+ }
+ if (entry == null) {
+ entry = tbi.batches.pollLastEntry();
+ } else {
+ createSoft = true;
+ tbi.batches.remove(entry.getKey());
+ }
+ if (tbi.batches.isEmpty()) {
+ iter.remove();
+ }
+ activeBatchCount--;
+ toPersistCount--;
+ mb = entry.getValue();
+ }
+ persist(createSoft, mb);
+ }
+ synchronized (softCache) {
+ if (softCache.size() > reserveBatches) {
+ Iterator<ManagedBatchImpl> iter = softCache.iterator();
+ mb = iter.next();
+ iter.remove();
+ }
+ }
+ persist(false, mb);
+ }
+
+ private void persist(boolean createSoft, ManagedBatchImpl mb)
+ throws MetaMatrixComponentException {
+ try {
+ if (mb != null) {
+ mb.persist(createSoft);
+ }
+ } catch (MetaMatrixComponentException e) {
+ if (mb == this) {
+ throw e;
+ }
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, e, "Error persisting batch, attempts to read that batch later will result in an exception"); //$NON-NLS-1$
+ }
+ }
+
+ public synchronized void persist(boolean createSoft) throws MetaMatrixComponentException {
+ try {
+ TupleBatch batch = pBatch;
+ if (batch != null) {
+ if (!persistent) {
+ LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, "Writing batch to disk", writeCount.incrementAndGet()); //$NON-NLS-1$
+ synchronized (store) {
+ offset = store.getLength();
+ FileStoreOutputStream fsos = store.createOutputStream(IO_BUFFER_SIZE);
+ ObjectOutputStream oos = new ObjectOutputStream(fsos);
+ batch.writeExternal(oos);
+ oos.flush();
+ oos.close();
+ fsos.flushBuffer();
+ }
+ }
+ if (createSoft) {
+ this.batchReference = new SoftReference<TupleBatch>(batch);
+ softCache.add(this);
+ } else {
+ this.batchReference = new WeakReference<TupleBatch>(batch);
+ }
+ }
+ } catch (IOException e) {
+ throw new MetaMatrixComponentException(e);
+ } finally {
+ persistent = true;
+ pBatch = null;
+ }
+ }
+
+ public void remove() {
+ synchronized (activeBatches) {
+ TupleBufferInfo tbi = activeBatches.get(this.id);
+ if (tbi != null && tbi.removeBatch(this.beginRow) != null && tbi.batches.isEmpty()) {
+ activeBatches.remove(this.id);
+ }
+ }
+ softCache.remove(this);
+ pBatch = null;
+ if (batchReference != null) {
+ batchReference.clear();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "ManagedBatch " + id + " " + pBatch; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
// Configuration
private int connectorBatchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
private int processorBatchSize = BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE;
private int maxProcessingBatches = BufferManager.DEFAULT_MAX_PROCESSING_BATCHES;
+ private int reserveBatches = BufferManager.DEFAULT_RESERVE_BUFFERS;
+ private int maxReserveBatches = BufferManager.DEFAULT_RESERVE_BUFFERS;
+ private ReentrantLock lock = new ReentrantLock(true);
+ private Condition batchesFreed = lock.newCondition();
+
+ private int toPersistCount = 0;
+ private int activeBatchCount = 0;
+ private Map<String, TupleBufferInfo> activeBatches = new LinkedHashMap<String, TupleBufferInfo>();
+ private Set<ManagedBatchImpl> softCache = Collections.synchronizedSet(new LinkedHashSet<ManagedBatchImpl>());
+
private StorageManager diskMgr;
- private AtomicLong currentTuple = new AtomicLong(0);
-
+ private AtomicLong currentTuple = new AtomicLong();
+ private AtomicInteger batchAdded = new AtomicInteger();
+ private AtomicInteger readCount = new AtomicInteger();
+ private AtomicInteger writeCount = new AtomicInteger();
+ private AtomicInteger readAttempts = new AtomicInteger();
+ private AtomicInteger referenceHit = new AtomicInteger();
+
public int getMaxProcessingBatches() {
return maxProcessingBatches;
}
public void setMaxProcessingBatches(int maxProcessingBatches) {
- this.maxProcessingBatches = maxProcessingBatches;
+ this.maxProcessingBatches = Math.max(2, maxProcessingBatches);
}
/**
@@ -112,11 +388,32 @@
}
@Override
- public TupleBuffer createTupleBuffer(List elements, String groupName,
- TupleSourceType tupleSourceType)
- throws MetaMatrixComponentException {
- String newID = String.valueOf(this.currentTuple.getAndIncrement());
- TupleBuffer tupleBuffer = new TupleBuffer(this, newID, elements, getTypeNames(elements), getProcessorBatchSize());
+ public TupleBuffer createTupleBuffer(final List elements, String groupName,
+ TupleSourceType tupleSourceType) {
+ final String newID = String.valueOf(this.currentTuple.getAndIncrement());
+
+ BatchManager batchManager = new BatchManager() {
+ private FileStore store;
+
+ @Override
+ public ManagedBatch createManagedBatch(TupleBatch batch)
+ throws MetaMatrixComponentException {
+ if (this.store == null) {
+ this.store = createFileStore(newID);
+ this.store.setCleanupReference(this);
+ }
+ return new ManagedBatchImpl(newID, store, batch);
+ }
+
+ @Override
+ public void remove() {
+ if (this.store != null) {
+ this.store.remove();
+ this.store = null;
+ }
+ }
+ };
+ TupleBuffer tupleBuffer = new TupleBuffer(batchManager, newID, elements, getProcessorBatchSize());
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, new Object[]{"Creating TupleBuffer:", newID, "of type "+tupleSourceType}); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -132,8 +429,7 @@
}
@Override
- public void initialize(Properties props) throws MetaMatrixComponentException {
- PropertiesUtils.setBeanProperties(this, props, "metamatrix.buffer"); //$NON-NLS-1$
+ public void initialize() throws MetaMatrixComponentException {
DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
@Override
public XMLType transform(Source value) {
@@ -152,23 +448,43 @@
});
}
- /**
- * Gets the data type names for each of the input expressions, in order.
- * @param expressions List of Expressions
- * @return
- * @since 4.2
- */
- private static String[] getTypeNames(List expressions) {
- if (expressions == null) {
- return null;
+ @Override
+ public void releaseBuffers(int count) {
+ lock.lock();
+ try {
+ this.reserveBatches += count;
+ batchesFreed.signalAll();
+ } finally {
+ lock.unlock();
}
- String[] types = new String[expressions.size()];
- for (ListIterator i = expressions.listIterator(); i.hasNext();) {
- Expression expr = (Expression)i.next();
- types[i.previousIndex()] = DataTypeManager.getDataTypeName(expr.getType());
- }
- return types;
+ }
+
+ @Override
+ public int reserveBuffers(int count, boolean wait) throws MetaMatrixComponentException {
+ lock.lock();
+ try {
+ while (wait && count > this.reserveBatches && this.reserveBatches < this.maxReserveBatches / 2) {
+ try {
+ batchesFreed.await();
+ } catch (InterruptedException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ }
+ this.reserveBatches -= count;
+ if (this.reserveBatches >= 0) {
+ return count;
+ }
+ int result = count + this.reserveBatches;
+ this.reserveBatches = 0;
+ return result;
+ } finally {
+ lock.unlock();
+ }
}
+
+ public void setMaxReserveBatches(int maxReserveBatches) {
+ this.maxReserveBatches = maxReserveBatches;
+ }
public void shutdown() {
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -29,15 +29,12 @@
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Properties;
import java.util.TreeMap;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.util.LogConstants;
@@ -47,9 +44,9 @@
* Implements file storage that automatically splits large files and limits the number of open files.
*/
public class FileStorageManager implements StorageManager {
+
+ private static final String FILE_PREFIX = "b_"; //$NON-NLS-1$
- private static final String FILE_PREFIX = "b_"; //$NON-NLS-1$
-
private class FileInfo {
private File file;
private RandomAccessFile fileData; // may be null if not open
@@ -112,7 +109,7 @@
}
}
- public synchronized long writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
+ public void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
Map.Entry<Long, FileInfo> entry = this.storageFiles.lastEntry();
boolean createNew = false;
FileInfo fileInfo = null;
@@ -138,7 +135,6 @@
fileAccess.setLength(pointer + length);
fileAccess.seek(pointer);
fileAccess.write(bytes, offset, length);
- return fileOffset + pointer;
} catch(IOException e) {
throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
} finally {
@@ -183,8 +179,7 @@
* @see com.metamatrix.common.buffer.BufferManager#MAX_OPEN_FILES
* @see com.metamatrix.common.buffer.BufferManager#MAX_FILE_SIZE
*/
- public void initialize(Properties props) throws MetaMatrixComponentException {
- this.directory = props.getProperty(BufferManager.BUFFER_STORAGE_DIRECTORY);
+ public void initialize() throws MetaMatrixComponentException {
if(this.directory == null) {
throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.no_directory")); //$NON-NLS-1$
}
@@ -198,14 +193,24 @@
} else if(! dirFile.mkdirs()) {
throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.error_creating", dirFile.getAbsoluteFile())); //$NON-NLS-1$
}
-
- // Set up max number of open file descriptors
- maxOpenFiles = PropertiesUtils.getIntProperty(props, BufferManager.MAX_OPEN_FILES, 32);
-
- // Set the max file size
- maxFileSize = PropertiesUtils.getIntProperty(props, BufferManager.MAX_FILE_SIZE, 2048) * 1024L * 1024L; // Multiply by 1MB
}
+ public void setMaxFileSize(long maxFileSize) {
+ this.maxFileSize = maxFileSize * 1024L * 1024L;
+ }
+
+ void setMaxFileSizeDirect(long maxFileSize) {
+ this.maxFileSize = maxFileSize;
+ }
+
+ public void setMaxOpenFiles(int maxOpenFiles) {
+ this.maxOpenFiles = maxOpenFiles;
+ }
+
+ public void setStorageDirectory(String directory) {
+ this.directory = directory;
+ }
+
File createFile(String name, int fileNumber) throws MetaMatrixComponentException {
try {
File storageFile = File.createTempFile(FILE_PREFIX + name + "_" + String.valueOf(fileNumber) + "_", null, this.dirFile); //$NON-NLS-1$ //$NON-NLS-2$
Modified: branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -31,30 +31,23 @@
public class MemoryStorageManager implements StorageManager {
- /**
- * @see StorageManager#initialize(Properties)
- */
- public void initialize(Properties props) throws MetaMatrixComponentException {
+ public void initialize() throws MetaMatrixComponentException {
}
@Override
public FileStore createFileStore(String name) {
return new FileStore() {
private ByteBuffer buffer = ByteBuffer.allocate(2 << 15);
- private int end;
@Override
- public synchronized long writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
- if (end + length > buffer.capacity()) {
+ public void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
+ if (getLength() + length > buffer.capacity()) {
ByteBuffer newBuffer = ByteBuffer.allocate(buffer.capacity() * 2 + length);
newBuffer.put(buffer);
buffer = newBuffer;
}
- buffer.position(end);
+ buffer.position((int)getLength());
buffer.put(bytes, offset, length);
- long result = end;
- end += length;
- return result;
}
@Override
@@ -65,12 +58,12 @@
@Override
public synchronized int readDirect(long fileOffset, byte[] b, int offset, int length)
throws MetaMatrixComponentException {
- if (fileOffset >= end) {
+ if (fileOffset >= getLength()) {
return -1;
}
int position = (int)fileOffset;
buffer.position(position);
- length = Math.min(length, end - position);
+ length = Math.min(length, (int)getLength() - position);
buffer.get(b, offset, length);
return length;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -39,6 +39,8 @@
// treat a double quoted variable as variable instead of string
public boolean ansiQuotedIdentifiers=Boolean.valueOf(System.getProperty("teiid.ansi_quoted_identifiers", Boolean.TRUE.toString())).booleanValue(); //$NON-NLS-1$
+ public boolean cache;
+
public ParseInfo() { }
public boolean useAnsiQuotedIdentifiers() {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -116,6 +116,7 @@
QueryParserException qpe = null;
try {
Command result = parseCommandWithParser(sql, parseInfo);
+ result.setCache(parseInfo.cache);
return result;
} catch (QueryParserException e) {
qpe = e;
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -31,6 +31,7 @@
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.ReservedWords;
+import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.FromClause;
import com.metamatrix.query.sql.lang.JoinType;
import com.metamatrix.query.sql.lang.Option;
@@ -157,22 +158,33 @@
}
void setFromClauseOptions(Token groupID, FromClause fromClause){
- Token optToken = groupID.specialToken;
+ String[] parts = getComment(groupID);
+
+ for (int i = 0; i < parts.length; i++) {
+ if (parts[i].equalsIgnoreCase(Option.OPTIONAL)) {
+ fromClause.setOptional(true);
+ }
+ }
+ }
+
+ private String[] getComment(Token t) {
+ Token optToken = t.specialToken;
if (optToken == null) {
- return;
+ return new String[0];
}
String hint = optToken.image.substring(2, optToken.image.length() - 2);
String[] parts = hint.split("\\s"); //$NON-NLS-1$
+ return parts;
+ }
+
+ void setQueryCacheOption(Token t, ParseInfo p) {
+ String[] parts = getComment(t);
- HashSet<String> set = new HashSet<String>();
-
for (int i = 0; i < parts.length; i++) {
- set.add(parts[i].toLowerCase());
+ if (parts[i].equalsIgnoreCase(Command.CACHE)) {
+ p.cache = true;
+ }
}
-
- if (set.contains(Option.OPTIONAL)) {
- fromClause.setOptional(true);
- }
}
/**
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -51,7 +51,7 @@
}
public interface BatchHandler {
- void batchProduced(TupleBatch batch) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+ boolean batchProduced(TupleBatch batch) throws MetaMatrixProcessingException, MetaMatrixComponentException;
}
private BatchProducer sourceNode;
@@ -59,7 +59,6 @@
private boolean done = false;
private TupleBuffer buffer;
- private boolean collectedAny;
public BatchCollector(BatchProducer sourceNode, TupleBuffer buffer) {
this.sourceNode = sourceNode;
@@ -91,34 +90,22 @@
* Flush the batch by giving it to the buffer manager.
*/
private void flushBatch(TupleBatch batch) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ boolean add = true;
+ if (this.batchHandler != null && (batch.getRowCount() > 0 || batch.getTerminationFlag())) {
+ add = this.batchHandler.batchProduced(batch);
+ }
// Add batch
if(batch.getRowCount() > 0) {
- for (List tuple : batch.getAllTuples()) {
- buffer.addTuple(tuple);
- }
- collectedAny = true;
+ buffer.addTupleBatch(batch, add);
}
- if (this.batchHandler != null && (batch.getRowCount() > 0 || batch.getTerminationFlag())) {
- this.batchHandler.batchProduced(batch);
- }
}
public void setBatchHandler(BatchHandler batchHandler) {
this.batchHandler = batchHandler;
}
- public boolean collectedAny() {
- boolean result = collectedAny;
- collectedAny = false;
- return result;
- }
-
public int getRowCount() {
return buffer.getRowCount();
}
- public boolean isDone() {
- return done;
- }
-
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -28,13 +28,23 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.IndexedTupleSource;
import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.query.processor.BatchCollector.BatchProducer;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-public class BatchIterator implements
- IndexedTupleSource {
+/**
+ * A BatchIterator provides an iterator interface to a {@link BatchProducer}.
+ * By setting {@link #setBuffer(TupleBuffer)},
+ * the iterator can copy on read into a {@link TupleBuffer} for repeated reading.
+ *
+ * Note that the saveOnMark buffering only lasts until the next mark is set.
+ */
+public class BatchIterator implements IndexedTupleSource {
private final BatchProducer source;
+ private boolean saveOnMark;
+ private TupleBuffer buffer;
+ private IndexedTupleSource bufferedTs;
public BatchIterator(BatchProducer source) {
this.source = source;
@@ -44,15 +54,33 @@
private int currentRow = 1;
private TupleBatch currentBatch;
private List currentTuple;
-
+ private int bufferedIndex;
+ private boolean mark;
+
+ @Override
public boolean hasNext() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
- if (done) {
+
+ if (done && this.bufferedTs == null) {
return false;
}
while (currentTuple == null) {
if (currentBatch == null) {
+ if (this.bufferedTs != null) {
+ if (this.currentRow <= this.bufferedIndex) {
+ this.bufferedTs.setPosition(currentRow++);
+ this.currentTuple = this.bufferedTs.nextTuple();
+ return true;
+ }
+ if (done) {
+ return false;
+ }
+ }
currentBatch = this.source.nextBatch();
+ if (buffer != null && !saveOnMark) {
+ buffer.addTupleBatch(currentBatch, true);
+ bufferedIndex = currentBatch.getEndRow();
+ }
}
if (currentBatch.getEndRow() >= currentRow) {
@@ -68,9 +96,18 @@
return true;
}
+ public void setBuffer(TupleBuffer buffer, boolean saveOnMark) {
+ this.buffer = buffer;
+ this.bufferedTs = this.buffer.createIndexedTupleSource();
+ this.saveOnMark = saveOnMark;
+ }
+
@Override
public void closeSource() throws MetaMatrixComponentException {
-
+ if (this.buffer != null) {
+ this.buffer.remove();
+ this.buffer = null;
+ }
}
@Override
@@ -86,15 +123,32 @@
}
List result = currentTuple;
currentTuple = null;
+ if (mark && saveOnMark && this.currentRow - 1 > this.buffer.getRowCount()) {
+ this.buffer.addTupleBatch(new TupleBatch(this.currentRow - 1, new List[] {result}), true);
+ this.bufferedIndex = this.currentRow - 1;
+ }
return result;
}
public void reset() {
+ if (this.bufferedTs != null) {
+ mark = false;
+ this.bufferedTs.reset();
+ this.currentRow = this.bufferedTs.getCurrentIndex();
+ return;
+ }
throw new UnsupportedOperationException();
}
public void mark() {
- //does nothing
+ if (this.bufferedTs != null) {
+ this.bufferedTs.mark();
+ if (saveOnMark && this.currentRow > this.bufferedIndex) {
+ this.buffer.purge();
+ this.bufferedIndex = 0;
+ }
+ }
+ mark = true;
}
@Override
@@ -103,17 +157,30 @@
}
public void setPosition(int position) {
- if (position == this.currentRow) {
- return;
+ if (this.bufferedTs != null) {
+ this.bufferedTs.setPosition(position);
+ this.currentRow = position;
}
- if (position < this.currentRow && (this.currentBatch == null || position < this.currentBatch.getBeginRow())) {
+ if (this.currentBatch == null && position < this.currentRow) {
throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$
- }
- this.currentRow = position;
+ }
+ this.currentRow = position;
this.currentTuple = null;
- if (currentBatch.getEndRow() < currentRow) {
+ if (this.currentBatch == null || !this.currentBatch.containsRow(position)) {
this.currentBatch = null;
- }
+ }
}
+ @Override
+ public int available() {
+ if (this.currentRow <= this.bufferedIndex) {
+ this.bufferedTs.setPosition(this.currentRow);
+ return this.bufferedTs.available();
+ }
+ if (currentBatch != null) {
+ return currentBatch.getEndRow() - currentRow + 1;
+ }
+ return 0;
+ }
+
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -67,4 +67,12 @@
public void closeSource() {
}
+
+ @Override
+ public int available() {
+ if (tuples.hasNext()) {
+ return 1;
+ }
+ return 0;
+ }
}
\ No newline at end of file
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -32,6 +32,7 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.util.LogConstants;
@@ -41,6 +42,12 @@
public class QueryProcessor implements BatchProducer {
+ public static class ExpiredTimeSliceException extends MetaMatrixRuntimeException {
+
+ }
+
+ private static ExpiredTimeSliceException EXPIRED_TIME_SLICE = new ExpiredTimeSliceException();
+
public interface ProcessorFactory {
QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException;
}
@@ -54,7 +61,6 @@
private volatile boolean requestCanceled = false;
private static final int DEFAULT_WAIT = 50;
private boolean processorClosed = false;
- private volatile int highestRow;
private boolean nonBlocking = false;
@@ -93,16 +99,19 @@
while (true) {
try {
return nextBatchDirect();
+ } catch (ExpiredTimeSliceException e) {
+ if (!nonBlocking) {
+ throw e;
+ }
} catch (BlockedException e) {
- if (nonBlocking) {
- try {
- Thread.sleep(DEFAULT_WAIT);
- } catch (InterruptedException err) {
- throw new MetaMatrixComponentException(err);
- }
- continue;
+ if (!nonBlocking) {
+ throw e;
}
- throw e;
+ try {
+ Thread.sleep(DEFAULT_WAIT);
+ } catch (InterruptedException err) {
+ throw new MetaMatrixComponentException(err);
+ }
}
}
}
@@ -132,7 +141,6 @@
throw new MetaMatrixProcessingException("Query timed out"); //$NON-NLS-1$
}
result = processPlan.nextBatch();
- this.highestRow = result.getEndRow();
if(result.getTerminationFlag()) {
done = true;
@@ -164,7 +172,7 @@
closeProcessing();
}
if (result == null) {
- throw BlockedException.INSTANCE; //expired timeslice
+ throw EXPIRED_TIME_SLICE;
}
return result;
}
@@ -202,10 +210,6 @@
this.requestCanceled = true;
}
- public int getHighestRow() {
- return highestRow;
- }
-
public BatchCollector createBatchCollector() throws MetaMatrixComponentException {
return new BatchCollector(this, this.bufferMgr.createTupleBuffer(this.processPlan.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR));
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -106,6 +106,7 @@
if(collectionBuffer == null) {
collectionBuffer = mgr.createTupleBuffer(elements, groupName, TupleSourceType.PROCESSOR);
+ collectionBuffer.setForwardOnly(true);
}
List row = new ArrayList(1);
@@ -126,6 +127,7 @@
// Sort
sortUtility = new SortUtility(collectionBuffer.createIndexedTupleSource(), elements, sortTypes, Mode.DUP_REMOVE, mgr, groupName);
TupleBuffer sorted = sortUtility.sort();
+ sorted.setForwardOnly(true);
try {
// Add all input to proxy
TupleSource sortedSource = sorted.createIndexedTupleSource();
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -23,8 +23,8 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -32,6 +32,7 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.buffer.TupleSource;
@@ -44,12 +45,14 @@
import com.metamatrix.query.function.aggregate.Min;
import com.metamatrix.query.function.aggregate.NullFilter;
import com.metamatrix.query.function.aggregate.Sum;
+import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.relational.SortUtility.Mode;
import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.util.CommandContext;
public class GroupingNode extends RelationalNode {
@@ -65,12 +68,12 @@
// Sort phase
private SortUtility sortUtility;
- private TupleBuffer sortedID;
+ private TupleBuffer sortBuffer;
private TupleSource groupTupleSource;
-
+
// Group phase
- private Map expressionMap; // Index map for all collected expressions (Expression -> index in collectedExpressions)
private AggregateFunction[] functions;
+ private int[] aggProjectionIndexes;
private List lastRow;
private List currentGroupTuple;
@@ -86,16 +89,18 @@
super.reset();
phase = COLLECTION;
- elementMap = null;
- collectedExpressions = null;
sortUtility = null;
- sortedID = null;
+ sortBuffer = null;
- expressionMap = null;
- functions = null;
lastRow = null;
currentGroupTuple = null;
+
+ if (this.functions != null) {
+ for (AggregateFunction function : this.functions) {
+ function.reset();
+ }
+ }
}
public void setRemoveDuplicates(boolean removeDuplicates) {
@@ -112,37 +117,24 @@
public void setGroupingElements(List groupingElements) {
this.sortElements = groupingElements;
if(groupingElements != null) {
- sortTypes = new ArrayList(groupingElements.size());
- for(int i=0; i<groupingElements.size(); i++) {
- sortTypes.add(Boolean.valueOf(OrderBy.ASC));
- }
+ sortTypes = Collections.nCopies(groupingElements.size(), Boolean.valueOf(OrderBy.ASC));
}
}
- public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
-
- super.open();
-
+ @Override
+ public void initialize(CommandContext context, BufferManager bufferManager,
+ ProcessorDataManager dataMgr) {
+ super.initialize(context, bufferManager, dataMgr);
+
+ if (this.functions != null) {
+ return;
+ }
+
// Incoming elements and lookup map for evaluating expressions
List sourceElements = this.getChildren()[0].getElements();
this.elementMap = createLookupMap(sourceElements);
-
- // Determine expressions to build (all grouping expressions + expressions used by aggregates)
- collectExpressions();
- initializeFunctionAccumulators();
- }
-
- /**
- * Collect a list of all expressions that must be evaluated during collection. This
- * will include all the expressions being sorted on AND all expressions used within
- * aggregate functions.
- *
- * @since 4.2
- */
- private void collectExpressions() {
- // List should contain all grouping columns / expressions as we need those for sorting
+ // List should contain all grouping columns / expressions as we need those for sorting
if(this.sortElements != null) {
this.collectedExpressions = new ArrayList(this.sortElements.size() + getElements().size());
this.collectedExpressions.addAll(sortElements);
@@ -150,27 +142,10 @@
this.collectedExpressions = new ArrayList(getElements().size());
}
- // Also need to include all expressions used within aggregates so that we can evaluate
- // them once up front during collection rather than repeatedly during aggregate evaluation
- Iterator outputIter = getElements().iterator();
- while(outputIter.hasNext()) {
- Object outputSymbol = outputIter.next();
- if(outputSymbol instanceof AggregateSymbol) {
- AggregateSymbol agg = (AggregateSymbol) outputSymbol;
- Expression expr = agg.getExpression();
- if(expr != null && ! this.collectedExpressions.contains(expr)) {
- this.collectedExpressions.add(expr);
- }
- }
- }
-
- // Build lookup map for evaluating aggregates later
- this.expressionMap = createLookupMap(collectedExpressions);
- }
-
- private void initializeFunctionAccumulators() {
// Construct aggregate function state accumulators
functions = new AggregateFunction[getElements().size()];
+ aggProjectionIndexes = new int[getElements().size()];
+ Arrays.fill(aggProjectionIndexes, -1);
for(int i=0; i<getElements().size(); i++) {
SingleElementSymbol symbol = (SingleElementSymbol)getElements().get(i);
Class<?> outputType = symbol.getType();
@@ -181,6 +156,12 @@
if(aggSymbol.getExpression() == null) {
functions[i] = new Count();
} else {
+ int index = this.collectedExpressions.indexOf(aggSymbol.getExpression());
+ if(index == -1) {
+ index = this.collectedExpressions.size();
+ this.collectedExpressions.add(aggSymbol.getExpression());
+ }
+ aggProjectionIndexes[i] = index;
String function = aggSymbol.getAggregateFunction();
if(function.equals(ReservedWords.COUNT)) {
functions[i] = new Count();
@@ -203,6 +184,7 @@
}
} else {
functions[i] = new ConstantFunction();
+ aggProjectionIndexes[i] = this.collectedExpressions.indexOf(symbol);
}
functions[i].initialize(outputType, inputType);
}
@@ -286,6 +268,14 @@
public void closeSource() throws MetaMatrixComponentException {
}
+
+ @Override
+ public int available() {
+ if (sourceBatch != null) {
+ return sourceBatch.getEndRow() - sourceRow + 1;
+ }
+ return 0;
+ }
};
}
@@ -304,8 +294,9 @@
}
private void sortPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- this.sortedID = this.sortUtility.sort();
- this.groupTupleSource = this.sortedID.createIndexedTupleSource();
+ this.sortBuffer = this.sortUtility.sort();
+ this.sortBuffer.setForwardOnly(true);
+ this.groupTupleSource = this.sortBuffer.createIndexedTupleSource();
this.phase = GROUP;
}
@@ -328,10 +319,6 @@
List row = new ArrayList(functions.length);
for(int i=0; i<functions.length; i++) {
row.add( functions[i].getResult() );
- }
-
- // Start a new group
- for(int i=0; i<functions.length; i++) {
functions[i].reset();
}
@@ -395,15 +382,9 @@
throws MetaMatrixComponentException, ExpressionEvaluationException {
for(int i=0; i<functions.length; i++) {
- Expression expression = (SingleElementSymbol) getElements().get(i);
- if(expression instanceof AggregateSymbol) {
- expression = ((AggregateSymbol)expression).getExpression();
- }
-
Object value = null;
- if(expression != null) {
- Integer exprIndex = (Integer)expressionMap.get(expression);
- value = tuple.get(exprIndex.intValue());
+ if(aggProjectionIndexes[i] != -1) {
+ value = tuple.get(aggProjectionIndexes[i]);
}
functions[i].addInput(value);
}
@@ -411,6 +392,10 @@
public void close() throws MetaMatrixComponentException {
if (!isClosed()) {
+ if (this.sortBuffer != null) {
+ this.sortBuffer.remove();
+ this.sortBuffer = null;
+ }
super.close();
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -37,6 +37,7 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
@@ -70,6 +71,7 @@
private Criteria joinCriteria;
private Map combinedElementMap;
+ private int[] projectionIndexes;
public JoinNode(int nodeID) {
super(nodeID);
@@ -127,10 +129,13 @@
ProcessorDataManager dataMgr) {
super.initialize(context, bufferManager, dataMgr);
- // Create element lookup map for evaluating project expressions
- List combinedElements = new ArrayList(getChildren()[0].getElements());
- combinedElements.addAll(getChildren()[1].getElements());
- this.combinedElementMap = createLookupMap(combinedElements);
+ if (this.combinedElementMap == null) {
+ // Create element lookup map for evaluating project expressions
+ List combinedElements = new ArrayList(getChildren()[0].getElements());
+ combinedElements.addAll(getChildren()[1].getElements());
+ this.combinedElementMap = createLookupMap(combinedElements);
+ this.projectionIndexes = getProjectionIndexes(combinedElementMap, getElements());
+ }
}
public void open()
@@ -184,7 +189,10 @@
MetaMatrixComponentException,
MetaMatrixProcessingException {
if (state == State.LOAD_LEFT) {
- //left child was already opened by the join node
+ if (this.joinType != JoinType.JOIN_FULL_OUTER) {
+ this.joinStrategy.leftSource.setImplicitBuffer(ImplicitBuffer.NONE);
+ }
+ //left child was already opened by the join node
this.joinStrategy.loadLeft();
state = State.LOAD_RIGHT;
}
@@ -197,11 +205,6 @@
this.rightOpened = true;
}
this.joinStrategy.loadRight();
- //force buffering based upon join type - may have already happened in the strategy load methods
- this.joinStrategy.rightSource.getTupleBuffer();
- if (joinType == JoinType.JOIN_FULL_OUTER) {
- this.joinStrategy.leftSource.getTupleBuffer();
- }
state = State.EXECUTE;
}
@@ -211,7 +214,7 @@
}
List outputTuple = this.joinStrategy.nextTuple();
if(outputTuple != null) {
- List projectTuple = projectTuple(this.combinedElementMap, outputTuple, getElements());
+ List projectTuple = projectTuple(this.projectionIndexes, outputTuple);
super.addBatchRow(projectTuple);
} else {
super.terminateBatches();
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/MergeJoinStrategy.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/MergeJoinStrategy.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/MergeJoinStrategy.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,15 +22,13 @@
package com.metamatrix.query.processor.relational;
-import java.util.Collections;
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
+import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
/**
* MergeJoinStrategy supports generalized Full, Left Outer, and Inner Joins (containing non-equi join criteria) as long as there
@@ -85,8 +83,6 @@
private boolean grouping;
//load time state
- private SortUtility leftSort;
- private SortUtility rightSort;
protected SortOption processingSortLeft;
protected SortOption processingSortRight;
@@ -136,8 +132,6 @@
super.close();
this.outerState = null;
this.innerState = null;
- this.leftSort = null;
- this.rightSort = null;
}
@Override
@@ -331,33 +325,16 @@
@Override
protected void loadLeft() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
- if (this.processingSortLeft == SortOption.SORT || this.processingSortLeft == SortOption.SORT_DISTINCT) {
- if (this.leftSort == null) {
- List expressions = this.joinNode.getLeftExpressions();
- this.leftSort = new SortUtility(this.leftSource.getIterator(),
- expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), processingSortLeft == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT,
- this.joinNode.getBufferManager(), this.joinNode.getConnectionID());
- this.leftSource.markDistinct(processingSortLeft == SortOption.SORT_DISTINCT && expressions.size() == this.leftSource.getOuterVals().size());
- }
- this.leftSource.setTupleSource(leftSort.sort());
- this.leftSource.markDistinct(leftSort.isDistinct());
- }
+ this.leftSource.sort(this.processingSortLeft);
}
@Override
protected void loadRight() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
- if (this.processingSortRight == SortOption.SORT || this.processingSortRight == SortOption.SORT_DISTINCT) {
- if (this.rightSort == null) {
- List expressions = this.joinNode.getRightExpressions();
- this.rightSort = new SortUtility(this.rightSource.getIterator(),
- expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), processingSortRight == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT,
- this.joinNode.getBufferManager(), this.joinNode.getConnectionID());
- this.rightSource.markDistinct(processingSortRight == SortOption.SORT_DISTINCT && expressions.size() == this.rightSource.getOuterVals().size());
- }
- this.rightSource.setTupleSource(rightSort.sort());
- this.rightSource.markDistinct(rightSort.isDistinct());
- }
+ this.rightSource.sort(this.processingSortRight);
+ if (this.joinNode.getJoinType() != JoinType.JOIN_FULL_OUTER) {
+ this.rightSource.setImplicitBuffer(ImplicitBuffer.ON_MARK);
+ }
}
public void setProcessingSortRight(boolean processingSortRight) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -24,6 +24,10 @@
import java.util.List;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
+
/**
* Nested loop is currently implemented as a degenerate case of merge join.
*
@@ -55,6 +59,12 @@
return 0; // there are no expressions in nested loop joins, comparison is meaningless
}
+ @Override
+ protected void loadRight() throws MetaMatrixComponentException,
+ MetaMatrixProcessingException {
+ this.rightSource.setImplicitBuffer(ImplicitBuffer.FULL);
+ }
+
/**
* @see com.metamatrix.query.processor.relational.MergeJoinStrategy#toString()
*/
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -42,21 +42,10 @@
*/
public class PartitionedSortJoin extends MergeJoinStrategy {
- /**
- * This is a compromise between the max size of the smaller side
- * and effective partitioning assuming that we only want to hold
- * two batches in memory during partitioning.
- *
- * TODO: apply partitioning recursively and/or have a better mechanism
- * for buffermanager reserve/release of memory
- * (would also help the sort utility)
- */
- public static final int MAX_PARTITIONS = 8;
-
private List[] endTuples;
private List<Boolean> overlap = new ArrayList<Boolean>();
private List<Integer> endRows = new ArrayList<Integer>();
- private List<TupleBuffer> partitionIds = new ArrayList<TupleBuffer>();
+ private List<TupleBuffer> partitions = new ArrayList<TupleBuffer>();
private int currentPartition;
private IndexedTupleSource currentSource;
private SourceState sortedSource;
@@ -73,13 +62,13 @@
@Override
public void close() {
super.close();
- for (TupleBuffer tupleSourceID : this.partitionIds) {
+ for (TupleBuffer tupleSourceID : this.partitions) {
tupleSourceID.remove();
}
this.endTuples = null;
this.overlap.clear();
this.endRows.clear();
- this.partitionIds.clear();
+ this.partitions.clear();
this.currentSource = null;
this.sortedSource = null;
this.partitionedSource = null;
@@ -128,7 +117,7 @@
protected void loadRight() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
this.rightSource.getTupleBuffer();
- int maxRows = this.joinNode.getBatchSize() * MAX_PARTITIONS;
+ int maxRows = this.joinNode.getBatchSize() * getMaxProcessingBatches();
if (processingSortRight == SortOption.SORT
&& this.leftSource.getRowCount() < maxRows
&& this.leftSource.getRowCount() * 4 < this.rightSource.getRowCount()) {
@@ -161,13 +150,25 @@
}
}
}
+
+ /**
+ * Since the source to be partitioned is already loaded, then there's no
+ * chance of a blocked exception during partitioning, so double the max.
+ *
+ * TODO: partition at the same time as the load to determine size
+ *
+ * @return
+ */
+ private int getMaxProcessingBatches() {
+ return 2 * this.joinNode.getBufferManager().getMaxProcessingBatches();
+ }
private void partitionSource(boolean left) throws MetaMatrixComponentException,
MetaMatrixProcessingException {
if (partitioned) {
return;
}
- if (endTuples.length > MAX_PARTITIONS + 1) {
+ if (endTuples.length > getMaxProcessingBatches() + 1) {
if (left) {
this.processingSortLeft = SortOption.SORT;
} else {
@@ -176,13 +177,13 @@
return;
}
if (endTuples.length < 2) {
- partitionIds.add(this.partitionedSource.getTupleBuffer());
+ partitions.add(this.partitionedSource.getTupleBuffer());
} else {
- if (partitionIds.isEmpty()) {
+ if (partitions.isEmpty()) {
for (int i = 0; i < endTuples.length; i++) {
TupleBuffer tc = this.partitionedSource.createSourceTupleBuffer();
- tc.setBatchSize(Math.max(1, this.joinNode.getBatchSize()/4));
- this.partitionIds.add(tc);
+ tc.setBatchSize(Math.max(1, this.joinNode.getBatchSize()));
+ this.partitions.add(tc);
}
}
while (this.partitionedSource.getIterator().hasNext()) {
@@ -191,16 +192,18 @@
if (index < 0) {
index = -index - 1;
}
- if (index > this.partitionIds.size() -1) {
+ if (index > this.partitions.size() -1) {
continue;
}
while (index > 0 && this.overlap.get(index - 1)
&& compare(tuple, this.endTuples[index - 1], this.partitionedSource.getExpressionIndexes(), this.sortedSource.getExpressionIndexes()) == 0) {
index--;
}
- this.partitionIds.get(index).addTuple(tuple);
+ this.partitions.get(index).addTuple(tuple);
}
- this.partitionedSource.getIterator().setPosition(1);
+ for (TupleBuffer partition : this.partitions) {
+ partition.close();
+ }
}
partitioned = true;
}
@@ -214,12 +217,9 @@
if (endRows.isEmpty()) {
return null; //no rows on the sorted side
}
- while (currentPartition < partitionIds.size()) {
+ while (currentPartition < partitions.size()) {
if (currentSource == null) {
- if (!this.partitionIds.isEmpty()) {
- this.partitionIds.get(currentPartition).close();
- }
- currentSource = partitionIds.get(currentPartition).createIndexedTupleSource();
+ currentSource = partitions.get(currentPartition).createIndexedTupleSource();
}
int beginIndex = currentPartition>0?endRows.get(currentPartition - 1)+1:1;
@@ -251,7 +251,7 @@
}
}
if (matchEnd == batch.length - 1 && currentPartition < overlap.size() && overlap.get(currentPartition)) {
- this.partitionIds.get(currentPartition + 1).addTuple(partitionedTuple);
+ this.partitions.get(currentPartition + 1).addTuple(partitionedTuple);
}
}
while (matchBegin <= matchEnd) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -38,8 +37,8 @@
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.Describable;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
@@ -51,7 +50,6 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
public abstract class RelationalNode implements Cloneable, Describable, BatchProducer {
@@ -338,23 +336,27 @@
/**
* Helper method for all the node that will filter the elements needed for the next node.
*/
- protected List projectTuple(Map tupleElements, List tupleValues, List projectElements)
- throws MetaMatrixComponentException {
+ protected int[] getProjectionIndexes(Map<SingleElementSymbol, Integer> tupleElements, List<SingleElementSymbol> projectElements) {
+ int[] result = new int[projectElements.size()];
- List projectedTuple = new ArrayList(projectElements.size());
+ int i = 0;
+ for (SingleElementSymbol symbol : projectElements) {
+ Integer index = tupleElements.get(symbol);
+ Assertion.isNotNull(index);
+ result[i++] = index;
+ }
- Iterator projectIter = projectElements.iterator();
- while(projectIter.hasNext()) {
- SingleElementSymbol symbol = (SingleElementSymbol) projectIter.next();
-
- Integer index = (Integer) tupleElements.get(symbol);
- if(index == null) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0035, new Object[]{symbol, tupleElements}));
- }
-
- projectedTuple.add(tupleValues.get(index.intValue()));
+ return result;
+ }
+
+ protected List<?> projectTuple(int[] indexes, List<?> tupleValues) {
+
+ List<Object> projectedTuple = new ArrayList<Object>(indexes.length);
+
+ for (int index : indexes) {
+ projectedTuple.add(tupleValues.get(index));
}
-
+
return projectedTuple;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -42,7 +42,8 @@
private Criteria criteria;
// Derived element lookup map
- private Map elementMap;
+ private Map elementMap;
+ private int[] projectionIndexes;
// State if blocked on evaluating a criteria
private boolean blockedOnCriteria = false;
@@ -78,6 +79,7 @@
// Create element lookup map for evaluating project expressions
if(this.elementMap == null) {
this.elementMap = createLookupMap(this.getChildren()[0].getElements());
+ this.projectionIndexes = getProjectionIndexes(this.elementMap, getElements());
}
}
@@ -109,7 +111,7 @@
// Evaluate criteria with tuple
try {
if(getEvaluator(this.elementMap).evaluate(this.criteria, tuple)) {
- addBatchRow( projectTuple(elementMap, tuple, getElements()) );
+ addBatchRow(projectTuple(this.projectionIndexes, tuple));
}
} catch(BlockedException e) {
// Save state and rethrow
@@ -142,6 +144,7 @@
super.copy(source, target);
target.criteria = criteria;
target.elementMap = source.elementMap;
+ target.projectionIndexes = source.projectionIndexes;
}
/*
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortNode.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -23,7 +23,6 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -32,6 +31,7 @@
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.buffer.TupleBuffer;
+import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.query.processor.BatchIterator;
import com.metamatrix.query.processor.relational.SortUtility.Mode;
import com.metamatrix.query.sql.lang.OrderBy;
@@ -44,9 +44,8 @@
private SortUtility sortUtility;
private int phase = SORT;
- private TupleBuffer outputID;
- private int rowCount = -1;
- private int outputBeginRow = 1;
+ private TupleBuffer output;
+ private TupleSource outputTs;
private static final int SORT = 2;
private static final int OUTPUT = 3;
@@ -59,9 +58,8 @@
super.reset();
sortUtility = null;
phase = SORT;
- outputID = null;
- rowCount = -1;
- outputBeginRow = 1;
+ output = null;
+ outputTs = null;
}
public void setSortElements(List sortElements, List<Boolean> sortTypes) {
@@ -81,12 +79,6 @@
this.mode = mode;
}
- public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
-
- super.open();
- }
-
public TupleBatch nextBatchDirect()
throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
if(this.phase == SORT) {
@@ -102,55 +94,45 @@
sortTypes, this.mode, getBufferManager(),
getConnectionID());
}
- this.outputID = this.sortUtility.sort();
+ this.output = this.sortUtility.sort();
+ if (this.outputTs == null) {
+ this.outputTs = this.output.createIndexedTupleSource();
+ }
this.phase = OUTPUT;
}
- private TupleBatch outputPhase() throws BlockedException, MetaMatrixComponentException {
- if (this.rowCount == -1) {
- if (this.outputID.isFinal()) {
- this.rowCount = this.outputID.getRowCount();
- } else {
- this.phase = SORT;
- }
- }
- if(this.rowCount == 0 || (this.rowCount != -1 && this.outputBeginRow > this.rowCount)) {
- TupleBatch terminationBatch = new TupleBatch(1, Collections.EMPTY_LIST);
- terminationBatch.setTerminationFlag(true);
- return terminationBatch;
- }
- int beginPinned = this.outputBeginRow;
- TupleBatch outputBatch = this.outputID.getBatch(beginPinned);
-
- this.outputBeginRow += outputBatch.getRowCount();
-
- outputBatch = removeUnrelatedColumns(outputBatch);
-
- if(rowCount != -1 && outputBeginRow > rowCount) {
- outputBatch.setTerminationFlag(true);
- }
-
- return outputBatch;
- }
-
- private TupleBatch removeUnrelatedColumns(TupleBatch outputBatch) {
- int extraColumns = this.getChildren()[0].getElements().size() - this.getElements().size();
-
- if (extraColumns > 0) {
- for (List tuple : outputBatch.getAllTuples()) {
+ private TupleBatch outputPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ if (!this.output.isFinal()) {
+ this.phase = SORT;
+ } else {
+ this.output.setForwardOnly(true);
+ }
+ List<?> tuple = null;
+ try {
+ while ((tuple = this.outputTs.nextTuple()) != null) {
+ //resize to remove unrelated columns
addBatchRow(tuple.subList(0, this.getElements().size()));
+ if (this.isBatchFull()) {
+ return pullBatch();
+ }
}
- outputBatch = pullBatch();
+ } catch (BlockedException e) {
+ if (this.hasPendingRows()) {
+ return this.pullBatch();
+ }
+ throw e;
}
- return outputBatch;
- }
+ this.terminateBatches();
+ return this.pullBatch();
+ }
public void close() throws MetaMatrixComponentException {
if (!isClosed()) {
super.close();
- if(this.outputID != null) {
- this.outputID.remove();
- this.outputID = null;
+ if(this.output != null) {
+ this.output.remove();
+ this.output = null;
+ this.outputTs = null;
}
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -23,9 +23,11 @@
package com.metamatrix.query.processor.relational;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
+import java.util.TreeSet;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -35,7 +37,10 @@
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.buffer.TupleSource;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
@@ -61,17 +66,23 @@
private class SortedSublist implements Comparable<SortedSublist> {
List<?> tuple;
int index;
- boolean duplicate;
IndexedTupleSource its;
+ int limit = Integer.MAX_VALUE;
@Override
public int compareTo(SortedSublist o) {
- return comparator.compare(this.tuple, o.tuple);
+ //reverse the comparison, so that removal of the lowest is a low cost operation
+ return -comparator.compare(this.tuple, o.tuple);
}
+
+ @Override
+ public String toString() {
+ return index + " " + tuple; //$NON-NLS-1$
+ }
}
//constructor state
- private TupleSource sourceID;
+ private TupleSource source;
private Mode mode;
private BufferManager bufferManager;
private String groupName;
@@ -83,19 +94,22 @@
private int phase = INITIAL_SORT;
private List<TupleBuffer> activeTupleBuffers = new ArrayList<TupleBuffer>();
private int masterSortIndex;
+
+ private int collected;
// Phase constants for readability
private static final int INITIAL_SORT = 1;
private static final int MERGE = 2;
private static final int DONE = 3;
+ private Collection<List<?>> workingTuples;
public SortUtility(TupleSource sourceID, List sortElements, List<Boolean> sortTypes, Mode mode, BufferManager bufferMgr,
String groupName) {
- this.sourceID = sourceID;
+ this.source = sourceID;
this.mode = mode;
this.bufferManager = bufferMgr;
this.groupName = groupName;
- this.schema = this.sourceID.getSchema();
+ this.schema = this.source.getSchema();
int distinctIndex = sortElements != null? sortElements.size() - 1:0;
if (mode != Mode.SORT) {
if (sortElements == null) {
@@ -144,7 +158,9 @@
}
private TupleBuffer createTupleBuffer() throws MetaMatrixComponentException {
- return bufferManager.createTupleBuffer(this.schema, this.groupName, TupleSourceType.PROCESSOR);
+ TupleBuffer tb = bufferManager.createTupleBuffer(this.schema, this.groupName, TupleSourceType.PROCESSOR);
+ tb.setForwardOnly(true);
+ return tb;
}
/**
@@ -152,108 +168,141 @@
*/
protected void initialSort() throws MetaMatrixComponentException, MetaMatrixProcessingException {
while(!doneReading) {
- List<List<?>> workingTuples = new ArrayList<List<?>>();
- int maxRows = bufferManager.getMaxProcessingBatches() * bufferManager.getProcessorBatchSize();
- while(!doneReading && workingTuples.size() < maxRows) {
- try {
- List<?> tuple = sourceID.nextTuple();
-
- if (tuple == null) {
- doneReading = true;
- break;
- }
-
- addTuple(workingTuples, tuple);
- } catch(BlockedException e) {
- if (workingTuples.isEmpty() && (mode != Mode.DUP_REMOVE || activeTupleBuffers.isEmpty())) {
- throw e; //block if no work can be performed
- }
- break;
- }
- }
-
- if(workingTuples.isEmpty()) {
- break;
- }
+ if (workingTuples == null) {
+ if (mode == Mode.SORT) {
+ workingTuples = new ArrayList<List<?>>();
+ } else {
+ workingTuples = new TreeSet<List<?>>(comparator);
+ }
+ }
+ int totalReservedBuffers = 0;
+ try {
+ int maxRows = bufferManager.getMaxProcessingBatches() * bufferManager.getProcessorBatchSize();
+ while(!doneReading) {
+ //attempt to reserve more working memory if there are additional rows available before blocking
+ if (workingTuples.size() == maxRows) {
+ if (source.available() < 1) {
+ break;
+ }
+ int reserved = bufferManager.reserveBuffers(1, false);
+ if (reserved == 0) {
+ break;
+ }
+ totalReservedBuffers += 1;
+ maxRows += bufferManager.getProcessorBatchSize();
+ }
+ try {
+ if (totalReservedBuffers > 0 && source.available() == 0) {
+ break;
+ }
+ List<?> tuple = source.nextTuple();
+
+ if (tuple == null) {
+ doneReading = true;
+ break;
+ }
+ if (workingTuples.add(tuple)) {
+ this.collected++;
+ }
+ } catch(BlockedException e) {
+ if (mode != Mode.DUP_REMOVE
+ || (this.output != null && collected < this.output.getRowCount() * 2)
+ || (this.output == null && this.workingTuples.isEmpty() && this.activeTupleBuffers.isEmpty())) {
+ throw e; //block if no work can be performed
+ }
+ break;
+ }
+ }
- TupleBuffer sublist = createTupleBuffer();
- activeTupleBuffers.add(sublist);
- if (this.mode == Mode.SORT) {
- //perform a stable sort
- Collections.sort(workingTuples, comparator);
- }
- for (List<?> list : workingTuples) {
- sublist.addTuple(list);
- }
- sublist.saveBatch(false);
+ if(workingTuples.isEmpty()) {
+ break;
+ }
+
+ TupleBuffer sublist = createTupleBuffer();
+ activeTupleBuffers.add(sublist);
+ if (this.mode == Mode.SORT) {
+ //perform a stable sort
+ Collections.sort((List<List<?>>)workingTuples, comparator);
+ }
+ for (List<?> list : workingTuples) {
+ sublist.addTuple(list);
+ }
+ workingTuples = null;
+
+ sublist.saveBatch();
+ } finally {
+ bufferManager.releaseBuffers(totalReservedBuffers);
+ }
}
if (this.activeTupleBuffers.isEmpty()) {
activeTupleBuffers.add(createTupleBuffer());
}
-
+ this.collected = 0;
this.phase = MERGE;
}
- protected void addTuple(List<List<?>> workingTuples, List<?> tuple) {
- if (this.mode == Mode.SORT) {
- workingTuples.add(tuple);
- return;
- }
- int index = Collections.binarySearch(workingTuples, tuple, comparator);
- if (index >= 0) {
- return; //it's already there
- }
- workingTuples.add(-index - 1, tuple);
- }
-
protected void mergePhase() throws MetaMatrixComponentException, MetaMatrixProcessingException {
while(this.activeTupleBuffers.size() > 1) {
- ArrayList<SortedSublist> workingTuples = new ArrayList<SortedSublist>(activeTupleBuffers.size());
+ ArrayList<SortedSublist> sublists = new ArrayList<SortedSublist>(activeTupleBuffers.size());
TupleBuffer merged = createTupleBuffer();
- int sortedIndex = 0;
- int maxSortIndex = Math.min(this.bufferManager.getMaxProcessingBatches() * 2, activeTupleBuffers.size());
- for(; sortedIndex<maxSortIndex; sortedIndex++) {
- TupleBuffer activeID = activeTupleBuffers.get(sortedIndex);
- SortedSublist sortedSublist = new SortedSublist();
- sortedSublist.its = activeID.createIndexedTupleSource();
- sortedSublist.index = sortedIndex;
- addWorkingTuple(workingTuples, sortedSublist);
+ int maxSortIndex = Math.min(activeTupleBuffers.size(), this.bufferManager.getMaxProcessingBatches());
+ int reservedBuffers = 0;
+ if (activeTupleBuffers.size() > maxSortIndex) {
+ reservedBuffers = bufferManager.reserveBuffers(activeTupleBuffers.size() - maxSortIndex, true);
}
-
- // iteratively process the lowest tuple
- while (workingTuples.size() > 0) {
- SortedSublist sortedSublist = workingTuples.remove(0);
- if (!sortedSublist.duplicate) {
- merged.addTuple(sortedSublist.tuple);
- if (this.output != null && sortedSublist.index != masterSortIndex && sortedIndex > masterSortIndex) {
- this.output.addTuple(sortedSublist.tuple); //a new distinct row
- }
- }
- addWorkingTuple(workingTuples, sortedSublist);
- }
-
- // Remove merged sublists
- for(int i=0; i<sortedIndex; i++) {
- TupleBuffer id = activeTupleBuffers.remove(0);
- if (id != this.output) {
- id.remove();
- }
+ maxSortIndex += reservedBuffers;
+ try {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.TRACE)) {
+ LogManager.logTrace(LogConstants.CTX_DQP, "Merging", maxSortIndex, "sublists out of", activeTupleBuffers.size()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // initialize the sublists with the min value
+ for(int i = 0; i<maxSortIndex; i++) {
+ TupleBuffer activeID = activeTupleBuffers.get(i);
+ SortedSublist sortedSublist = new SortedSublist();
+ sortedSublist.its = activeID.createIndexedTupleSource();
+ sortedSublist.index = i;
+ if (activeID == output) {
+ sortedSublist.limit = output.getRowCount();
+ }
+ incrementWorkingTuple(sublists, sortedSublist);
+ }
+
+ // iteratively process the lowest tuple
+ while (sublists.size() > 0) {
+ SortedSublist sortedSublist = sublists.remove(sublists.size() - 1);
+ merged.addTuple(sortedSublist.tuple);
+ if (this.output != null && sortedSublist.index > masterSortIndex) {
+ this.output.addTuple(sortedSublist.tuple); //a new distinct row
+ }
+ incrementWorkingTuple(sublists, sortedSublist);
+ }
+
+ // Remove merged sublists
+ for(int i=0; i<maxSortIndex; i++) {
+ TupleBuffer id = activeTupleBuffers.remove(0);
+ if (id != this.output) {
+ id.remove();
+ }
+ }
+ merged.saveBatch();
+ this.activeTupleBuffers.add(merged);
+ masterSortIndex = masterSortIndex - maxSortIndex + 1;
+ if (masterSortIndex < 0) {
+ masterSortIndex = this.activeTupleBuffers.size() - 1;
+ }
+ } finally {
+ this.bufferManager.releaseBuffers(reservedBuffers);
}
- merged.saveBatch(false);
- this.activeTupleBuffers.add(merged);
- masterSortIndex = masterSortIndex - sortedIndex + 1;
- if (masterSortIndex < 0) {
- masterSortIndex = this.activeTupleBuffers.size() - 1;
- }
}
// Close sorted source (all others have been removed)
if (doneReading) {
activeTupleBuffers.get(0).close();
- if (this.output != null) {
+ activeTupleBuffers.get(0).setForwardOnly(false);
+ if (this.output != null) {
this.output.close();
}
this.phase = DONE;
@@ -262,27 +311,41 @@
Assertion.assertTrue(mode == Mode.DUP_REMOVE);
if (this.output == null) {
this.output = activeTupleBuffers.get(0);
+ this.output.setForwardOnly(false);
}
this.phase = INITIAL_SORT;
}
- private void addWorkingTuple(ArrayList<SortedSublist> workingTuples, SortedSublist sortedSublist) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- sortedSublist.tuple = null;
- try {
- sortedSublist.tuple = sortedSublist.its.nextTuple();
- } catch (BlockedException e) {
- //intermediate sources aren't closed
- }
- if (sortedSublist.tuple == null) {
- return; // done with this sublist
- }
- sortedSublist.duplicate = false;
- int index = Collections.binarySearch(workingTuples, sortedSublist);
- if (index >= 0) {
- sortedSublist.duplicate = mode != Mode.SORT;
- workingTuples.add(index, sortedSublist);
- } else {
- workingTuples.add(-index - 1, sortedSublist);
+ private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ while (true) {
+ sortedSublist.tuple = null;
+ if (sortedSublist.limit < sortedSublist.its.getCurrentIndex()) {
+ return; //special case for still reading the output tuplebuffer
+ }
+ try {
+ sortedSublist.tuple = sortedSublist.its.nextTuple();
+ } catch (BlockedException e) {
+ //intermediate sources aren't closed
+ }
+ if (sortedSublist.tuple == null) {
+ return; // done with this sublist
+ }
+ int index = Collections.binarySearch(subLists, sortedSublist);
+ if (index < 0) {
+ subLists.add(-index - 1, sortedSublist);
+ return;
+ }
+ if (mode == Mode.SORT) {
+ subLists.add(index, sortedSublist);
+ return;
+ }
+ /* In dup removal mode we need to ensure that a sublist other than the master is incremented
+ */
+ if (mode == Mode.DUP_REMOVE && this.output != null && sortedSublist.index == masterSortIndex) {
+ SortedSublist dup = subLists.get(index);
+ subLists.set(index, sortedSublist);
+ sortedSublist = dup;
+ }
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -32,10 +32,18 @@
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.query.processor.BatchCollector;
import com.metamatrix.query.processor.BatchIterator;
+import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
+import com.metamatrix.query.processor.relational.SortUtility.Mode;
+import com.metamatrix.query.sql.lang.OrderBy;
class SourceState {
+ enum ImplicitBuffer {
+ NONE, FULL, ON_MARK
+ }
+
private RelationalNode source;
+ private List expressions;
private BatchCollector collector;
private TupleBuffer buffer;
private List<Object> outerVals;
@@ -44,16 +52,22 @@
private List currentTuple;
private int maxProbeMatch = 1;
private boolean distinct;
+ private ImplicitBuffer implicitBuffer = ImplicitBuffer.FULL;
- private boolean canBuffer = true;
+ private SortUtility sortUtility;
public SourceState(RelationalNode source, List expressions) {
this.source = source;
+ this.expressions = expressions;
List elements = source.getElements();
this.outerVals = Collections.nCopies(elements.size(), null);
this.expressionIndexes = getExpressionIndecies(expressions, elements);
}
+ public void setImplicitBuffer(ImplicitBuffer implicitBuffer) {
+ this.implicitBuffer = implicitBuffer;
+ }
+
private int[] getExpressionIndecies(List expressions,
List elements) {
if (expressions == null) {
@@ -75,43 +89,41 @@
return currentTuple;
}
- public void reset() {
+ public void reset() throws MetaMatrixComponentException {
this.getIterator().reset();
this.getIterator().mark();
this.currentTuple = null;
}
public void close() {
- closeTupleSource();
- }
-
- private void closeTupleSource() {
- if (this.buffer != null) {
+ if (this.buffer != null) {
this.buffer.remove();
this.buffer = null;
}
if (this.iterator != null) {
+ try {
+ this.iterator.closeSource();
+ } catch (MetaMatrixComponentException e) {
+ }
this.iterator = null;
}
}
-
+
public int getRowCount() throws MetaMatrixComponentException, MetaMatrixProcessingException {
return this.getTupleBuffer().getRowCount();
}
- void setTupleSource(TupleBuffer result) {
- closeTupleSource();
- this.buffer = result;
- }
-
- IndexedTupleSource getIterator() {
+ IndexedTupleSource getIterator() throws MetaMatrixComponentException {
if (this.iterator == null) {
if (this.buffer != null) {
iterator = buffer.createIndexedTupleSource();
} else {
- canBuffer = false;
// return a TupleBatch tuplesource iterator
- iterator = new BatchIterator(this.source);
+ BatchIterator bi = new BatchIterator(this.source);
+ if (implicitBuffer != ImplicitBuffer.NONE) {
+ bi.setBuffer(createSourceTupleBuffer(), implicitBuffer == ImplicitBuffer.ON_MARK);
+ }
+ this.iterator = bi;
}
}
return this.iterator;
@@ -139,14 +151,13 @@
public TupleBuffer getTupleBuffer() throws MetaMatrixComponentException, MetaMatrixProcessingException {
if (this.buffer == null) {
- if (!canBuffer) {
+ if (this.iterator instanceof BatchIterator) {
throw new AssertionError("cannot buffer the source"); //$NON-NLS-1$
}
if (collector == null) {
collector = new BatchCollector(source, createSourceTupleBuffer());
}
- TupleBuffer result = collector.collectTuples();
- setTupleSource(result);
+ this.buffer = collector.collectTuples();
}
return this.buffer;
}
@@ -158,5 +169,18 @@
public void markDistinct(boolean distinct) {
this.distinct |= distinct;
}
+
+ public void sort(SortOption sortOption) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ if (sortOption == SortOption.SORT || sortOption == SortOption.SORT_DISTINCT) {
+ if (this.sortUtility == null) {
+ this.sortUtility = new SortUtility(this.buffer != null ? this.buffer.createIndexedTupleSource() : new BatchIterator(this.source),
+ expressions, Collections.nCopies(expressions.size(), OrderBy.ASC), sortOption == SortOption.SORT_DISTINCT?Mode.DUP_REMOVE_SORT:Mode.SORT,
+ this.source.getBufferManager(), this.source.getConnectionID());
+ this.markDistinct(sortOption == SortOption.SORT_DISTINCT && expressions.size() == this.getOuterVals().size());
+ }
+ this.buffer = sortUtility.sort();
+ this.markDistinct(sortUtility.isDistinct());
+ }
+ }
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareEvaluator.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareEvaluator.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareEvaluator.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -61,7 +61,7 @@
return;
}
processor.closeProcessing();
- collector.getTupleBuffer().close();
+ collector.getTupleBuffer().remove();
processor = null;
this.done = false;
}
@@ -100,7 +100,7 @@
SubqueryState state = this.subqueries.get(key);
if (state == null) {
state = new SubqueryState();
- state.plan = (ProcessorPlan)container.getCommand().getProcessorPlan().clone();
+ state.plan = container.getCommand().getProcessorPlan().clone();
this.subqueries.put(key, state);
}
if ((tuple == null && state.tuple != null) || (tuple != null && !tuple.equals(state.tuple))) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -75,7 +75,7 @@
@Override
public InputStream getInputStream() throws IOException {
//TODO: adjust the buffer size, and/or develop a shared buffer strategy
- return new BufferedInputStream(lobBuffer.createInputStream());
+ return new BufferedInputStream(lobBuffer.createInputStream(0));
}
@Override
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -294,7 +294,7 @@
GroupSymbol group = obj.getGroup();
visitNode(group);
try {
- if (metadata.isXMLGroup(group.getMetadataID())) {
+ if (!group.isProcedure() && metadata.isXMLGroup(group.getMetadataID())) {
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0003, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0003));
}
this.discoveredGroups.add(group);
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -50,6 +50,8 @@
* SQL update statement, etc.
*/
public abstract class Command implements LanguageObject {
+
+ public static final String CACHE = "cache"; //$NON-NLS-1$
/**
* Represents an unknown type of command
@@ -126,6 +128,8 @@
private ProcessorPlan plan;
private SymbolMap correlatedReferences;
+
+ private boolean cache;
/**
* Return type of command to make it easier to build switch statements by command type.
@@ -232,6 +236,10 @@
if (this.correlatedReferences != null) {
copy.correlatedReferences = this.correlatedReferences.clone();
}
+ if(this.getOption() != null) {
+ copy.setOption( (Option) this.getOption().clone() );
+ }
+ copy.cache = this.cache;
}
/**
@@ -337,6 +345,14 @@
this.plan = plan;
}
+ public boolean isCache() {
+ return cache;
+ }
+
+ public void setCache(boolean cache) {
+ this.cache = cache;
+ }
+
/**
* Returns a string representation of an instance of this class.
* @return String representation of object
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -351,10 +351,6 @@
copy.setLimit( (Limit) getLimit().clone());
}
- if(getOption() != null) {
- copy.setOption( (Option) getOption().clone());
- }
-
// Defect 13751: should clone isXML state.
copy.setIsXML(getIsXML());
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -181,11 +181,7 @@
if(this.getLimit() != null) {
copy.setLimit( (Limit) this.getLimit().clone() );
}
-
- if(this.getOption() != null) {
- copy.setOption( (Option) this.getOption().clone() );
- }
-
+
return copy;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -153,10 +153,6 @@
public Object clone() {
CreateUpdateProcedureCommand copy = new CreateUpdateProcedureCommand();
- if (this.getOption() != null) {
- copy.setOption((Option)this.getOption().clone());
- }
-
//Clone this class state
if (this.block != null) {
copy.setBlock((Block)this.block.clone());
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -35,6 +35,7 @@
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.BetweenCriteria;
+import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Create;
@@ -481,9 +482,7 @@
}
public void visit(JoinPredicate obj) {
- if (obj.isOptional()) {
- addOptionComment(obj);
- }
+ addOptionComment(obj);
if(obj.hasHint()) {
parts.add("(");//$NON-NLS-1$
@@ -557,14 +556,14 @@
}
private void addOptionComment(FromClause obj) {
- parts.add(BEGIN_COMMENT);
- parts.add(SPACE);
- if (obj.isOptional()) {
- parts.add(Option.OPTIONAL);
- parts.add(SPACE);
- }
- parts.add(END_COMMENT);
- parts.add(SPACE);
+ if (obj.isOptional()) {
+ parts.add(BEGIN_COMMENT);
+ parts.add(SPACE);
+ parts.add(Option.OPTIONAL);
+ parts.add(SPACE);
+ parts.add(END_COMMENT);
+ parts.add(SPACE);
+ }
}
public void visit(JoinType obj) {
@@ -791,6 +790,7 @@
}
public void visit(Query obj) {
+ addCacheHint(obj);
parts.add(registerNode(obj.getSelect()));
if(obj.getInto() != null){
@@ -920,6 +920,7 @@
}
public void visit(SetQuery obj) {
+ addCacheHint(obj);
QueryCommand query = obj.getLeftQuery();
if(query instanceof Query) {
parts.add(registerNode(query));
@@ -975,6 +976,7 @@
}
public void visit(StoredProcedure obj) {
+ addCacheHint(obj);
//exec clause
parts.add(ReservedWords.EXEC);
parts.add(SPACE);
@@ -1016,10 +1018,19 @@
}
}
+ private void addCacheHint(Command obj) {
+ if (obj.isCache()) {
+ parts.add(BEGIN_COMMENT);
+ parts.add(SPACE);
+ parts.add(Command.CACHE);
+ parts.add(SPACE);
+ parts.add(END_COMMENT);
+ parts.add(SPACE);
+ }
+ }
+
public void visit(SubqueryFromClause obj) {
- if(obj.isOptional()) {
- addOptionComment(obj);
- }
+ addOptionComment(obj);
parts.add("(");//$NON-NLS-1$
parts.add(registerNode(obj.getCommand()));
parts.add(")");//$NON-NLS-1$
@@ -1046,9 +1057,7 @@
public void visit(UnaryFromClause obj) {
- if(obj.isOptional()) {
- addOptionComment(obj);
- }
+ addOptionComment(obj);
parts.add(registerNode(obj.getGroup()));
addFromClasueDepOptions(obj);
}
@@ -1157,7 +1166,7 @@
* @param str String literal value (unquoted), never null
* @return Escaped string literal value
*/
- protected String escapeStringValue(String str, String tick) {
+ static String escapeStringValue(String str, String tick) {
return StringUtil.replaceAll(str, tick, tick + tick);
}
@@ -1551,7 +1560,7 @@
parts.add(registerNode(obj.getRowLimit()));
}
- private String escapeSinglePart(String part) {
+ public static String escapeSinglePart(String part) {
if(isReservedWord(part)) {
return ID_ESCAPE_CHAR + part + ID_ESCAPE_CHAR;
}
@@ -1576,7 +1585,7 @@
* @param string String to check
* @return True if reserved word
*/
- protected boolean isReservedWord(String string) {
+ static boolean isReservedWord(String string) {
if(string == null) {
return false;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -129,6 +129,11 @@
public void closeSource() throws MetaMatrixComponentException {
}
+
+ @Override
+ public int available() {
+ return 0;
+ }
}
private BufferManager buffer;
@@ -299,7 +304,7 @@
tsId.addTuple(list);
}
//TODO: this leads to fragmented batches, which may require recreating the table
- tsId.saveBatch(false);
+ tsId.saveBatch();
tuplesAdded = tuples.size();
} catch (QueryMetadataException err) {
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -90,7 +90,7 @@
private ICommand translatedCommand;
private Class<?>[] schema;
private List<Integer> convertToRuntimeType;
- private List<Integer> convertToDesiredRuntimeType;
+ private boolean[] convertToDesiredRuntimeType;
/* End state information */
protected boolean lastBatch;
@@ -299,12 +299,12 @@
Command command = this.requestMsg.getCommand();
List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
this.schema = new Class[symbols.size()];
- this.convertToDesiredRuntimeType = new ArrayList<Integer>(symbols.size());
+ this.convertToDesiredRuntimeType = new boolean[symbols.size()];
this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
for (int i = 0; i < schema.length; i++) {
SingleElementSymbol symbol = symbols.get(i);
this.schema[i] = symbol.getType();
- this.convertToDesiredRuntimeType.add(i);
+ this.convertToDesiredRuntimeType[i] = true;
this.convertToRuntimeType.add(i);
}
@@ -465,20 +465,23 @@
}
}
//TODO: add a proper intermediate schema
- for (int i = convertToDesiredRuntimeType.size() - 1; i >= 0; i--) {
- int index = convertToDesiredRuntimeType.get(i);
- Object value = row.get(index);
- if (value != null) {
- Object result;
- try {
- result = DataTypeManager.transformValue(value, value.getClass(), this.schema[index]);
- } catch (TransformationException e) {
- throw new ConnectorException(e);
+ for (int i = 0; i < row.size(); i++) {
+ if (convertToDesiredRuntimeType[i]) {
+ Object value = row.get(i);
+ if (value != null) {
+ Object result;
+ try {
+ result = DataTypeManager.transformValue(value, value.getClass(), this.schema[i]);
+ } catch (TransformationException e) {
+ throw new ConnectorException(e);
+ }
+ if (value == result) {
+ convertToDesiredRuntimeType[i] = false;
+ }
+ row.set(i, result);
}
- if (value == result) {
- convertToDesiredRuntimeType.remove(i);
- }
- row.set(index, result);
+ } else {
+ row.set(i, DataTypeManager.getCanonicalValue(row.get(i)));
}
}
}
Copied: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java (from rev 1798, trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java)
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import com.metamatrix.common.buffer.TupleBuffer;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.sql.lang.Command;
+
+public class CachedResults {
+ private Command command;
+ private AnalysisRecord analysisRecord;
+ private TupleBuffer results;
+
+ public AnalysisRecord getAnalysisRecord() {
+ return analysisRecord;
+ }
+
+ public void setAnalysisRecord(AnalysisRecord analysisRecord) {
+ this.analysisRecord = analysisRecord;
+ }
+
+ public TupleBuffer getResults() {
+ return results;
+ }
+
+ public void setResults(TupleBuffer results) {
+ this.results = results;
+ }
+
+ public void setCommand(Command command) {
+ this.command = command;
+ }
+
+ public Command getCommand() {
+ return command;
+ }
+
+}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -21,40 +21,146 @@
*/
package org.teiid.dqp.internal.process;
-public interface DQPConfiguration {
+import com.metamatrix.dqp.message.RequestMessage;
+
+public class DQPConfiguration {
//Constants
static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
static final int DEFAULT_MAX_CODE_TABLES = 200;
static final int DEFAULT_MAX_CODE_RECORDS = 200000;
- static final int DEFAULT_FETCH_SIZE = 2000;
+ static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
- static final String DEFAULT_MAX_RESULTSET_CACHE_SIZE = "50"; //$NON-NLS-1$
- static final String DEFAULT_MAX_RESULTSET_CACHE_AGE = "3600000"; //$NON-NLS-1$
+ static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
- String getProcessName();
+
+ private String processName = "localhost";
+ private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
+ private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
+ private boolean optionDebugAllowed = true;
+ private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
+ private int lobChunkSizeInKB = 100;
+ private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
+ private int codeTablesMaxCount = DEFAULT_MAX_CODE_TABLES;
+ private int codeTablesMaxRowsPerTable = DEFAULT_MAX_CODE_TABLE_RECORDS;
+ private int codeTablesMaxRows = DEFAULT_MAX_CODE_RECORDS;
+ private String bindAddress = "localhost";
+ private int portNumber = 31000;
+ private boolean resultSetCacheEnabled = false;
+ private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
- int getMaxThreads();
- int getTimeSliceInMilli();
+ public String getProcessName() {
+ return processName;
+ }
+
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+
+ public int getMaxThreads() {
+ return maxThreads;
+ }
+
+ public void setMaxThreads(Integer maxThreads) {
+ this.maxThreads = maxThreads;
+ }
+
+ public int getTimeSliceInMilli() {
+ return timeSliceInMilli;
+ }
+
+ public void setTimeSliceInMilli(Integer timeSliceInMilli) {
+ this.timeSliceInMilli = timeSliceInMilli;
+ }
+
+ public boolean isOptionDebugAllowed() {
+ return optionDebugAllowed;
+ }
+
+ public void setOptionDebugAllowed(Boolean optionDebugAllowed) {
+ this.optionDebugAllowed = optionDebugAllowed;
+ }
+
+ public int getMaxRowsFetchSize() {
+ return maxRowsFetchSize;
+ }
+
+ public void setMaxRowsFetchSize(Integer maxRowsFetchSize) {
+ this.maxRowsFetchSize = maxRowsFetchSize;
+ }
+
+ public int getLobChunkSizeInKB() {
+ return lobChunkSizeInKB;
+ }
+
+ public void setLobChunkSizeInKB(Integer lobChunkSizeInKB) {
+ this.lobChunkSizeInKB = lobChunkSizeInKB;
+ }
+
+ public int getPreparedPlanCacheMaxCount() {
+ return preparedPlanCacheMaxCount;
+ }
+
+ public void setPreparedPlanCacheMaxCount(Integer preparedPlanCacheMaxCount) {
+ this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
+ }
+
+ public int getCodeTablesMaxCount() {
+ return codeTablesMaxCount;
+ }
+
+ public void setCodeTablesMaxCount(Integer codeTablesMaxCount) {
+ this.codeTablesMaxCount = codeTablesMaxCount;
+ }
+
+ public int getCodeTablesMaxRowsPerTable() {
+ return codeTablesMaxRowsPerTable;
+ }
+
+ public void setCodeTablesMaxRowsPerTable(Integer codeTablesMaxRowsPerTable) {
+ this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
+ }
+
+ public int getCodeTablesMaxRows() {
+ return codeTablesMaxRows;
+ }
+
+ public void setCodeTablesMaxRows(Integer codeTablesMaxRows) {
+ this.codeTablesMaxRows = codeTablesMaxRows;
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public void setBindAddress(String bindAddress) {
+ this.bindAddress = bindAddress;
+ }
+
+ public int getPortNumber() {
+ return portNumber;
+ }
+
+ public void setPortNumber(Integer portNumber) {
+ this.portNumber = portNumber;
+ }
+
+ public int getResultSetCacheMaxEntries() {
+ return this.maxResultSetCacheEntries;
+ }
- boolean isOptionDebugAllowed();
+ public void setResultSetCacheMaxEntries(Integer value) {
+ this.maxResultSetCacheEntries = value;
+ }
+
+ public boolean isResultSetCacheEnabled() {
+ return this.resultSetCacheEnabled;
+ }
- int getMaxRowsFetchSize();
-
- int getLobChunkSizeInKB();
-
- int getPreparedPlanCacheMaxCount();
-
- int getCodeTablesMaxCount();
-
- int getCodeTablesMaxRowsPerTable();
-
- int getCodeTablesMaxRows();
-
- String getBindAddress();
-
- int getPortNumber();
+ public void setResultSetCacheEnabled(Boolean value) {
+ this.resultSetCacheEnabled = value;
+ }
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -125,9 +125,9 @@
// Resources
private BufferManager bufferManager;
private ProcessorDataManager dataTierMgr;
- private PreparedPlanCache prepPlanCache;
+ private SessionAwareCache<PreparedPlan> prepPlanCache;
+ private SessionAwareCache<CachedResults> rsCache;
private TransactionService transactionService;
- //private ResultSetCache rsCache;
private AuthorizationService authorizationService;
private BufferService bufferService;
private SessionService sessionService;
@@ -458,9 +458,9 @@
private void clearResultSetCache() {
//clear cache in server
- /*if(rsCache != null){
- rsCache.clear();
- }*/
+ if(rsCache != null){
+ rsCache.clearAll();
+ }
}
@@ -582,9 +582,9 @@
return transactionService;
}
- /*ResultSetCache getRsCache() {
+ SessionAwareCache<CachedResults> getRsCache() {
return rsCache;
- }*/
+ }
int getProcessorTimeSlice() {
return this.processorTimeslice;
@@ -608,15 +608,12 @@
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
//result set cache
- /*if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, false)){
- this.rsCache = new ResultSetCache();
- PropertiesUtils.setBeanProperties(this.rsCache, props, "ResultSetCache"); //$NON-NLS-1$
- this.rsCache.start(cacheFactory);
- }*/
+ if (config.isResultSetCacheEnabled()) {
+ this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries());
+ }
//prepared plan cache
-
- prepPlanCache = new PreparedPlanCache(config.getPreparedPlanCacheMaxCount());
+ prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount());
// Processor debug flag
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -229,4 +229,17 @@
return this.isTransactional;
}
+ @Override
+ public int available() {
+ if (index < currentBatchCount) {
+ return currentBatchCount - index;
+ }
+ synchronized (this) {
+ if (nextBatch != null) {
+ return nextBatch.length;
+ }
+ }
+ return 0;
+ }
+
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -30,7 +30,7 @@
import java.util.Set;
import org.teiid.dqp.internal.process.DQPCore.ClientState;
-import org.teiid.dqp.internal.process.PreparedPlanCache.CacheID;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -73,13 +73,13 @@
// Resources
private DQPCore requestManager;
private QueryMetadataInterface metadata;
- private PreparedPlanCache planCache;
+ private SessionAwareCache<PreparedPlan> planCache;
private String vdbName;
private int vdbVersion;
private RequestID requestID;
- public MetaDataProcessor(DQPCore requestManager, PreparedPlanCache planCache, String vdbName, int vdbVersion) {
+ public MetaDataProcessor(DQPCore requestManager, SessionAwareCache<PreparedPlan> planCache, String vdbName, int vdbVersion) {
this.requestManager = requestManager;
this.planCache = planCache;
this.vdbName = vdbName;
@@ -205,8 +205,8 @@
ParseInfo info = new ParseInfo();
// Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
info.ansiQuotedIdentifiers = isDoubleQuotedVariablesAllowed;
- CacheID id = new PreparedPlanCache.CacheID(workContext, info, sql);
- PreparedPlanCache.PreparedPlan plan = planCache.getPreparedPlan(id);
+ CacheID id = new CacheID(workContext, info, sql);
+ PreparedPlan plan = planCache.get(id);
if(plan != null) {
command = plan.getCommand();
} else {
Copied: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java (from rev 1798, trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java)
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.List;
+
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.symbol.Reference;
+
+class PreparedPlan{
+ private ProcessorPlan plan;
+ private Command command;
+ private List<Reference> refs;
+ private AnalysisRecord analysisRecord;
+
+ /**
+ * Return the ProcessorPlan.
+ */
+ public ProcessorPlan getPlan(){
+ return plan;
+ }
+
+ /**
+ * Return the plan description.
+ */
+ public AnalysisRecord getAnalysisRecord(){
+ return this.analysisRecord;
+ }
+
+ /**
+ * Return the Command .
+ */
+ public Command getCommand(){
+ return command;
+ }
+
+ /**
+ * Return the list of Reference.
+ */
+ public List<Reference> getReferences(){
+ return refs;
+ }
+
+ /**
+ * Set the ProcessorPlan.
+ */
+ public void setPlan(ProcessorPlan planValue){
+ plan = planValue;
+ }
+
+ /**
+ * Set the plan description.
+ */
+ public void setAnalysisRecord(AnalysisRecord analysisRecord){
+ this.analysisRecord = analysisRecord;
+ }
+
+ /**
+ * Set the Command.
+ */
+ public void setCommand(Command commandValue){
+ command = commandValue;
+ }
+
+ /**
+ * Set the list of Reference.
+ */
+ public void setReferences(List<Reference> refsValue){
+ refs = refsValue;
+ }
+
+}
\ No newline at end of file
Deleted: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.dqp.internal.process;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-/**
- * This class is used to cache plan and related objects for prepared statement
- */
-public class PreparedPlanCache {
- public static final int DEFAULT_MAX_SIZE_TOTAL = 250;
-
- private Map<CacheID, PreparedPlan> cache;
- private int maxSize;
-
- PreparedPlanCache(){
- this(DEFAULT_MAX_SIZE_TOTAL);
- }
-
- PreparedPlanCache (int maxSize ){
- if(maxSize < 0){
- maxSize = DEFAULT_MAX_SIZE_TOTAL;
- }
- this.maxSize = maxSize;
- cache = Collections.synchronizedMap(new LRUCache<CacheID, PreparedPlan>(maxSize));
- }
-
- /**
- * Return the PreparedPlan for the given session and SQl query
- * @param sql SQL query string
- * @param session ClientConnection
- * @return PreparedPlan for the given clientConn and SQl query. Null if not exist.
- */
- public PreparedPlan getPreparedPlan(CacheID id){
- id.setSessionId(id.originalSessionId);
- PreparedPlan result = cache.get(id);
- if (result == null) {
- id.setSessionId(null);
- }
- return cache.get(id);
- }
-
- /**
- * Create PreparedPlan for the given clientConn and SQl query
- */
- public void putPreparedPlan(CacheID id, boolean sessionSpecific, PreparedPlan plan){
- if (sessionSpecific) {
- id.setSessionId(id.originalSessionId);
- } else {
- id.setSessionId(null);
- }
- this.cache.put(id, plan);
- }
-
- /**
- * Clear all the cached plans for all the clientConns
- * @param clientConn ClientConnection
- */
- public void clearAll(){
- cache.clear();
- }
-
- static class CacheID{
- private String sql;
- private VDBKey vdbInfo;
- private ParseInfo pi;
- private String sessionId;
- private String originalSessionId;
- private int hashCode;
-
- CacheID(DQPWorkContext context, ParseInfo pi, String sql){
- this.sql = sql;
- this.vdbInfo = new VDBKey(context.getVdbName(), context.getVdbVersion());
- this.pi = pi;
- this.originalSessionId = context.getConnectionID();
- }
-
- private void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- hashCode = HashCodeUtil.hashCode(HashCodeUtil.hashCode(HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, vdbInfo), sql), pi), sessionId);
- }
-
- public boolean equals(Object obj){
- if(obj == this) {
- return true;
- }
- if(! (obj instanceof CacheID)) {
- return false;
- }
- CacheID that = (CacheID)obj;
- return this.pi.equals(that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
- && ((this.sessionId == null && that.sessionId == null) || this.sessionId.equals(that.sessionId));
- }
-
- public int hashCode() {
- return hashCode;
- }
- }
-
- static class PreparedPlan{
- private ProcessorPlan plan;
- private Command command;
- private List<Reference> refs;
- private AnalysisRecord analysisRecord;
-
- /**
- * Return the ProcessorPlan.
- */
- public ProcessorPlan getPlan(){
- return plan;
- }
-
- /**
- * Return the plan description.
- */
- public AnalysisRecord getAnalysisRecord(){
- return this.analysisRecord;
- }
-
- /**
- * Return the Command .
- */
- public Command getCommand(){
- return command;
- }
-
- /**
- * Return the list of Reference.
- */
- public List<Reference> getReferences(){
- return refs;
- }
-
- /**
- * Set the ProcessorPlan.
- */
- public void setPlan(ProcessorPlan planValue){
- plan = planValue;
- }
-
- /**
- * Set the plan description.
- */
- public void setAnalysisRecord(AnalysisRecord analysisRecord){
- this.analysisRecord = analysisRecord;
- }
-
- /**
- * Set the Command.
- */
- public void setCommand(Command commandValue){
- command = commandValue;
- }
-
- /**
- * Set the list of Reference.
- */
- public void setReferences(List<Reference> refsValue){
- refs = refsValue;
- }
-
- }
-
- //for testing purpose
- int getSpaceUsed() {
- return cache.size();
- }
- int getSpaceAllowed() {
- return maxSize;
- }
-
-}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -27,8 +27,7 @@
import java.util.LinkedList;
import java.util.List;
-import org.teiid.dqp.internal.process.PreparedPlanCache.CacheID;
-import org.teiid.dqp.internal.process.PreparedPlanCache.PreparedPlan;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
@@ -63,10 +62,10 @@
* Specific request for handling prepared statement calls.
*/
public class PreparedStatementRequest extends Request {
- private PreparedPlanCache prepPlanCache;
+ private SessionAwareCache<PreparedPlan> prepPlanCache;
private PreparedPlan prepPlan;
- public PreparedStatementRequest(PreparedPlanCache prepPlanCache) {
+ public PreparedStatementRequest(SessionAwareCache<PreparedPlan> prepPlanCache) {
this.prepPlanCache = prepPlanCache;
}
@@ -101,15 +100,15 @@
return;
}
List values = requestMsg.getParameterValues();
- List spParams = proc.getParameters();
+ List<SPParameter> spParams = proc.getParameters();
proc.clearParameters();
int inParameterCount = values.size();
if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
inParameterCount = ((List)values.get(0)).size();
}
int index = 1;
- for (Iterator params = spParams.iterator(); params.hasNext();) {
- SPParameter param = (SPParameter) params.next();
+ for (Iterator<SPParameter> params = spParams.iterator(); params.hasNext();) {
+ SPParameter param = params.next();
if (param.getParameterType() == SPParameter.RETURN_VALUE) {
continue;
}
@@ -133,8 +132,8 @@
*/
protected void generatePlan() throws QueryPlannerException, QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
String sqlQuery = requestMsg.getCommands()[0];
- CacheID id = new PreparedPlanCache.CacheID(this.workContext, Request.createParseInfo(this.requestMsg), sqlQuery);
- prepPlan = prepPlanCache.getPreparedPlan(id);
+ CacheID id = new CacheID(this.workContext, Request.createParseInfo(this.requestMsg), sqlQuery);
+ prepPlan = prepPlanCache.get(id);
if (prepPlan == null) {
//if prepared plan does not exist, create one
prepPlan = new PreparedPlan();
@@ -148,13 +147,13 @@
if (!this.addedLimit) { //TODO: this is a little problematic
prepPlan.setCommand(this.userCommand);
// Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
- prepPlan.setPlan((ProcessorPlan)processPlan.clone());
+ prepPlan.setPlan(processPlan.clone());
prepPlan.setAnalysisRecord(analysisRecord);
- this.prepPlanCache.putPreparedPlan(id, this.context.isSessionFunctionEvaluated(), prepPlan);
+ this.prepPlanCache.put(id, this.context.isSessionFunctionEvaluated(), prepPlan);
}
} else {
LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
- processPlan = (ProcessorPlan)cachedPlan.clone();
+ processPlan = cachedPlan.clone();
//already in cache. obtain the values from cache
analysisRecord = prepPlan.getAnalysisRecord();
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,6 +22,7 @@
package org.teiid.dqp.internal.process;
+import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -34,6 +35,7 @@
import org.teiid.ContainerHelper;
import org.teiid.ContainerUtil;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
@@ -82,31 +84,24 @@
/*
* Obtained at construction time
*/
- protected final DQPCore dqpCore;
+ protected final DQPCore dqpCore;
final RequestMessage requestMsg;
final RequestID requestID;
- protected Request request; //provides the processing plan, held on a temporary basis
- final private int processorTimeslice;
- //protected ResultSetCache rsCache;
- //protected CacheID cid;
- final private TransactionService transactionService;
- final DQPWorkContext dqpWorkContext;
+ private Request request; //provides the processing plan, held on a temporary basis
+ private final int processorTimeslice;
+ private CacheID cid;
+ private final TransactionService transactionService;
+ private final DQPWorkContext dqpWorkContext;
- //results request
- private ResultsReceiver<ResultsMessage> resultsReceiver;
- private int begin;
- private int end;
-
/*
* obtained during new
*/
private volatile QueryProcessor processor;
private BatchCollector collector;
- protected Command originalCommand;
+ private Command originalCommand;
private AnalysisRecord analysisRecord;
private TransactionContext transactionContext;
- protected TupleBuffer resultsBuffer;
- private Collection schemas; // These are schemas associated with XML results
+ TupleBuffer resultsBuffer;
private boolean returnsUpdateCount;
/*
@@ -116,22 +111,21 @@
private Map<AtomicRequestID, DataTierTupleSource> connectorInfo = new ConcurrentHashMap<AtomicRequestID, DataTierTupleSource>(4);
// This exception contains details of all the atomic requests that failed when query is run in partial results mode.
private List<MetaMatrixException> warnings = new LinkedList<MetaMatrixException>();
-
private boolean doneProducingBatches;
- protected boolean isClosed;
+ private boolean isClosed;
private volatile boolean isCanceled;
private volatile boolean closeRequested;
-
+ //results request
+ private ResultsReceiver<ResultsMessage> resultsReceiver;
+ private int begin;
+ private int end;
+ private TupleBatch savedBatch;
private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
this.requestMsg = requestMsg;
this.requestID = requestID;
this.processorTimeslice = dqpCore.getProcessorTimeSlice();
- /*this.rsCache = dqpCore.getRsCache();
- if (this.rsCache != null) {
- this.cid = this.rsCache.createCacheID(workContext, requestMsg.getCommandString(), requestMsg.getParameterValues());
- }*/
this.transactionService = dqpCore.getTransactionService();
this.dqpCore = dqpCore;
this.request = request;
@@ -139,6 +133,10 @@
this.requestResults(1, requestMsg.getFetchSize(), receiver);
}
+ private boolean isForwardOnly() {
+ return this.cid == null && requestMsg.getCursorType() == ResultSet.TYPE_FORWARD_ONLY;
+ }
+
/**
* Ask for results.
* @param beginRow
@@ -186,6 +184,9 @@
}
} catch (BlockedException e) {
LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on", requestID, "- processor blocked ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (QueryProcessor.ExpiredTimeSliceException e) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "############# PW reenqueueing ", requestID, "- time slice expired ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ this.moreWork();
} catch (Throwable e) {
LogManager.logDetail(LogConstants.CTX_DQP, e, "############# PW EXITING on", requestID, "- error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -225,19 +226,15 @@
}
protected void processMore() throws BlockedException, MetaMatrixCoreException {
- this.processor.getContext().setTimeSliceEnd(System.currentTimeMillis() + this.processorTimeslice);
+ if (this.processor != null) {
+ this.processor.getContext().setTimeSliceEnd(System.currentTimeMillis() + this.processorTimeslice);
+ }
if (!doneProducingBatches) {
sendResultsIfNeeded(null);
collector.collectTuples();
- doneProducingBatches = collector.isDone();
+ doneProducingBatches = this.resultsBuffer.isFinal();
}
if (doneProducingBatches) {
- /*if(rsCache != null && requestMsg.useResultSetCache() && originalCommand.areResultsCachable()){
- boolean sessionScope = this.processor.getContext().isSessionFunctionEvaluated();
- CacheResults cr = new CacheResults();
- cr.setCommand(originalCommand);
- cr.setAnalysisRecord(analysisRecord);
- }*/
if (this.transactionState == TransactionState.ACTIVE) {
boolean endState = true;
/*
@@ -274,9 +271,12 @@
* Any errors that occur will not make it to the client, instead we just log them here.
*/
protected void attemptClose() {
+ int rowcount = -1;
if (this.resultsBuffer != null) {
try {
- this.processor.closeProcessing();
+ if (this.processor != null) {
+ this.processor.closeProcessing();
+ }
} catch (MetaMatrixComponentException e) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
@@ -286,7 +286,19 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "Removing tuplesource for the request " + requestID); //$NON-NLS-1$
}
- resultsBuffer.remove();
+ rowcount = resultsBuffer.getRowCount();
+ if (this.processor != null) {
+ if (this.cid == null || !this.doneProducingBatches) {
+ resultsBuffer.remove();
+ } else {
+ boolean sessionScope = this.processor.getContext().isSessionFunctionEvaluated();
+ CachedResults cr = new CachedResults();
+ cr.setCommand(originalCommand);
+ cr.setAnalysisRecord(analysisRecord);
+ cr.setResults(this.resultsBuffer);
+ dqpCore.getRsCache().put(cid, sessionScope, cr);
+ }
+ }
for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
try {
@@ -299,6 +311,7 @@
}
this.resultsBuffer = null;
+ this.processor = null;
}
if (this.transactionState == TransactionState.ACTIVE) {
@@ -324,23 +337,39 @@
if (this.processingException != null) {
sendError();
} else {
- dqpCore.logMMCommand(this, false, false, this.processor.getHighestRow());
+ dqpCore.logMMCommand(this, false, false, rowcount);
}
}
protected void processNew() throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ SessionAwareCache<CachedResults> rsCache = dqpCore.getRsCache();
+ CacheID cacheId = new CacheID(this.dqpWorkContext, Request.createParseInfo(requestMsg), requestMsg.getCommandString());
+ cacheId.setParameters(requestMsg.getParameterValues());
+ if (rsCache != null) {
+ CachedResults cr = rsCache.get(cacheId);
+ if (cr != null && (requestMsg.useResultSetCache() || cr.getCommand().isCache())) {
+ this.resultsBuffer = cr.getResults();
+ this.analysisRecord = cr.getAnalysisRecord();
+ this.originalCommand = cr.getCommand();
+ this.doneProducingBatches = true;
+ return;
+ }
+ }
request.processRequest();
originalCommand = request.userCommand;
+ if ((requestMsg.useResultSetCache() || originalCommand.isCache()) && rsCache != null && originalCommand.areResultsCachable()) {
+ this.cid = cacheId;
+ }
processor = request.processor;
collector = processor.createBatchCollector();
collector.setBatchHandler(new BatchHandler() {
- public void batchProduced(TupleBatch batch) throws MetaMatrixComponentException {
- sendResultsIfNeeded(batch);
+ public boolean batchProduced(TupleBatch batch) throws MetaMatrixComponentException {
+ return sendResultsIfNeeded(batch);
}
});
resultsBuffer = collector.getTupleBuffer();
+ resultsBuffer.setForwardOnly(isForwardOnly());
analysisRecord = request.analysisRecord;
- schemas = request.schemas;
transactionContext = request.transactionContext;
if (this.transactionContext != null && this.transactionContext.getXid() != null) {
this.transactionState = TransactionState.ACTIVE;
@@ -349,6 +378,7 @@
if (option != null && option.getPlanOnly()) {
doneProducingBatches = true;
resultsBuffer.close();
+ this.cid = null;
}
if (analysisRecord.recordQueryPlan()) {
@@ -361,77 +391,90 @@
/**
* Send results if they have been requested. This should only be called from the processing thread.
*/
- protected void sendResultsIfNeeded(TupleBatch batch) throws MetaMatrixComponentException {
+ protected boolean sendResultsIfNeeded(TupleBatch batch) throws MetaMatrixComponentException {
ResultsMessage response = null;
ResultsReceiver<ResultsMessage> receiver = null;
-
+ boolean result = true;
synchronized (this) {
if (this.resultsReceiver == null
- || (this.begin > this.processor.getHighestRow() && !doneProducingBatches)
+ || (this.begin > (batch != null?batch.getEndRow():this.resultsBuffer.getRowCount()) && !doneProducingBatches)
|| (this.transactionState == TransactionState.ACTIVE)) {
- return;
+ return result;
}
- }
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID: " + requestID + " resultsID: " + this.resultsBuffer + " done: " + doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- if (batch == null || batch.getBeginRow() > this.begin) {
- batch = resultsBuffer.getBatch(begin);
- //TODO: support fetching more than 1 batch
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID:", requestID, "resultsID:", this.resultsBuffer, "done:", doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ //TODO: support fetching more than 1 batch
+ boolean fromBuffer = false;
+ if (batch == null || !(batch.containsRow(this.begin))) {
+ if (savedBatch != null && savedBatch.containsRow(this.begin)) {
+ batch = savedBatch;
+ } else {
+ batch = resultsBuffer.getBatch(begin);
+ }
+ savedBatch = null;
+ fromBuffer = true;
+ }
int count = this.end - this.begin + 1;
if (batch.getRowCount() > count) {
int beginRow = Math.min(this.begin, batch.getEndRow() - count + 1);
int endRow = Math.min(beginRow + count - 1, batch.getEndRow());
+ boolean last = false;
+ if (endRow == batch.getEndRow()) {
+ last = batch.getTerminationFlag();
+ } else if (fromBuffer && isForwardOnly()) {
+ savedBatch = batch;
+ }
int firstOffset = beginRow - batch.getBeginRow();
List[] memoryRows = batch.getAllTuples();
List[] rows = new List[count];
System.arraycopy(memoryRows, firstOffset, rows, 0, endRow - beginRow + 1);
batch = new TupleBatch(beginRow, rows);
+ batch.setTerminationFlag(last);
+ } else if (!fromBuffer){
+ result = !isForwardOnly();
}
- }
- int finalRowCount = doneProducingBatches?this.processor.getHighestRow():-1;
-
- response = createResultsMessage(requestMsg, batch.getAllTuples(), this.processor.getProcessorPlan().getOutputElements(), analysisRecord);
- response.setFirstRow(batch.getBeginRow());
- response.setLastRow(batch.getEndRow());
- response.setUpdateResult(this.returnsUpdateCount);
- // set final row
- response.setFinalRow(finalRowCount);
-
- // send any schemas associated with the results
- response.setSchemas(this.schemas);
-
- // send any warnings with the response object
- List<Throwable> responseWarnings = new ArrayList<Throwable>();
- List<Exception> currentWarnings = processor.getAndClearWarnings();
- if (currentWarnings != null) {
- responseWarnings.addAll(currentWarnings);
- }
- synchronized (warnings) {
- responseWarnings.addAll(this.warnings);
- this.warnings.clear();
- }
- response.setWarnings(responseWarnings);
-
- // If it is stored procedure, set parameters
- if (originalCommand instanceof StoredProcedure) {
- StoredProcedure proc = (StoredProcedure)originalCommand;
- if (proc.returnParameters()) {
- response.setParameters(getParameterInfo(proc));
- }
- }
- /*
- * mark the results sent at this point.
- * communication exceptions will be treated as non-recoverable
- */
- synchronized (this) {
+ int finalRowCount = this.resultsBuffer.isFinal()?this.resultsBuffer.getRowCount():(batch.getTerminationFlag()?batch.getEndRow():-1);
+
+ response = createResultsMessage(requestMsg, batch.getAllTuples(), this.originalCommand.getProjectedSymbols(), analysisRecord);
+ response.setFirstRow(batch.getBeginRow());
+ response.setLastRow(batch.getEndRow());
+ response.setUpdateResult(this.returnsUpdateCount);
+ // set final row
+ response.setFinalRow(finalRowCount);
+
+ // send any warnings with the response object
+ List<Throwable> responseWarnings = new ArrayList<Throwable>();
+ if (this.processor != null) {
+ List<Exception> currentWarnings = processor.getAndClearWarnings();
+ if (currentWarnings != null) {
+ responseWarnings.addAll(currentWarnings);
+ }
+ }
+ synchronized (warnings) {
+ responseWarnings.addAll(this.warnings);
+ this.warnings.clear();
+ }
+ response.setWarnings(responseWarnings);
+
+ // If it is stored procedure, set parameters
+ if (originalCommand instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)originalCommand;
+ if (proc.returnParameters()) {
+ response.setParameters(getParameterInfo(proc));
+ }
+ }
+ /*
+ * mark the results sent at this point.
+ * communication exceptions will be treated as non-recoverable
+ */
receiver = this.resultsReceiver;
this.resultsReceiver = null;
}
-
receiver.receiveResults(response);
-
+ return result;
}
public static ResultsMessage createResultsMessage(RequestMessage message, List[] batch, List columnSymbols, AnalysisRecord analysisRecord) {
@@ -488,13 +531,10 @@
resultsReceiver.receiveResults(response);
}
- private static List getParameterInfo(StoredProcedure procedure) {
- List params = procedure.getParameters();
- List paramInfos = new ArrayList(params.size());
+ private static List<ParameterInfo> getParameterInfo(StoredProcedure procedure) {
+ List<ParameterInfo> paramInfos = new ArrayList<ParameterInfo>();
- Iterator iter = params.iterator();
- while(iter.hasNext()) {
- SPParameter param = (SPParameter) iter.next();
+ for (SPParameter param : procedure.getParameters()) {
ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size());
paramInfos.add(info);
}
Copied: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java (from rev 1798, trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java)
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.process;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.metamatrix.core.util.EquivalenceUtil;
+import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.core.util.LRUCache;
+import com.metamatrix.query.parser.ParseInfo;
+import com.metamatrix.vdb.runtime.VDBKey;
+
+/**
+ * This class is used to cache session aware objects
+ */
+public class SessionAwareCache<T> {
+ public static final int DEFAULT_MAX_SIZE_TOTAL = 250;
+
+ private Map<CacheID, T> cache;
+ private int maxSize;
+
+ private AtomicInteger cacheHit = new AtomicInteger();
+
+ SessionAwareCache(){
+ this(DEFAULT_MAX_SIZE_TOTAL);
+ }
+
+ SessionAwareCache (int maxSize ){
+ if(maxSize < 0){
+ maxSize = DEFAULT_MAX_SIZE_TOTAL;
+ }
+ this.maxSize = maxSize;
+ cache = Collections.synchronizedMap(new LRUCache<CacheID, T>(maxSize));
+ }
+
+ public T get(CacheID id){
+ id.setSessionId(id.originalSessionId);
+ T result = cache.get(id);
+ if (result == null) {
+ id.setSessionId(null);
+ result = cache.get(id);
+ }
+ if (result != null) {
+ cacheHit.getAndIncrement();
+ }
+ return result;
+ }
+
+ public int getCacheHitCount() {
+ return cacheHit.get();
+ }
+
+ /**
+ * Create PreparedPlan for the given clientConn and SQl query
+ */
+ public void put(CacheID id, boolean sessionSpecific, T t){
+ if (sessionSpecific) {
+ id.setSessionId(id.originalSessionId);
+ } else {
+ id.setSessionId(null);
+ }
+ this.cache.put(id, t);
+ }
+
+ /**
+ * Clear all the cached plans for all the clientConns
+ * @param clientConn ClientConnection
+ */
+ public void clearAll(){
+ cache.clear();
+ }
+
+ static class CacheID{
+ private String sql;
+ private VDBKey vdbInfo;
+ private ParseInfo pi;
+ private String sessionId;
+ private String originalSessionId;
+ private List<?> parameters;
+
+ CacheID(DQPWorkContext context, ParseInfo pi, String sql){
+ this.sql = sql;
+ this.vdbInfo = new VDBKey(context.getVdbName(), context.getVdbVersion());
+ this.pi = pi;
+ this.originalSessionId = context.getConnectionID();
+ }
+
+ private void setSessionId(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ public void setParameters(List<?> parameters) {
+ this.parameters = parameters;
+ }
+
+ public boolean equals(Object obj){
+ if(obj == this) {
+ return true;
+ }
+ if(! (obj instanceof CacheID)) {
+ return false;
+ }
+ CacheID that = (CacheID)obj;
+ return this.pi.equals(that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
+ && EquivalenceUtil.areEqual(this.sessionId, that.sessionId)
+ && EquivalenceUtil.areEqual(this.parameters, that.parameters);
+ }
+
+ public int hashCode() {
+ return HashCodeUtil.hashCode(0, vdbInfo, sql, pi, sessionId, parameters);
+ }
+
+ @Override
+ public String toString() {
+ return "Cache Entry<" + originalSessionId + "> params:" + parameters + " sql:" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ }
+ }
+
+ //for testing purpose
+ int getSpaceUsed() {
+ return cache.size();
+ }
+ int getSpaceAllowed() {
+ return maxSize;
+ }
+
+}
Modified: branches/JCA/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- branches/JCA/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2010-02-04 18:44:39 UTC (rev 1800)
@@ -999,10 +999,15 @@
StoredProcedure storedProcedure = new StoredProcedure();
String procName = null;
Option option = null;
+ Token execToken = null;
}
{
(
- (<EXEC> | <EXECUTE>)
+ (
+ (execToken = <EXEC> { setQueryCacheOption(execToken, info); })
+ |
+ (execToken = <EXECUTE> { setQueryCacheOption(execToken, info); })
+ )
procName = id()
{
storedProcedure.setProcedureName(procName);
@@ -1415,9 +1420,13 @@
SelectSymbol symbol = null;
Select select = new Select();
info.aggregatesAllowed = true;
+ Token selectToken = null;
}
{
- <SELECT>
+ selectToken = <SELECT>
+ {
+ setQueryCacheOption(selectToken, info);
+ }
[<ALL> | (<DISTINCT> {isDistinct=true;})]
(<STAR>
{
Modified: branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -51,8 +51,7 @@
public static BufferManager getStandaloneBufferManager() throws MetaMatrixComponentException {
if (INSTANCE == null) {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
- Properties props = new Properties();
- bufferMgr.initialize(props);
+ bufferMgr.initialize();
// Add unmanaged memory storage manager
bufferMgr.setStorageManager(new MemoryStorageManager());
Copied: branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java (from rev 1798, trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java)
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java (rev 0)
+++ branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,85 @@
+/*
+ * 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 com.metamatrix.common.buffer;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+
+public class TestTupleBuffer {
+
+ @Test public void testForwardOnly() throws Exception {
+ ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
+ x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ List<ElementSymbol> schema = Arrays.asList(x);
+ TupleBuffer tb = new TupleBuffer(new BatchManager() {
+
+ @Override
+ public void remove() {
+
+ }
+
+ @Override
+ public ManagedBatch createManagedBatch(final TupleBatch batch)
+ throws MetaMatrixComponentException {
+ return new ManagedBatch() {
+
+ @Override
+ public void remove() {
+
+ }
+
+ @Override
+ public TupleBatch getBatch(boolean cache, String[] types)
+ throws MetaMatrixComponentException {
+ return batch;
+ }
+ };
+ }
+ }, "x", schema, 32); //$NON-NLS-1$
+ tb.setForwardOnly(true);
+ tb.addTuple(Arrays.asList(1));
+ TupleBatch batch = tb.getBatch(1);
+ assertTrue(!batch.getTerminationFlag());
+ assertEquals(1, batch.getBeginRow());
+ try {
+ tb.getBatch(1);
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (AssertionError e) {
+
+ }
+ tb.addTuple(Arrays.asList(1));
+ tb.close();
+ batch = tb.getBatch(2);
+ assertTrue(batch.getTerminationFlag());
+ assertEquals(2, batch.getBeginRow());
+ }
+
+}
Copied: branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl (from rev 1798, trunk/engine/src/test/java/com/metamatrix/common/buffer/impl)
Deleted: branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-02-02 20:46:07 UTC (rev 1798)
+++ branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.core.util.UnitTestUtil;
-public class TestFileStorageManager {
-
- public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
- Properties resourceProps = new Properties();
- FileStorageManager sm = new FileStorageManager();
- sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
- if (maxFileSize != null) {
- sm.setMaxFileSizeDirect(maxFileSize);
- }
- if (openFiles != null) {
- sm.setMaxOpenFiles(openFiles);
- }
- sm.initialize(resourceProps);
- return sm;
- }
-
- @Test public void testAddGetBatch1() throws Exception {
- StorageManager sm = getStorageManager(null, null, null);
- String tsID = "local,1:0"; //$NON-NLS-1$
- // Add one batch
- FileStore store = sm.createFileStore(tsID);
- writeBytes(store);
- // Get that batch
- store.remove();
- }
-
- @Test public void testCreatesSpillFiles() throws Exception {
- FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
- String tsID = "local,1:0"; //$NON-NLS-1$
- // Add one batch
- FileStore store = sm.createFileStore(tsID);
- writeBytes(store);
-
- Map<File, RandomAccessFile> cache = sm.getFileCache();
- assertEquals(1, cache.size());
-
- writeBytes(store);
-
- assertEquals(2, cache.size());
-
- store.remove();
-
- assertEquals(0, cache.size());
- }
-
- static Random r = new Random();
-
- private void writeBytes(FileStore store)
- throws MetaMatrixComponentException {
- byte[] bytes = new byte[2048];
- r.nextBytes(bytes);
- long start = store.write(bytes, 0, bytes.length);
- byte[] bytesRead = new byte[2048];
- store.readFully(start, bytesRead, 0, bytesRead.length);
- assertTrue(Arrays.equals(bytes, bytesRead));
- }
-
-}
Copied: branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java (from rev 1798, trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java)
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java (rev 0)
+++ branches/JCA/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.buffer.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Random;
+
+import org.junit.Test;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.FileStore;
+import com.metamatrix.common.buffer.StorageManager;
+import com.metamatrix.core.util.UnitTestUtil;
+public class TestFileStorageManager {
+
+ public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
+ FileStorageManager sm = new FileStorageManager();
+ sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
+ if (maxFileSize != null) {
+ sm.setMaxFileSizeDirect(maxFileSize);
+ }
+ if (openFiles != null) {
+ sm.setMaxOpenFiles(openFiles);
+ }
+ sm.initialize();
+ return sm;
+ }
+
+ @Test public void testAddGetBatch1() throws Exception {
+ StorageManager sm = getStorageManager(null, null, null);
+ String tsID = "local,1:0"; //$NON-NLS-1$
+ // Add one batch
+ FileStore store = sm.createFileStore(tsID);
+ writeBytes(store);
+ // Get that batch
+ store.remove();
+ }
+
+ @Test public void testCreatesSpillFiles() throws Exception {
+ FileStorageManager sm = getStorageManager(1024, null, null); // 1KB
+ String tsID = "local,1:0"; //$NON-NLS-1$
+ // Add one batch
+ FileStore store = sm.createFileStore(tsID);
+ writeBytes(store);
+
+ Map<File, RandomAccessFile> cache = sm.getFileCache();
+ assertEquals(1, cache.size());
+
+ writeBytes(store);
+
+ assertEquals(2, cache.size());
+
+ store.remove();
+
+ assertEquals(0, cache.size());
+ }
+
+ static Random r = new Random();
+
+ private void writeBytes(FileStore store)
+ throws MetaMatrixComponentException {
+ byte[] bytes = new byte[2048];
+ r.nextBytes(bytes);
+ long start = store.write(bytes, 0, bytes.length);
+ byte[] bytesRead = new byte[2048];
+ store.readFully(start, bytesRead, 0, bytesRead.length);
+ assertTrue(Arrays.equals(bytes, bytesRead));
+ }
+
+}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestResultsMessage.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestResultsMessage.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestResultsMessage.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -70,11 +70,6 @@
results.add(new BigInteger("300")); //$NON-NLS-1$
results.add(new BigInteger("400")); //$NON-NLS-1$
message.setResults(new List[] {results});
- List schemas = new ArrayList();
- schemas.add("schema1"); //$NON-NLS-1$
- schemas.add("schema2"); //$NON-NLS-1$
- schemas.add("schema3"); //$NON-NLS-1$
- message.setSchemas(schemas);
List warnings = new ArrayList();
warnings.add(new Exception("warning1")); //$NON-NLS-1$
warnings.add(new Exception("warning2")); //$NON-NLS-1$
@@ -134,13 +129,6 @@
assertEquals(new BigInteger("300"), copy.getResults()[0].get(2)); //$NON-NLS-1$
assertEquals(new BigInteger("400"), copy.getResults()[0].get(3)); //$NON-NLS-1$
- assertNotNull(copy.getSchemas());
- assertEquals(3, copy.getSchemas().size());
- // We know that the implementation creates a List
- assertTrue(copy.getSchemas().contains("schema1")); //$NON-NLS-1$
- assertTrue(copy.getSchemas().contains("schema2")); //$NON-NLS-1$
- assertTrue(copy.getSchemas().contains("schema3")); //$NON-NLS-1$
-
assertNotNull(copy.getWarnings());
assertEquals(2, copy.getWarnings().size());
assertEquals(Exception.class, copy.getWarnings().get(0).getClass());
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,10 +22,14 @@
package com.metamatrix.query.parser;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.junit.Test;
+
import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.CompareCriteria;
@@ -58,13 +62,10 @@
import com.metamatrix.query.sql.symbol.Function;
import com.metamatrix.query.sql.symbol.GroupSymbol;
import com.metamatrix.query.sql.symbol.Reference;
-
-import junit.framework.TestCase;
-
-public class TestOptionsAndHints extends TestCase {
+public class TestOptionsAndHints {
/** Select a From db.g1 MAKENOTDEP, db.g2 MAKENOTDEP WHERE a = b */
- public void testOptionMakeNotDepInline4(){
+ @Test public void testOptionMakeNotDepInline4(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("c", "db.g2"); //$NON-NLS-1$ //$NON-NLS-2$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -93,7 +94,7 @@
}
/** Select a From db.g1 JOIN db.g2 MAKEDEP ON a = b */
- public void testOptionMakeDepInline1(){
+ @Test public void testOptionMakeDepInline1(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -118,7 +119,7 @@
}
/** Select a From db.g1 MAKEDEP JOIN db.g2 ON a = b */
- public void testOptionMakeDepInline2(){
+ @Test public void testOptionMakeDepInline2(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -143,7 +144,7 @@
}
/** Select a From (db.g1 MAKEDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKEDEP ON a = c */
- public void testOptionMakeDepInline3(){
+ @Test public void testOptionMakeDepInline3(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
GroupSymbol g3 = new GroupSymbol("db.g3"); //$NON-NLS-1$
@@ -174,7 +175,7 @@
}
/** Select a From db.g1 MAKEDEP, db.g2 MAKEDEP WHERE a = b */
- public void testOptionMakeDepInline4(){
+ @Test public void testOptionMakeDepInline4(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("c", "db.g2"); //$NON-NLS-1$ //$NON-NLS-2$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -202,7 +203,7 @@
query);
}
- public void testOptionMakedepBankOfAmerica() throws Exception {
+ @Test public void testOptionMakedepBankOfAmerica() throws Exception {
String sql = "SELECT A.alert_id " + //$NON-NLS-1$
"FROM (FSK_ALERT AS A MAKEDEP INNER JOIN Core.FSC_PARTY_DIM AS C ON A.primary_entity_key = C.PARTY_KEY) " +//$NON-NLS-1$
"LEFT OUTER JOIN FSK_SCENARIO AS S ON A.scenario_id = S.scenario_id " +//$NON-NLS-1$
@@ -213,7 +214,7 @@
}
/** Select a From db.g1 JOIN db.g2 MAKENOTDEP ON a = b */
- public void testOptionMakeNotDepInline1(){
+ @Test public void testOptionMakeNotDepInline1(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -238,7 +239,7 @@
}
/** Select a From db.g1 MAKENOTDEP JOIN db.g2 ON a = b */
- public void testOptionMakeNotDepInline2(){
+ @Test public void testOptionMakeNotDepInline2(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
@@ -263,7 +264,7 @@
}
/** Select a From (db.g1 MAKENOTDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKENOTDEP ON a = c */
- public void testOptionMakeNotDepInline3(){
+ @Test public void testOptionMakeNotDepInline3(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
GroupSymbol g3 = new GroupSymbol("db.g3"); //$NON-NLS-1$
@@ -293,7 +294,7 @@
query);
}
- public void testDepOptions2() {
+ @Test public void testDepOptions2() {
GroupSymbol a = new GroupSymbol("a"); //$NON-NLS-1$
GroupSymbol b = new GroupSymbol("b"); //$NON-NLS-1$
ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$
@@ -312,7 +313,7 @@
query);
}
- public void testOptionNoCache1(){
+ @Test public void testOptionNoCache1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -334,7 +335,7 @@
query);
}
- public void testOptionNoCache2(){
+ @Test public void testOptionNoCache2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -359,7 +360,7 @@
}
// related to defect 14423
- public void testOptionNoCache3(){
+ @Test public void testOptionNoCache3(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -381,11 +382,11 @@
}
/** SELECT a from g OPTION xyx */
- public void testFailsIllegalOption(){
+ @Test public void testFailsIllegalOption(){
TestParser.helpException("SELECT a from g OPTION xyx"); //$NON-NLS-1$
}
- public void testInsertWithOption() {
+ @Test public void testInsertWithOption() {
Insert insert = new Insert();
insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
List vars = new ArrayList();
@@ -402,7 +403,7 @@
insert);
}
- public void testDeleteWithOption() {
+ @Test public void testDeleteWithOption() {
Delete delete = new Delete();
delete.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
Option option = new Option();
@@ -413,7 +414,7 @@
delete);
}
- public void testUpdateWithOption() {
+ @Test public void testUpdateWithOption() {
Update update = new Update();
update.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
update.addChange(new ElementSymbol("a"), new Reference(0));
@@ -426,7 +427,7 @@
update);
}
- public void testOptionalFromClause1() {
+ @Test public void testOptionalFromClause1() {
String sql = "SELECT * FROM /* optional */ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -444,7 +445,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause1_1() {
+ @Test public void testOptionalFromClause1_1() {
String sql = "SELECT * FROM /* optional*/ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -462,7 +463,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause1_2() {
+ @Test public void testOptionalFromClause1_2() {
String sql = "SELECT * FROM /*optional */ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -480,7 +481,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause1_3() {
+ @Test public void testOptionalFromClause1_3() {
String sql = "SELECT * FROM /* optional */ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -498,7 +499,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause1_4() {
+ @Test public void testOptionalFromClause1_4() {
String sql = "SELECT * /* optional */ FROM /* OptiOnal */ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -516,7 +517,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause1_5() {
+ @Test public void testOptionalFromClause1_5() {
String sql = "SELECT * FROM /* OptiOnal */ t1, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -534,7 +535,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause2() {
+ @Test public void testOptionalFromClause2() {
String sql = "SELECT * FROM t1, /* optional */ t2"; //$NON-NLS-1$
Query query = new Query();
@@ -552,7 +553,7 @@
TestParser.helpTest(sql, "SELECT * FROM t1, /* optional */ t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause3() {
+ @Test public void testOptionalFromClause3() {
String sql = "SELECT * FROM /* optional */ t1 AS a, t2"; //$NON-NLS-1$
Query query = new Query();
@@ -570,7 +571,7 @@
TestParser.helpTest(sql, "SELECT * FROM /* optional */ t1 AS a, t2", query); //$NON-NLS-1$
}
- public void testOptionalFromClause4() {
+ @Test public void testOptionalFromClause4() {
String sql = "SELECT * FROM t1, /* optional */ t2 as a"; //$NON-NLS-1$
Query query = new Query();
@@ -588,7 +589,7 @@
TestParser.helpTest(sql, "SELECT * FROM t1, /* optional */ t2 AS a", query); //$NON-NLS-1$
}
- public void testOptionalFromClause5() {
+ @Test public void testOptionalFromClause5() {
String sql = "SELECT * FROM t1, /* optional */ (select * from t1, t2) as x"; //$NON-NLS-1$
Query query = new Query();
@@ -615,7 +616,7 @@
TestParser.helpTest(sql, "SELECT * FROM t1, /* optional */ (SELECT * FROM t1, t2) AS x", query); //$NON-NLS-1$
}
- public void testOptionalFromClause6() {
+ @Test public void testOptionalFromClause6() {
String sql = "SELECT * FROM t1 INNER JOIN /* optional */ (select a from t1, t2) AS x ON t1.a=x.a"; //$NON-NLS-1$
Query query = new Query();
@@ -648,7 +649,7 @@
TestParser.helpTest(sql, "SELECT * FROM t1 INNER JOIN /* optional */ (SELECT a FROM t1, t2) AS x ON t1.a = x.a", query); //$NON-NLS-1$
}
- public void testOptionalFromClause7() {
+ @Test public void testOptionalFromClause7() {
String sql = "SELECT b FROM t1, /* optional */ (t2 INNER JOIN t3 ON t2.a = t3.a)"; //$NON-NLS-1$
Query query = new Query();
@@ -677,7 +678,7 @@
TestParser.helpTest(sql, "SELECT b FROM t1, /* optional */ (t2 INNER JOIN t3 ON t2.a = t3.a)", query); //$NON-NLS-1$
}
- public void testOptionalFromClause8() {
+ @Test public void testOptionalFromClause8() {
String sql = "SELECT b FROM t1, /* optional */ (/* optional */ (SELECT * FROM t1, t2) AS x INNER JOIN t3 ON x.a = t3.a)"; //$NON-NLS-1$
Query query = new Query();
@@ -715,7 +716,7 @@
TestParser.helpTest(sql, "SELECT b FROM t1, /* optional */ (/* optional */ (SELECT * FROM t1, t2) AS x INNER JOIN t3 ON x.a = t3.a)", query); //$NON-NLS-1$
}
- public void testOptionalFromClause9() {
+ @Test public void testOptionalFromClause9() {
String sql = "SELECT b FROM (t1 LEFT OUTER JOIN /* optional */t2 on t1.a = t2.a) LEFT OUTER JOIN /* optional */t3 on t1.a = t3.a"; //$NON-NLS-1$
Query query = new Query();
@@ -749,7 +750,7 @@
TestParser.helpTest(sql, "SELECT b FROM (t1 LEFT OUTER JOIN /* optional */ t2 ON t1.a = t2.a) LEFT OUTER JOIN /* optional */ t3 ON t1.a = t3.a", query); //$NON-NLS-1$
}
- public void testOptionalFromClause10(){
+ @Test public void testOptionalFromClause10(){
//declare var1
ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
String shortType = new String("short"); //$NON-NLS-1$
@@ -835,7 +836,7 @@
"var2 = SELECT b1 FROM g, /* optional */ h WHERE a2 = 5;"+"\n"+"END"+"\n"+"END", cmd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
- public void testStoredQueryWithOption(){
+ @Test public void testStoredQueryWithOption(){
StoredProcedure storedQuery = new StoredProcedure();
storedQuery.setProcedureName("proc1"); //$NON-NLS-1$
Option option = new Option();
@@ -845,7 +846,7 @@
}
/** Select a From db.g Option SHOWPLAN */
- public void testOptionShowPlan(){
+ @Test public void testOptionShowPlan(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -867,7 +868,7 @@
}
/** Select a From db.g Option PLANONLY */
- public void testOptionPlanOnly(){
+ @Test public void testOptionPlanOnly(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -889,7 +890,7 @@
}
/** Select a From db.g Option makedep a.b.c */
- public void testOptionMakeDependent1(){
+ @Test public void testOptionMakeDependent1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -911,7 +912,7 @@
}
/** Select a From db.g Option makedep a.b.c, d.e.f showplan */
- public void testOptionMakeDependent2(){
+ @Test public void testOptionMakeDependent2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -935,7 +936,7 @@
}
/** Select a From db.g Option makedep a.b.c, d.e.f, x.y.z */
- public void testOptionMakeDependent3(){
+ @Test public void testOptionMakeDependent3(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -959,7 +960,7 @@
}
/** Select a From db.g Option makenotdep a.b.c */
- public void testOptionMakeNotDependent1(){
+ @Test public void testOptionMakeNotDependent1(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -981,7 +982,7 @@
}
/** Select a From db.g Option makenotdep a.b.c, d.e.f showplan */
- public void testOptionMakeNotDependent2(){
+ @Test public void testOptionMakeNotDependent2(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1005,7 +1006,7 @@
}
/** Select a From db.g Option makenotdep a.b.c, d.e.f, x.y.z */
- public void testOptionMakeNotDependent3(){
+ @Test public void testOptionMakeNotDependent3(){
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
From from = new From();
from.addGroup(g);
@@ -1028,7 +1029,7 @@
query);
}
- public void testDepOptions1() {
+ @Test public void testDepOptions1() {
GroupSymbol a = new GroupSymbol("a"); //$NON-NLS-1$
GroupSymbol b = new GroupSymbol("b"); //$NON-NLS-1$
ElementSymbol x = new ElementSymbol("a.x", true); //$NON-NLS-1$
@@ -1049,7 +1050,7 @@
query);
}
- public void testOptionMakeDepInline5(){
+ @Test public void testOptionMakeDepInline5(){
GroupSymbol g1 = new GroupSymbol("db.g1"); //$NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2"); //$NON-NLS-1$
GroupSymbol g3 = new GroupSymbol("db.g3"); //$NON-NLS-1$
@@ -1081,4 +1082,30 @@
TestParser.helpTest(query.toString(), query.toString(), query);
}
+ @Test public void testCache() {
+ String sql = "/* cache */ SELECT * FROM t1"; //$NON-NLS-1$
+
+ Query query = new Query();
+ Select select = new Select();
+ select.addSymbol(new AllSymbol());
+ query.setSelect(select);
+ From from = new From();
+ UnaryFromClause ufc = new UnaryFromClause();
+ from.addClause(ufc);
+ ufc.setGroup(new GroupSymbol("t1")); //$NON-NLS-1$
+ query.setFrom(from);
+ query.setCache(true);
+ TestParser.helpTest(sql, "/* cache */ SELECT * FROM t1", query); //$NON-NLS-1$
+ }
+
+ @Test public void testCache1() {
+ String sql = "/* cache */ execute foo()"; //$NON-NLS-1$
+
+ StoredProcedure sp = new StoredProcedure();
+ sp.setCache(true);
+ sp.setProcedureName("foo"); //$NON-NLS-1$
+
+ TestParser.helpTest(sql, "/* cache */ EXEC foo()", sp); //$NON-NLS-1$
+ }
+
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -120,4 +120,9 @@
this.exceptionOnClose = exceptionOnClose;
}
+ @Override
+ public int available() {
+ return 0;
+ }
+
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -25,16 +25,13 @@
import java.util.Arrays;
import java.util.List;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
+import org.junit.Test;
+
import com.metamatrix.query.unittest.FakeMetadataFactory;
-import junit.framework.TestCase;
-
-public class TestOptionalJoins extends TestCase {
+public class TestOptionalJoins {
- public void testOptionalJoinNode1() {
+ @Test public void testOptionalJoinNode1() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2 where pm1.g1.e1 = 'a'"; //$NON-NLS-1$
@@ -56,7 +53,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode2() {
+ @Test public void testOptionalJoinNode2() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2, pm1.g3 where pm1.g1.e1 = 'a' and pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -84,7 +81,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode3() {
+ @Test public void testOptionalJoinNode3() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
@@ -109,7 +106,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode4() {
+ @Test public void testOptionalJoinNode4() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -134,7 +131,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode5() {
+ @Test public void testOptionalJoinNode5() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -165,7 +162,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode6() {
+ @Test public void testOptionalJoinNode6() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -196,7 +193,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode7() {
+ @Test public void testOptionalJoinNode7() {
// Create query
String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -221,7 +218,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode8() {
+ @Test public void testOptionalJoinNode8() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ (select * from pm1.g2) as X on pm1.g1.e1 = x.e1"; //$NON-NLS-1$
@@ -246,7 +243,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode9() {
+ @Test public void testOptionalJoinNode9() {
// Create query
String sql = "SELECT pm1.g2.e1 FROM pm1.g2, /* optional */ vm1.g1"; //$NON-NLS-1$
@@ -271,7 +268,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode10() {
+ @Test public void testOptionalJoinNode10() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM /* optional */ vm1.g1, pm1.g1"; //$NON-NLS-1$
@@ -296,7 +293,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode11() {
+ @Test public void testOptionalJoinNode11() {
// Create query
String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ vm1.g2 on pm1.g1.e1 = vm1.g2.e1"; //$NON-NLS-1$
@@ -321,7 +318,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode12() {
+ @Test public void testOptionalJoinNode12() {
// Create query
String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN vm1.g1 on pm1.g1.e1 = vm1.g1.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
@@ -346,7 +343,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode13() {
+ @Test public void testOptionalJoinNode13() {
// Create query
String sql = "SELECT count(pm1.g1.e1) FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
@@ -366,7 +363,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode15() {
+ @Test public void testOptionalJoinNode15() {
// Create query
String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
@@ -391,7 +388,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode16() {
+ @Test public void testOptionalJoinNode16() {
// Create query
String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x order by x.e1"; //$NON-NLS-1$
@@ -416,7 +413,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode17() {
+ @Test public void testOptionalJoinNode17() {
// Create query
String sql = "SELECT length(z) FROM /* optional */ pm1.g1, (select distinct e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY y, z) AS x"; //$NON-NLS-1$
@@ -440,7 +437,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode18() {
+ @Test public void testOptionalJoinNode18() {
// Create query
String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
@@ -465,7 +462,7 @@
TestProcessor.helpProcess(plan, dataManager, expected);
}
- public void testOptionalJoinNode19() {
+ @Test public void testOptionalJoinNode19() {
// Create query
String sql = "SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y"; //$NON-NLS-1$
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -491,10 +491,9 @@
private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
BufferManagerImpl bufferMgr = new BufferManagerImpl();
- Properties props = new Properties();
- props.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, String.valueOf(batchSize));
- props.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, String.valueOf(batchSize));
- bufferMgr.initialize(props);
+ bufferMgr.setConnectorBatchSize(batchSize);
+ bufferMgr.setProcessorBatchSize(batchSize);
+ bufferMgr.initialize();
// Add unmanaged memory storage manager
bufferMgr.setStorageManager(new MemoryStorageManager());
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -50,6 +50,7 @@
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.mapping.relational.QueryNode;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.QueryOptimizer;
import com.metamatrix.query.optimizer.TestOptimizer;
import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
@@ -111,9 +112,15 @@
}
}
- static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, CommandContext context) throws SQLException, MetaMatrixCoreException {
+ static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, QueryMetadataInterface metadata) throws SQLException, MetaMatrixCoreException {
// Process twice, testing reset and clone method of Processor plan
for (int i=1; i<=2; i++) {
+
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
+ context.getNextRand(0);
+ context.setProcessDebug(DEBUG);
+ context.setMetadata(metadata);
+
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
@@ -191,18 +198,12 @@
}
private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
- CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
- context.getNextRand(0);
- context.setProcessDebug(DEBUG);
- helpTestProcess(procPlan, expectedRows, null, false, dataMgr, context);
+ helpTestProcess(procPlan, expectedRows, null, false, dataMgr, null);
}
static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults,
ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
- CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
- context.getNextRand(0);
- context.setProcessDebug(DEBUG);
- helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr, context);
+ helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr, null);
}
// Helper to create a list of elements - used in creating sample data
@@ -2262,14 +2263,10 @@
ProcessorPlan plan = getProcedurePlan(userUpdateStr, metadata);
- CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
- context.getNextRand(0);
- context.setProcessDebug(DEBUG);
- context.setMetadata(metadata);
helpTestProcess(plan, 0, new List[] {
Arrays.asList(new Object[] {new Integer(240)}),
- Arrays.asList(new Object[] {new Integer(637)})}, false, dataMgr, context);
+ Arrays.asList(new Object[] {new Integer(637)})}, false, dataMgr, metadata);
}
private FakeMetadataFacade createProcedureMetadata(String procedure) {
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/BlockingFakeRelationalNode.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/BlockingFakeRelationalNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/BlockingFakeRelationalNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -30,7 +30,10 @@
public class BlockingFakeRelationalNode extends FakeRelationalNode {
- private boolean blocked = false;
+ private int count = 1;
+
+ private int returnPeriod = 2;
+
/**
* @param nodeID
* @param data
@@ -51,13 +54,15 @@
public BlockingFakeRelationalNode(int nodeID, TupleSource source, int batchSize) {
super(nodeID, source, batchSize);
}
+
+ public void setReturnPeriod(int returnPeriod) {
+ this.returnPeriod = returnPeriod;
+ }
public TupleBatch nextBatchDirect() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
- if(! blocked) {
- blocked = true;
- throw BlockedException.INSTANCE;
+ if (count++%returnPeriod != 0) {
+ throw BlockedException.INSTANCE;
}
- blocked = false;
return super.nextBatchDirect();
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -37,26 +37,23 @@
public class NodeTestUtil {
static BufferManager getTestBufferManager(long bytesAvailable, int procBatchSize, int connectorBatchSize) {
-
+ BufferManagerImpl bufferManager = new BufferManagerImpl();
+ bufferManager.setProcessorBatchSize(procBatchSize);
+ bufferManager.setConnectorBatchSize(connectorBatchSize);
// Get the properties for BufferManager
- Properties bmProps = new Properties();
- bmProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
- bmProps.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, "" + connectorBatchSize); //$NON-NLS-1$
- return createBufferManager(bmProps);
+ return createBufferManager(bufferManager);
}
static BufferManager getTestBufferManager(long bytesAvailable, int procBatchSize) {
-
+ BufferManagerImpl bufferManager = new BufferManagerImpl();
+ bufferManager.setProcessorBatchSize(procBatchSize);
// Get the properties for BufferManager
- Properties bmProps = new Properties();
- bmProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, "" + procBatchSize); //$NON-NLS-1$
- return createBufferManager(bmProps);
+ return createBufferManager(bufferManager);
}
- static BufferManager createBufferManager(Properties bmProps) {
- BufferManagerImpl bufferManager = new BufferManagerImpl();
+ static BufferManager createBufferManager(BufferManagerImpl bufferManager) {
try {
- bufferManager.initialize(bmProps);
+ bufferManager.initialize();
} catch (MetaMatrixComponentException e) {
throw new RuntimeException(e);
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -243,6 +243,11 @@
}
return null;
}
+
+ @Override
+ public int available() {
+ return 0;
+ }
}
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,6 +22,8 @@
package com.metamatrix.query.processor.relational;
+import static org.junit.Assert.*;
+
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,7 +31,7 @@
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -46,6 +48,7 @@
import com.metamatrix.query.function.aggregate.NullFilter;
import com.metamatrix.query.processor.FakeDataManager;
import com.metamatrix.query.processor.FakeTupleSource;
+import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -53,16 +56,8 @@
import com.metamatrix.query.sql.symbol.Function;
import com.metamatrix.query.util.CommandContext;
-public class TestGroupingNode extends TestCase {
+public class TestGroupingNode {
- // ################################## FRAMEWORK ################################
-
- public TestGroupingNode(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
public static TupleSource createTupleSource1() {
List<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
symbols.add(new ElementSymbol("col1")); //$NON-NLS-1$
@@ -93,24 +88,24 @@
private void helpProcess(BufferManager mgr,
GroupingNode node,
CommandContext context,
- List[] expected) throws MetaMatrixComponentException,
+ List[] expected, ProcessorDataManager dataMgr) throws MetaMatrixComponentException,
BlockedException,
MetaMatrixProcessingException {
TupleSource dataSource = createTupleSource1();
- helpProcess(mgr, node, context, expected, dataSource);
+ helpProcess(mgr, node, context, expected, dataSource, dataMgr);
}
private void helpProcess(BufferManager mgr,
GroupingNode node,
CommandContext context,
List[] expected,
- TupleSource dataSource) throws MetaMatrixComponentException,
+ TupleSource dataSource, ProcessorDataManager dataMgr) throws MetaMatrixComponentException,
BlockedException,
MetaMatrixProcessingException {
RelationalNode dataNode = new FakeRelationalNode(0, dataSource, mgr.getProcessorBatchSize());
dataNode.setElements(dataSource.getSchema());
- dataNode.initialize(context, mgr, null);
- node.addChild(dataNode);
+ node.addChild(dataNode);
+ node.initialize(context, mgr, dataMgr);
node.open();
int currentRow = 1;
@@ -134,7 +129,7 @@
// ################################## ACTUAL TESTS ################################
- public void test1() throws Exception {
+ @Test public void test1() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
// Set up
@@ -159,10 +154,9 @@
node.setElements(outputElements);
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(2), new Integer(1), new Integer(1), new Long(3), new Long(3), new Double(3.0), new Double(3.0), new Integer(3), new Integer(3), new Integer(3), new Integer(3) }),
@@ -175,7 +169,7 @@
Arrays.asList(new Object[] { new Integer(6), new Integer(2), new Integer(2), new Integer(2), new Long(7), new Long(7), new Double(3.5), new Double(3.5), new Integer(3), new Integer(3), new Integer(4), new Integer(4) })
};
- helpProcess(mgr, node, context, expected);
+ helpProcess(mgr, node, context, expected, null);
//ensure that the distinct input type is correct
AggregateFunction[] functions = node.getFunctions();
@@ -184,12 +178,11 @@
assertEquals(DataTypeManager.DefaultDataClasses.INTEGER, ((ElementSymbol)dup.getElements().get(0)).getType());
}
- public void test2() throws Exception {
+ @Test public void test2() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -202,17 +195,16 @@
Arrays.asList(new Object[] { new Integer(6), new Integer(2) })
};
- helpProcess(mgr, node, context, expected);
+ helpProcess(mgr, node, context, expected, null);
}
// Same as test2, but uses processor batch size smaller than number of groups
- public void test3() throws Exception {
+ @Test public void test3() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
((BufferManagerImpl)mgr).setProcessorBatchSize(5);
GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -225,10 +217,10 @@
Arrays.asList(new Object[] { new Integer(6), new Integer(2) })
};
- helpProcess(mgr, node, context, expected);
+ helpProcess(mgr, node, context, expected, null);
}
- public void testDefect5769() throws Exception {
+ @Test public void testDefect5769() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
ElementSymbol bigDecimal = new ElementSymbol("value"); //$NON-NLS-1$
@@ -244,7 +236,6 @@
// Set grouping elements to null
node.setGroupingElements(null);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] data = new List[] {
Arrays.asList(new Object[] { new BigDecimal("0.0") }), //$NON-NLS-1$
@@ -261,10 +252,10 @@
List symbols = new ArrayList();
symbols.add(bigDecimal);
TupleSource dataSource = new FakeTupleSource(symbols, data);
- helpProcess(mgr, node, context, expected, dataSource);
+ helpProcess(mgr, node, context, expected, dataSource, null);
}
- public void testdefect9842() throws Exception {
+ @Test public void testdefect9842() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
ElementSymbol col1 = new ElementSymbol("col1"); //$NON-NLS-1$
@@ -285,7 +276,6 @@
groupingElements.add(col1); //$NON-NLS-1$
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] data = new List[] {
Arrays.asList(new Object[] { new Integer(1), new BigDecimal("0.0") }), //$NON-NLS-1$
@@ -304,7 +294,7 @@
symbols.add(col1);
symbols.add(bigDecimal);
TupleSource dataSource = new FakeTupleSource(symbols, data);
- helpProcess(mgr, node, context, expected, dataSource);
+ helpProcess(mgr, node, context, expected, dataSource, null);
}
private void helpTestLookupFunctionInAggregate(int batchSize) throws Exception {
@@ -345,8 +335,6 @@
valueMap.put(new Integer(4), new Integer(5));
dataMgr.defineCodeTable("pm1.g1", "e1", "e2", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- node.initialize(context, mgr, dataMgr);
-
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1), new Long(4), new Long(4) }),
Arrays.asList(new Object[] { new Integer(0), new Integer(1), new Long(5), new Long(5) }),
@@ -358,7 +346,7 @@
Arrays.asList(new Object[] { new Integer(6), new Integer(2), new Long(9), new Long(9) })
};
- helpProcess(mgr, node, context, expected);
+ helpProcess(mgr, node, context, expected, dataMgr);
}
public void helpTestEmptyGroup(boolean groupBy) throws Exception {
@@ -383,7 +371,6 @@
node.setGroupingElements(groupingElements);
}
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] data = new List[] {
};
@@ -400,28 +387,27 @@
symbols.add(col1);
symbols.add(bigDecimal);
TupleSource dataSource = new FakeTupleSource(symbols, data);
- helpProcess(mgr, node, context, expected, dataSource);
+ helpProcess(mgr, node, context, expected, dataSource, null);
}
- public void testTestEmptyGroupWithoutGroupBy() throws Exception {
+ @Test public void testTestEmptyGroupWithoutGroupBy() throws Exception {
helpTestEmptyGroup(false);
}
- public void testTestEmptyGroupWithGroupBy() throws Exception {
+ @Test public void testTestEmptyGroupWithGroupBy() throws Exception {
helpTestEmptyGroup(true);
}
- public void testLookupFunctionMultipleBatches() throws Exception {
+ @Test public void testLookupFunctionMultipleBatches() throws Exception {
helpTestLookupFunctionInAggregate(3);
}
- public void testDupSort() throws Exception {
+ @Test public void testDupSort() throws Exception {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
GroupingNode node = getExampleGroupingNode();
node.setRemoveDuplicates(true);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- node.initialize(context, mgr, null);
List[] expected = new List[] {
Arrays.asList(new Object[] { null, new Integer(1) }),
@@ -434,7 +420,7 @@
Arrays.asList(new Object[] { new Integer(6), new Integer(2) })
};
- helpProcess(mgr, node, context, expected);
+ helpProcess(mgr, node, context, expected, null);
}
private GroupingNode getExampleGroupingNode() {
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -217,5 +217,9 @@
? null
: Arrays.asList(new Object[] {new Integer(currentRow), Integer.toString(currentRow)});
}
+ @Override
+ public int available() {
+ return 0;
+ }
}
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.TreeSet;
import org.junit.Test;
@@ -53,7 +54,8 @@
BufferManager mgr = NodeTestUtil.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- FakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
+ BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(2, data);
+ dataNode.setReturnPeriod(3);
dataNode.setElements(elements);
dataNode.initialize(context, mgr, null);
@@ -127,38 +129,31 @@
elements.add(es1);
int rows = batches * BATCH_SIZE;
-
+
+ ListNestedSortComparator comparator = new ListNestedSortComparator(new int[] {0}, OrderBy.DESC);
+
List[] expected = new List[rows];
List[] data = new List[rows];
+ TreeSet<List> distinct = new TreeSet<List>(comparator);
for(int i=0; i<rows; i++) {
- data[i] = new ArrayList();
- expected[i] = new ArrayList();
- Integer value = new Integer((i*51) % 12321);
- data[i].add(value);
- expected[i].add(value);
+ Integer value = new Integer((i*51) % 11);
+ data[i] = Arrays.asList(value);
+ expected[i] = Arrays.asList(value);
+ distinct.add(Arrays.asList(value));
}
+ List[] expectedDistinct = distinct.toArray(new List[distinct.size()]);
List sortElements = new ArrayList();
sortElements.add(es1);
List sortTypes = new ArrayList();
- sortTypes.add(new Boolean(OrderBy.ASC));
+ sortTypes.add(new Boolean(OrderBy.DESC));
- ListNestedSortComparator comparator = new ListNestedSortComparator(new int[] {0}, OrderBy.ASC);
Arrays.sort(expected, comparator);
for (Mode mode : Mode.values()) {
- helpTestSort(elements, data, sortElements, sortTypes, expected, mode);
+ helpTestSort(elements, data, sortElements, sortTypes, mode==Mode.SORT?expected:expectedDistinct, mode);
}
-
- comparator = new ListNestedSortComparator(new int[] {0}, OrderBy.DESC);
- Arrays.sort(expected, comparator);
- sortTypes.clear();
- sortTypes.add(new Boolean(OrderBy.DESC));
-
- for (Mode mode : Mode.values()) {
- helpTestSort(elements, data, sortElements, sortTypes, expected, mode);
- }
}
@Test public void testNoSort() throws Exception {
@@ -276,7 +271,7 @@
}
@Test public void testBiggerSort() throws Exception {
- helpTestAllSorts(10);
+ helpTestAllSorts(100);
}
@Test public void testAllSort() throws Exception {
@@ -300,6 +295,7 @@
}
tsid.addTuple(Arrays.asList(2));
+ tsid.addTuple(Arrays.asList(3));
su.sort();
assertEquals(Arrays.asList(2), ts.nextTuple());
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -155,8 +155,8 @@
*/
try {
state.requestMore();
- } catch (IllegalStateException e) {
-
+ } catch (Throwable e) {
+ // catches the assertion error
}
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -67,7 +67,7 @@
core.setConnectorManagerRepository(repo);
core.setTransactionService(new FakeTransactionService());
- core.start(Mockito.mock(DQPConfiguration.class));
+ core.start(new DQPConfiguration());
}
@After public void tearDown() throws Exception {
@@ -196,7 +196,7 @@
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_OFF);
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
}
@@ -224,7 +224,7 @@
}
Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ ResultsMessage results = message.get(5000, TimeUnit.MILLISECONDS);
if (results.getException() != null) {
throw results.getException();
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -158,7 +158,7 @@
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
- AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
+ AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, "connID", workItem); //$NON-NLS-1$
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
@@ -173,7 +173,7 @@
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
- AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
+ AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1);
DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null,"connID", workItem); //$NON-NLS-1$
workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -58,7 +58,7 @@
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
// Create components
- PreparedPlanCache prepPlanCache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
DQPCore requestMgr = new DQPCore();
requestMgr.setTransactionService(new FakeTransactionService());
@@ -115,7 +115,7 @@
private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql, VDBMetaData vdb) throws Exception {
// Create components
- PreparedPlanCache prepPlanCache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Initialize components
MetaDataProcessor mdProc = new MetaDataProcessor(new DQPCore(), prepPlanCache, "MyVDB", 1);
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -30,8 +30,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.dqp.internal.process.PreparedPlanCache.CacheID;
-import org.teiid.dqp.internal.process.PreparedPlanCache.PreparedPlan;
+import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.query.analysis.AnalysisRecord;
@@ -57,25 +56,25 @@
//====Tests====//
@Test public void testPutPreparedPlan(){
- PreparedPlanCache cache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
CacheID id = new CacheID(token, pi, EXAMPLE_QUERY + 1);
//No PreparedPlan at the begining
- assertNull(cache.getPreparedPlan(id));
+ assertNull(cache.get(id));
//create one
- cache.putPreparedPlan(id, true, new PreparedPlan());
+ cache.put(id, true, new PreparedPlan());
//should have one now
- assertNotNull("Unable to get prepared plan from cache", cache.getPreparedPlan(id)); //$NON-NLS-1$
+ assertNotNull("Unable to get prepared plan from cache", cache.get(id)); //$NON-NLS-1$
}
- @Test public void testGetPreparedPlan(){
- PreparedPlanCache cache = new PreparedPlanCache();
+ @Test public void testget(){
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
helpPutPreparedPlans(cache, token, 0, 10);
helpPutPreparedPlans(cache, token2, 0, 15);
//read an entry for session2 (token2)
- PreparedPlan pPlan = cache.getPreparedPlan(new CacheID(token2, pi, EXAMPLE_QUERY + 12));
+ PreparedPlan pPlan = cache.get(new CacheID(token2, pi, EXAMPLE_QUERY + 12));
assertNotNull("Unable to get prepared plan from cache", pPlan); //$NON-NLS-1$
assertEquals("Error getting plan from cache", new RelationalPlan(new ProjectNode(12)).toString(), pPlan.getPlan().toString()); //$NON-NLS-1$
assertEquals("Error getting command from cache", EXAMPLE_QUERY + 12, pPlan.getCommand().toString()); //$NON-NLS-1$
@@ -84,30 +83,30 @@
}
@Test public void testClearAll(){
- PreparedPlanCache cache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
//create one for each session token
helpPutPreparedPlans(cache, token, 1, 1);
helpPutPreparedPlans(cache, token2, 1, 1);
//should have one
- assertNotNull("Unable to get prepared plan from cache for token", cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
+ assertNotNull("Unable to get prepared plan from cache for token", cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
cache.clearAll();
//should not exist for token
- assertNull("Failed remove from cache", cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
+ assertNull("Failed remove from cache", cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
//should not exist for token2
- assertNull("Unable to get prepared plan from cache for token2", cache.getPreparedPlan(new CacheID(token2, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
+ assertNull("Unable to get prepared plan from cache for token2", cache.get(new CacheID(token2, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
}
@Test public void testMaxSize(){
- PreparedPlanCache cache = new PreparedPlanCache(100);
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(100);
helpPutPreparedPlans(cache, token, 0, 101);
//the first one should be gone because the max size is 100
- assertNull(cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
+ assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
- assertNotNull(cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
+ assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
helpPutPreparedPlans(cache, token, 102, 50);
//"sql12" should still be there based on lru policy
- assertNotNull(cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
+ assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 12)));
helpPutPreparedPlans(cache, token2, 0, 121);
helpPutPreparedPlans(cache, token, 0, 50);
@@ -116,31 +115,31 @@
@Test public void testZeroSizeCache() {
// Create with 0 size cache
- PreparedPlanCache cache = new PreparedPlanCache(0);
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>(0);
assertEquals(0, cache.getSpaceAllowed());
// Add 1 plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 0, 1);
- assertNull(cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
+ assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 0)));
assertEquals(0, cache.getSpaceUsed());
// Add another plan and verify it is not in the cache
helpPutPreparedPlans(cache, token, 1, 1);
- assertNull(cache.getPreparedPlan(new CacheID(token, pi, EXAMPLE_QUERY + 1)));
+ assertNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + 1)));
assertEquals(0, cache.getSpaceUsed());
}
// set init size to negative number, which should default to 100 (default)
@Test public void testNegativeSizeCacheUsesDefault() {
- PreparedPlanCache negativeSizedCache = new PreparedPlanCache(-1000);
- PreparedPlanCache defaultSizedCache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> negativeSizedCache = new SessionAwareCache<PreparedPlan>(-1000);
+ SessionAwareCache<PreparedPlan> defaultSizedCache = new SessionAwareCache<PreparedPlan>();
assertEquals(defaultSizedCache.getSpaceAllowed(), negativeSizedCache.getSpaceAllowed());
- assertEquals(PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL, negativeSizedCache.getSpaceAllowed());
+ assertEquals(SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL, negativeSizedCache.getSpaceAllowed());
}
//====Help methods====//
- private void helpPutPreparedPlans(PreparedPlanCache cache, DQPWorkContext session, int start, int count){
+ private void helpPutPreparedPlans(SessionAwareCache<PreparedPlan> cache, DQPWorkContext session, int start, int count){
for(int i=0; i<count; i++){
Command dummy;
try {
@@ -151,7 +150,7 @@
CacheID id = new CacheID(session, pi, dummy.toString());
PreparedPlan pPlan = new PreparedPlan();
- cache.putPreparedPlan(id, true, pPlan);
+ cache.put(id, true, pPlan);
pPlan.setCommand(dummy);
pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
Map props = new HashMap();
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -64,34 +64,16 @@
private static boolean DEBUG = false;
- static class TestablePreparedPlanCache extends PreparedPlanCache {
-
- int hitCount;
-
- @Override
- public PreparedPlan getPreparedPlan(CacheID id) {
- PreparedPlan result = super.getPreparedPlan(id);
- if (result != null) {
- hitCount++;
- }
- return result;
- }
-
- }
-
- public void teardown() {
- DQPWorkContext.setWorkContext(null);
- }
-
+
static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, VDBMetaData vdb) throws Exception {
helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement, false, vdb);
}
static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement, boolean isSessionSpecific, VDBMetaData vdb) throws Exception {
- helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, (TestablePreparedPlanCache)null, callableStatement, isSessionSpecific, /* isAlreadyCached */false, vdb);
+ helpTestProcessing(preparedSql, values, expected, dataManager, (CapabilitiesFinder)null, metadata, null, callableStatement, isSessionSpecific, /* isAlreadyCached */false, vdb);
}
- static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, TestablePreparedPlanCache prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached, VDBMetaData vdb) throws Exception {
+ static public void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, boolean callableStatement, boolean isSessionSpecific, boolean isAlreadyCached, VDBMetaData vdb) throws Exception {
if ( dataManager == null ) {
// Construct data manager with data
dataManager = new FakeDataManager();
@@ -103,7 +85,7 @@
}
if ( prepPlanCache == null ) {
- prepPlanCache = new TestablePreparedPlanCache();
+ prepPlanCache = new SessionAwareCache<PreparedPlan>();
}
// expected cache hit count
@@ -115,9 +97,9 @@
* get the plan twice. Otherwise, we want it to be 1.
*/
if ( isAlreadyCached ) {
- exHitCount = prepPlanCache.hitCount + 2;
+ exHitCount = prepPlanCache.getCacheHitCount() + 2;
} else {
- exHitCount = prepPlanCache.hitCount + 1;
+ exHitCount = prepPlanCache.getCacheHitCount() + 1;
}
//Create plan or used cache plan if isPlanCached
@@ -130,7 +112,7 @@
plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, capFinder, metadata, prepPlanCache, SESSION_ID, callableStatement, false,vdb);
//make sure the plan is only created once
- assertEquals("should reuse the plan", exHitCount, prepPlanCache.hitCount); //$NON-NLS-1$
+ assertEquals("should reuse the plan", exHitCount, prepPlanCache.getCacheHitCount()); //$NON-NLS-1$
// If we are using FakeDataManager, stop command recording to prevent
// duplicate commands
@@ -158,7 +140,7 @@
* created and the hit count will be unchanged.
*/
if ( !isSessionSpecific ) exHitCount++;
- assertEquals(exHitCount, prepPlanCache.hitCount);
+ assertEquals(exHitCount, prepPlanCache.getCacheHitCount());
}
@Test public void testWhere() throws Exception {
@@ -220,12 +202,12 @@
List values = Arrays.asList(0);
- PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new PreparedPlanCache(), SESSION_ID, false, false,FakeMetadataFactory.example1VDB());
+ PreparedStatementRequest plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new SessionAwareCache<PreparedPlan>(), SESSION_ID, false, false,FakeMetadataFactory.example1VDB());
TestOptimizer.checkNodeTypes(plan.processPlan, TestOptimizer.FULL_PUSHDOWN);
}
- static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values, PreparedPlanCache prepPlanCache)
+ static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values, SessionAwareCache<PreparedPlan> prepPlanCache)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
@@ -233,7 +215,7 @@
}
static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
- PreparedPlanCache prepPlanCache, int conn)
+ SessionAwareCache<PreparedPlan> prepPlanCache, int conn)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
@@ -243,7 +225,7 @@
}
static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
- CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb)
+ CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb)
throws MetaMatrixComponentException, QueryParserException,
QueryResolverException, QueryValidatorException,
QueryPlannerException {
@@ -291,7 +273,7 @@
values.add("a"); //$NON-NLS-1$
//Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ helpGetProcessorPlan(preparedSql, values, new SessionAwareCache<PreparedPlan>());
}
/** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)*/
@@ -302,7 +284,7 @@
List values = Arrays.asList("a"); //$NON-NLS-1$
//Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ helpGetProcessorPlan(preparedSql, values, new SessionAwareCache<PreparedPlan>());
}
/** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = ? AND pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?) */
@@ -313,7 +295,7 @@
List values = Arrays.asList("d", "c"); //$NON-NLS-1$ //$NON-NLS-2$
//Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ helpGetProcessorPlan(preparedSql, values, new SessionAwareCache<PreparedPlan>());
}
/** SELECT X.e1 FROM (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = ?) as X */
@@ -326,13 +308,13 @@
values.add("d"); //$NON-NLS-1$
//Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ helpGetProcessorPlan(preparedSql, values, new SessionAwareCache<PreparedPlan>());
}
@Test public void testValidateWrongValues() throws Exception {
// Create query
String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
- TestablePreparedPlanCache prepCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepCache = new SessionAwareCache<PreparedPlan>();
//wrong type
try{
@@ -345,7 +327,7 @@
}catch(QueryResolverException qe){
assertEquals("Error converting parameter number 1 with value \"x\" to expected type integer.", qe.getMessage()); //$NON-NLS-1$
}
- assertEquals(0, prepCache.hitCount);
+ assertEquals(0, prepCache.getCacheHitCount());
//test cached plan
try{
@@ -358,7 +340,7 @@
assertEquals("The number of bound values '2' does not match the number of parameters '1' in the prepared statement.", qe.getMessage()); //$NON-NLS-1$
}
- assertEquals(1, prepCache.hitCount);
+ assertEquals(1, prepCache.getCacheHitCount());
//wrong number of values
try{
@@ -379,7 +361,7 @@
List values = Arrays.asList("0"); //$NON-NLS-1$
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ helpGetProcessorPlan(preparedSql, values, new SessionAwareCache<PreparedPlan>());
}
/**
@@ -391,13 +373,13 @@
List values = Arrays.asList("0"); //$NON-NLS-1$
- TestablePreparedPlanCache planCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> planCache = new SessionAwareCache<PreparedPlan>();
helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true, FakeMetadataFactory.example1VDB());
//make sure the plan wasn't reused
- assertEquals(0, planCache.hitCount);
+ assertEquals(0, planCache.getCacheHitCount());
}
@Test public void testUpdateProcedureCriteria() throws Exception {
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -29,7 +29,6 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.dqp.internal.process.TestPreparedStatement.TestablePreparedPlanCache;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
@@ -53,7 +52,7 @@
String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
- TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Construct data manager with data
HardcodedDataManager dataManager = new HardcodedDataManager();
@@ -115,7 +114,7 @@
// Create query
String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
- TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
@@ -211,7 +210,7 @@
// Create query
String preparedSql = "UPDATE vm1.g1 SET vm1.g1.e2=? WHERE vm1.g1.e1=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
- TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
@@ -304,7 +303,7 @@
// Create query
String preparedSql = "UPDATE pm1.g1 SET pm1.g1.e1=?, pm1.g1.e3=? WHERE pm1.g1.e2=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
- TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
@@ -427,7 +426,7 @@
// Create query
String preparedSql = "UPDATE vm1.g1 SET vm1.g1.e1=?, vm1.g1.e3=? WHERE vm1.g1.e2=?"; //$NON-NLS-1$
// Create a testable prepared plan cache
- TestablePreparedPlanCache prepPlanCache = new TestablePreparedPlanCache();
+ SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>();
// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -148,8 +148,7 @@
assertEquals("5", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
}
-
- private Request helpProcessMessage(RequestMessage message, PreparedPlanCache cache, DQPWorkContext workContext) throws QueryValidatorException,
+ private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,
QueryParserException,
QueryResolverException,
MetaMatrixComponentException,
@@ -183,7 +182,7 @@
*/
public void testProcessRequestPreparedStatement() throws Exception {
QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
- PreparedPlanCache cache = new PreparedPlanCache();
+ SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>();
//Try before plan is cached.
Modified: branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -15,9 +15,9 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminFactory;
import org.teiid.adminapi.ConnectionPoolStatistics;
import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.PropertyDefinition;
@@ -30,7 +30,7 @@
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.core.util.UnitTestUtil;
-
+@Ignore
public class TestConnectorBindings extends BaseConnection {
ServerDatasourceConnection ds;
com.metamatrix.jdbc.api.Connection conn;
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -37,6 +37,11 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeID;
+import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
import com.metamatrix.common.config.model.BasicConnectorBinding;
@@ -822,7 +827,14 @@
return getUserPreferences().getProperty(DQPEmbeddedProperties.PROCESSNAME);
}
-
+
+ public String getProcessorBatchSize() {
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_PROCESSOR_BATCH_SIZE, String.valueOf(BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE));
+ }
+ public String getConnectorBatchSize() {
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_CONNECTOR_BATCH_SIZE, String.valueOf(BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE));
+ }
+
public void unregister(VDBLifeCycleListener listener) {
this.vdbLifeCycleListeners.remove(listener);
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -35,28 +35,14 @@
import javax.security.auth.Subject;
import org.teiid.dqp.internal.process.DQPConfiguration;
-import org.teiid.dqp.internal.process.PreparedPlanCache;
-public class TeiidManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation, DQPConfiguration {
+public class TeiidManagedConnectionFactory extends DQPConfiguration implements ManagedConnectionFactory,ResourceAdapterAssociation {
private static final long serialVersionUID = -3728121947515526429L;
private TeiidResourceAdapter ra;
private PrintWriter log;
private TeiidConnectionFactory connFactory;
- private String processName = "localhost";
- private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
- private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
- private boolean optionDebugAllowed = true;
- private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
- private int lobChunkSizeInKB = 100;
- private int preparedPlanCacheMaxCount = PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL;
- private int codeTablesMaxCount = DEFAULT_MAX_CODE_TABLES;
- private int codeTablesMaxRowsPerTable = DEFAULT_MAX_CODE_TABLE_RECORDS;
- private int codeTablesMaxRows = DEFAULT_MAX_CODE_RECORDS;
- private String bindAddress = "localhost";
- private int portNumber = 31000;
-
@Override
public Object createConnectionFactory() throws ResourceException {
return new ResourceException("Resource Adapter does not currently support running in a non-managed environment.");
@@ -97,111 +83,4 @@
public void setResourceAdapter(ResourceAdapter arg0) throws ResourceException {
this.ra = (TeiidResourceAdapter)arg0;
}
-
- public String getProcessName() {
- return processName;
- }
-
- public void setProcessName(String processName) {
- this.processName = processName;
- }
-
- @Override
- public int getMaxThreads() {
- return maxThreads;
- }
-
- public void setMaxThreads(Integer maxThreads) {
- this.maxThreads = maxThreads;
- }
-
- @Override
- public int getTimeSliceInMilli() {
- return timeSliceInMilli;
- }
-
- public void setTimeSliceInMilli(Integer timeSliceInMilli) {
- this.timeSliceInMilli = timeSliceInMilli;
- }
-
- @Override
- public boolean isOptionDebugAllowed() {
- return optionDebugAllowed;
- }
-
- public void setOptionDebugAllowed(Boolean optionDebugAllowed) {
- this.optionDebugAllowed = optionDebugAllowed;
- }
-
- @Override
- public int getMaxRowsFetchSize() {
- return maxRowsFetchSize;
- }
-
- public void setMaxRowsFetchSize(Integer maxRowsFetchSize) {
- this.maxRowsFetchSize = maxRowsFetchSize;
- }
-
- @Override
- public int getLobChunkSizeInKB() {
- return lobChunkSizeInKB;
- }
-
- public void setLobChunkSizeInKB(Integer lobChunkSizeInKB) {
- this.lobChunkSizeInKB = lobChunkSizeInKB;
- }
-
- @Override
- public int getPreparedPlanCacheMaxCount() {
- return preparedPlanCacheMaxCount;
- }
-
- public void setPreparedPlanCacheMaxCount(Integer preparedPlanCacheMaxCount) {
- this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
- }
-
- @Override
- public int getCodeTablesMaxCount() {
- return codeTablesMaxCount;
- }
-
- public void setCodeTablesMaxCount(Integer codeTablesMaxCount) {
- this.codeTablesMaxCount = codeTablesMaxCount;
- }
-
- @Override
- public int getCodeTablesMaxRowsPerTable() {
- return codeTablesMaxRowsPerTable;
- }
-
- public void setCodeTablesMaxRowsPerTable(Integer codeTablesMaxRowsPerTable) {
- this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
- }
-
- @Override
- public int getCodeTablesMaxRows() {
- return codeTablesMaxRows;
- }
-
- public void setCodeTablesMaxRows(Integer codeTablesMaxRows) {
- this.codeTablesMaxRows = codeTablesMaxRows;
- }
-
- @Override
- public String getBindAddress() {
- return bindAddress;
- }
-
- public void setBindAddress(String bindAddress) {
- this.bindAddress = bindAddress;
- }
-
- @Override
- public int getPortNumber() {
- return portNumber;
- }
-
- public void setPortNumber(Integer portNumber) {
- this.portNumber = portNumber;
- }
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -25,14 +25,12 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Properties;
import org.teiid.dqp.internal.cache.DQPContextCache;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.buffer.impl.BufferManagerImpl;
import com.metamatrix.common.buffer.impl.FileStorageManager;
import com.metamatrix.common.buffer.impl.MemoryStorageManager;
@@ -47,7 +45,8 @@
* for file service access.
*/
public class BufferServiceImpl implements BufferService, Serializable {
-
+ private static final int DEFAULT_MAX_OPEN_FILES = 256;
+
// Instance
private BufferManagerImpl bufferMgr;
private File bufferDir;
@@ -57,9 +56,11 @@
private int processorBatchSize = 2000;
private int connectorBatchSize = 2000;
private CacheFactory cacheFactory;
+ private int maxOpenFiles = DEFAULT_MAX_OPEN_FILES;
+ private long maxFileSize = 2L; // 2GB
+ private int maxProcessingBatches = BufferManager.DEFAULT_MAX_PROCESSING_BATCHES;
+ private int maxReserveBatches = BufferManager.DEFAULT_RESERVE_BUFFERS;
-
-
/**
* Clean the file storage directory on startup
* @param dir
@@ -76,24 +77,24 @@
public void start(){
try {
- // Set up buffer configuration properties
- Properties bufferProps = new Properties();
- bufferProps.setProperty(BufferManager.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
- bufferProps.setProperty(BufferManager.PROCESSOR_BATCH_SIZE, String.valueOf(processorBatchSize));
- bufferProps.setProperty(BufferManager.CONNECTOR_BATCH_SIZE, String.valueOf(connectorBatchSize));
-
// Construct and initialize the buffer manager
this.bufferMgr = new BufferManagerImpl();
- this.bufferMgr.initialize(bufferProps);
+ this.bufferMgr.setConnectorBatchSize(Integer.valueOf(connectorBatchSize));
+ this.bufferMgr.setProcessorBatchSize(Integer.valueOf(processorBatchSize));
+ this.bufferMgr.setMaxReserveBatches(maxReserveBatches);
+ this.bufferMgr.setMaxProcessingBatches(maxProcessingBatches);
+ this.bufferMgr.initialize();
+
// If necessary, add disk storage manager
if(useDisk) {
// Get the properties for FileStorageManager and create.
- Properties fsmProps = new Properties();
- fsmProps.setProperty(BufferManager.BUFFER_STORAGE_DIRECTORY, bufferDir.getCanonicalPath());
- StorageManager fsm = new FileStorageManager();
- fsm.initialize(fsmProps);
+ FileStorageManager fsm = new FileStorageManager();
+ fsm.setStorageDirectory(bufferDir.getCanonicalPath());
+ fsm.setMaxFileSize(maxFileSize);
+ fsm.setMaxOpenFiles(maxOpenFiles);
+ fsm.initialize();
this.bufferMgr.setStorageManager(fsm);
// start the file storage manager in clean state
@@ -183,4 +184,20 @@
public void setCacheFactory(CacheFactory cf) {
this.cacheFactory = cf;
}
+
+ public void setMaxFileSize(long maxFileSize) {
+ this.maxFileSize = maxFileSize;
+ }
+
+ public void setMaxOpenFiles(int maxOpenFiles) {
+ this.maxOpenFiles = maxOpenFiles;
+ }
+
+ public void setMaxProcessingBatches(int maxProcessingBatches) {
+ this.maxProcessingBatches = maxProcessingBatches;
+ }
+
+ public void setMaxReserveBatches(int maxReserveBatches) {
+ this.maxReserveBatches = maxReserveBatches;
+ }
}
Modified: branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -4,6 +4,7 @@
import static org.junit.Assert.fail;
import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import javax.security.auth.login.LoginContext;
@@ -28,7 +29,8 @@
domains.add("somedomain");
SessionServiceImpl ssi = new SessionServiceImpl() {
- protected MembershipServiceImpl authenticate(String userName, Credentials credentials, String applicationName)
+ @Override
+ protected MembershipServiceImpl authenticate(String userName, Credentials credentials, String applicationName, List<String> domains)
throws LoginException {
impl.authenticateUser(userName, credentials, applicationName, domains);
return impl;
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -147,7 +147,7 @@
createFakeConnection(serverInstance);
fail("expected exception"); //$NON-NLS-1$
} catch (CommunicationException e) {
- assertEquals("Unable to find a component used in logging on to Teiid", e.getMessage()); //$NON-NLS-1$
+ assertEquals("Unable to find a component used authenticate on to Teiid", e.getMessage()); //$NON-NLS-1$
}
}
@@ -208,7 +208,6 @@
dqp.begin();
fail("exception expected"); //$NON-NLS-1$
} catch (XATransactionException e) {
- e.printStackTrace();
assertEquals("Component not found: com.metamatrix.dqp.client.ClientSideDQP", e.getMessage()); //$NON-NLS-1$
}
}
Modified: branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -22,10 +22,12 @@
package com.metamatrix.connector.jdbc.extension;
+import static org.junit.Assert.*;
+
import java.util.Properties;
-import junit.framework.TestCase;
-
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.jdbc.JDBCPropertyNames;
@@ -43,10 +45,9 @@
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
import com.metamatrix.cdk.api.EnvironmentUtility;
-
/**
*/
-public class TestSQLConversionVisitor extends TestCase {
+public class TestSQLConversionVisitor {
public static final ExecutionContext context = new ExecutionContextImpl("VDB", //$NON-NLS-1$
"Version", //$NON-NLS-1$
@@ -55,15 +56,17 @@
"ExecutionPayload", //$NON-NLS-1$
"ConnectionID", //$NON-NLS-1$
"Connector", //$NON-NLS-1$
- "RequestID", "PartID", "ExecCount"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- /**
- * Constructor for TestSQLConversionVisitor.
- * @param name
- */
- public TestSQLConversionVisitor(String name) {
- super(name);
- }
-
+ "RequestID", "PartID", "ExecCount"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private static Translator TRANSLATOR;
+
+ @BeforeClass public static void oneTimeSetup() throws ConnectorException {
+ TRANSLATOR = new Translator();
+ Properties p = new Properties();
+ p.setProperty(JDBCPropertyNames.TRIM_STRINGS, Boolean.TRUE.toString());
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(p, false));
+ }
+
public String getTestVDB() {
return TranslationHelper.PARTS_VDB;
}
@@ -99,244 +102,244 @@
return visitor.toString();
}
- public void testSimple() {
+ @Test public void testSimple() {
helpTestVisitor(getTestVDB(),
"select part_name from parts", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS"); //$NON-NLS-1$
}
- public void testAliasInSelect() {
+ @Test public void testAliasInSelect() {
helpTestVisitor(getTestVDB(),
"select part_name as x from parts", //$NON-NLS-1$
"SELECT PARTS.PART_NAME AS x FROM PARTS"); //$NON-NLS-1$
}
- public void testAliasedGroup() {
+ @Test public void testAliasedGroup() {
helpTestVisitor(getTestVDB(),
"select y.part_name from parts y", //$NON-NLS-1$
"SELECT y.PART_NAME FROM PARTS AS y"); //$NON-NLS-1$
}
- public void testAliasedGroupAndElement() {
+ @Test public void testAliasedGroupAndElement() {
helpTestVisitor(getTestVDB(),
"select y.part_name AS z from parts y", //$NON-NLS-1$
"SELECT y.PART_NAME AS z FROM PARTS AS y"); //$NON-NLS-1$
}
- public void testLiteralString() {
+ @Test public void testLiteralString() {
helpTestVisitor(getTestVDB(),
"select 'x' from parts", //$NON-NLS-1$
"SELECT 'x' FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralInteger() {
+ @Test public void testLiteralInteger() {
helpTestVisitor(getTestVDB(),
"select 5 from parts", //$NON-NLS-1$
"SELECT 5 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralFloat() {
+ @Test public void testLiteralFloat() {
helpTestVisitor(getTestVDB(),
"select 5.2 from parts", //$NON-NLS-1$
"SELECT 5.2 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralLowFloat() {
+ @Test public void testLiteralLowFloat() {
helpTestVisitor(getTestVDB(),
"select 0.012 from parts", //$NON-NLS-1$
"SELECT 0.012 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralLowFloat2() {
+ @Test public void testLiteralLowFloat2() {
helpTestVisitor(getTestVDB(),
"select 0.00012 from parts", //$NON-NLS-1$
"SELECT 0.00012 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralHighFloat() {
+ @Test public void testLiteralHighFloat() {
helpTestVisitor(getTestVDB(),
"select 12345.123 from parts", //$NON-NLS-1$
"SELECT 12345.123 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralHighFloat2() {
+ @Test public void testLiteralHighFloat2() {
helpTestVisitor(getTestVDB(),
"select 1234567890.1234567 from parts", //$NON-NLS-1$
"SELECT 1234567890.1234567 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralBoolean() {
+ @Test public void testLiteralBoolean() {
helpTestVisitor(getTestVDB(),
"select {b'true'}, {b'false'} from parts", //$NON-NLS-1$
"SELECT 1, 0 FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralDate() {
+ @Test public void testLiteralDate() {
helpTestVisitor(getTestVDB(),
- "select {d'2003-12-31'} from parts", //$NON-NLS-1$
- "SELECT {d'2003-12-31'} FROM PARTS"); //$NON-NLS-1$
+ "select {d '2003-12-31'} from parts", //$NON-NLS-1$
+ "SELECT {d '2003-12-31'} FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralTime() {
+ @Test public void testLiteralTime() {
helpTestVisitor(getTestVDB(),
- "select {t'23:59:59'} from parts", //$NON-NLS-1$
- "SELECT {t'23:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "select {t '23:59:59'} from parts", //$NON-NLS-1$
+ "SELECT {t '23:59:59'} FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralNull() {
+ @Test public void testLiteralNull() {
helpTestVisitor(getTestVDB(),
"select null from parts", //$NON-NLS-1$
"SELECT NULL FROM PARTS"); //$NON-NLS-1$
}
- public void testLiteralTimestamp() {
+ @Test public void testLiteralTimestamp() {
helpTestVisitor(getTestVDB(),
- "select {ts'2003-12-31 23:59:59.123'} from parts", //$NON-NLS-1$
- "SELECT {ts'2003-12-31 23:59:59.123'} FROM PARTS"); //$NON-NLS-1$
+ "select {ts '2003-12-31 23:59:59.123'} from parts", //$NON-NLS-1$
+ "SELECT {ts '2003-12-31 23:59:59.123'} FROM PARTS"); //$NON-NLS-1$
}
- public void testSQL89Join() {
+ @Test public void testSQL89Join() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p, supplier_parts s where p.part_id = s.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM PARTS AS p, SUPPLIER_PARTS AS s WHERE p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
- public void testSQL92Join() {
+ @Test public void testSQL92Join() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM PARTS AS p INNER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
- public void testSelfJoin() {
+ @Test public void testSelfJoin() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p join parts p2 on p.part_id = p2.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM PARTS AS p INNER JOIN PARTS AS p2 ON p.PART_ID = p2.PART_ID"); //$NON-NLS-1$
}
- public void testRightOuterJoin() {
+ @Test public void testRightOuterJoin() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p right join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM SUPPLIER_PARTS AS s LEFT OUTER JOIN PARTS AS p ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
- public void testLeftOuterJoin() {
+ @Test public void testLeftOuterJoin() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p left join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM PARTS AS p LEFT OUTER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
- public void testFullOuterJoin() {
+ @Test public void testFullOuterJoin() {
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p full join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
"SELECT p.PART_NAME FROM PARTS AS p FULL OUTER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
- public void testCompare1() {
+ @Test public void testCompare1() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id = 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID = 'x'"); //$NON-NLS-1$
}
- public void testCompare2() {
+ @Test public void testCompare2() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id <> 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID <> 'x'"); //$NON-NLS-1$
}
- public void testCompare3() {
+ @Test public void testCompare3() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id < 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID < 'x'"); //$NON-NLS-1$
}
- public void testCompare4() {
+ @Test public void testCompare4() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id <= 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID <= 'x'"); //$NON-NLS-1$
}
- public void testCompare5() {
+ @Test public void testCompare5() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id > 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID > 'x'"); //$NON-NLS-1$
}
- public void testCompare6() {
+ @Test public void testCompare6() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id >= 'x'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID >= 'x'"); //$NON-NLS-1$
}
- public void testIn1() {
+ @Test public void testIn1() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id in ('x')", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID = 'x'"); //$NON-NLS-1$
}
- public void testIn2() {
+ @Test public void testIn2() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id in ('x', 'y')", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IN ('x', 'y')"); //$NON-NLS-1$
}
- public void testIn3() {
+ @Test public void testIn3() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id not in ('x', 'y')", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID NOT IN ('x', 'y')"); //$NON-NLS-1$
}
- public void testIsNull1() {
+ @Test public void testIsNull1() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id is null", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IS NULL"); //$NON-NLS-1$
}
- public void testIsNull2() {
+ @Test public void testIsNull2() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id is not null", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IS NOT NULL"); //$NON-NLS-1$
}
- public void testInsertNull() {
+ @Test public void testInsertNull() {
helpTestVisitor(getTestVDB(),
"insert into parts (part_id, part_name, part_color, part_weight) values ('a', null, 'c', 'd')", //$NON-NLS-1$
"INSERT INTO PARTS (PART_ID, PART_NAME, PART_COLOR, PART_WEIGHT) VALUES ('a', NULL, 'c', 'd')"); //$NON-NLS-1$
}
- public void testUpdateNull() {
+ @Test public void testUpdateNull() {
helpTestVisitor(getTestVDB(),
"update parts set part_weight = null where part_color = 'b'", //$NON-NLS-1$
"UPDATE PARTS SET PART_WEIGHT = NULL WHERE PARTS.PART_COLOR = 'b'"); //$NON-NLS-1$
}
- public void testUpdateWhereNull() {
+ @Test public void testUpdateWhereNull() {
helpTestVisitor(getTestVDB(),
"update parts set part_weight = 'a' where part_weight = null", //$NON-NLS-1$
"UPDATE PARTS SET PART_WEIGHT = 'a' WHERE NULL <> NULL"); //$NON-NLS-1$
}
- public void testPreparedStatementCreationWithUpdate() {
+ @Test public void testPreparedStatementCreationWithUpdate() {
helpTestVisitor(getTestVDB(),
"update parts set part_weight = 'a' where part_weight < 5", //$NON-NLS-1$
"UPDATE PARTS SET PART_WEIGHT = ? WHERE PARTS.PART_WEIGHT < ?", //$NON-NLS-1$
true);
}
- public void testPreparedStatementCreationWithInsert() {
+ @Test public void testPreparedStatementCreationWithInsert() {
helpTestVisitor(getTestVDB(),
"insert into parts (part_weight) values (5)", //$NON-NLS-1$
"INSERT INTO PARTS (PART_WEIGHT) VALUES (?)", //$NON-NLS-1$
true);
}
- public void testPreparedStatementCreationWithSelect() {
+ @Test public void testPreparedStatementCreationWithSelect() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id not in ('x', 'y') and part_weight < 6", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE (PARTS.PART_ID NOT IN (?, ?)) AND (PARTS.PART_WEIGHT < ?)", //$NON-NLS-1$
true);
}
- public void testPreparedStatementCreationWithLike() {
+ @Test public void testPreparedStatementCreationWithLike() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_name like '%foo'", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_NAME LIKE ?", //$NON-NLS-1$
@@ -358,53 +361,76 @@
* In the future, functions can be made smarter about which of their literal arguments
* either are (or are not) eligible to be bind variables
*/
- public void testPreparedStatementCreationWithFunction() {
+ @Test public void testPreparedStatementCreationWithFunction() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where concat(part_name, 'x') = concat('y', part_weight)", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE concat(PARTS.PART_NAME, 'x') = concat('y', PARTS.PART_WEIGHT)", //$NON-NLS-1$
true);
}
- public void testPreparedStatementCreationWithCase() {
+ @Test public void testPreparedStatementCreationWithCase() {
helpTestVisitor(getTestVDB(),
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME='a' THEN 'b' ELSE 'c' END", //$NON-NLS-1$
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME = ? THEN 'b' ELSE 'c' END", //$NON-NLS-1$
true);
}
- public void testVisitIDeleteWithComment() throws Exception {
+ @Test public void testVisitIDeleteWithComment() throws Exception {
String expected = "DELETE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ FROM g1 WHERE (100 >= 200) AND (500 < 600)"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestDeleteImpl.example()));
}
- public void testVisitIInsertWithComment() throws Exception {
+ @Test public void testVisitIInsertWithComment() throws Exception {
String expected = "INSERT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ INTO g1 (e1, e2, e3, e4) VALUES (1, 2, 3, 4)"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestInsertImpl.example("g1"))); //$NON-NLS-1$
}
- public void testVisitISelectWithComment() throws Exception {
+ @Test public void testVisitISelectWithComment() throws Exception {
String expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestSelectImpl.example(false)));
expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestSelectImpl.example(true)));
}
- public void testVisitIUpdateWithComment() throws Exception {
+ @Test public void testVisitIUpdateWithComment() throws Exception {
String expected = "UPDATE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1 SET e1 = 1, e2 = 1, e3 = 1, e4 = 1 WHERE 1 = 1"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestUpdateImpl.example()));
}
- public void testVisitIProcedureWithComment() throws Exception {
+ @Test public void testVisitIProcedureWithComment() throws Exception {
String expected = "{ /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ call sq3(?,?)}"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestProcedureImpl.example()));
}
- public void testTrimStrings() throws Exception {
- Translator trans = new Translator();
- Properties p = new Properties();
- p.setProperty(JDBCPropertyNames.TRIM_STRINGS, Boolean.TRUE.toString());
- trans.initialize(EnvironmentUtility.createEnvironment(p, false));
-
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, "select stringkey from bqt1.smalla", "SELECT rtrim(SmallA.StringKey) FROM SmallA", trans); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ @Test public void testTrimStrings() throws Exception {
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, "select stringkey from bqt1.smalla", "SELECT rtrim(SmallA.StringKey) FROM SmallA", TRANSLATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testNestedSetQuery() throws Exception {
+ String input = "select part_id id FROM parts UNION ALL (select part_name FROM parts UNION select part_id FROM parts)"; //$NON-NLS-1$
+ String output = "SELECT rtrim(PARTS.PART_ID) AS id FROM PARTS UNION ALL (SELECT PARTS.PART_NAME FROM PARTS UNION SELECT rtrim(PARTS.PART_ID) FROM PARTS)"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.PARTS_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testNestedSetQuery1() throws Exception {
+ String input = "select part_id id FROM parts UNION (select part_name FROM parts EXCEPT select part_id FROM parts)"; //$NON-NLS-1$
+ String output = "SELECT rtrim(PARTS.PART_ID) AS id FROM PARTS UNION (SELECT PARTS.PART_NAME FROM PARTS EXCEPT SELECT rtrim(PARTS.PART_ID) FROM PARTS)"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.PARTS_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testNestedSetQuery2() throws Exception {
+ String input = "select part_id id FROM parts UNION select part_name FROM parts EXCEPT select part_id FROM parts"; //$NON-NLS-1$
+ String output = "SELECT rtrim(PARTS.PART_ID) AS id FROM PARTS UNION SELECT PARTS.PART_NAME FROM PARTS EXCEPT SELECT rtrim(PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.PARTS_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-02-04 18:44:39 UTC (rev 1800)
@@ -312,17 +312,17 @@
assertEquals(expected, getString(TestLiteralImpl.example("string'Literal"))); //$NON-NLS-1$
expected = "1000"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(new Integer(1000))));
- expected = "{b'true'}"; //$NON-NLS-1$
+ expected = "{b 'true'}"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(Boolean.TRUE)));
long now = System.currentTimeMillis();
Date date = new Date(now);
- expected = "{d'" + date.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{d '" + date.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(date)));
Timestamp ts = new Timestamp(now);
- expected = "{ts'" + ts.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{ts '" + ts.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(ts)));
Time t = new Time(now);
- expected = "{t'" + t.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ expected = "{t '" + t.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(expected, getString(TestLiteralImpl.example(t)));
}
Modified: branches/JCA/test-integration/pom.xml
===================================================================
--- branches/JCA/test-integration/pom.xml 2010-02-03 17:56:28 UTC (rev 1799)
+++ branches/JCA/test-integration/pom.xml 2010-02-04 18:44:39 UTC (rev 1800)
@@ -126,5 +126,6 @@
<modules>
<module>common</module>
+ <module>db</module>
</modules>
</project>
\ No newline at end of file
14 years, 10 months