[teiid-commits] teiid SVN: r3091 - in trunk: test-integration/common/src/test/java/org/teiid/transport and 2 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Apr 14 21:43:34 EDT 2011


Author: shawkins
Date: 2011-04-14 21:43:34 -0400 (Thu, 14 Apr 2011)
New Revision: 3091

Added:
   trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
   trunk/test-integration/common/src/test/resources/TestJDBCSocketTransport/
   trunk/test-integration/common/src/test/resources/TestJDBCSocketTransport/testSelect.expected
Modified:
   trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
Log:
TEIID-1536 fixing the regression with synch query execution

Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-04-14 16:19:52 UTC (rev 3090)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-04-15 01:43:34 UTC (rev 3091)
@@ -526,16 +526,32 @@
         
         final RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
         reqMessage.setSync(synch);
-    	ResultsFuture<Boolean> result = execute(reqMessage);
+    	ResultsFuture<ResultsMessage> pendingResult = execute(reqMessage, synch);
+    	final ResultsFuture<Boolean> result = new ResultsFuture<Boolean>();
+    	pendingResult.addCompletionListener(new ResultsFuture.CompletionListener<ResultsMessage>() {
+    		@Override
+    		public void onCompletion(ResultsFuture<ResultsMessage> future) {
+    			try {
+					postReceiveResults(reqMessage, future.get());
+					result.getResultsReceiver().receiveResults(hasResultSet());
+				} catch (Throwable t) {
+					result.getResultsReceiver().exceptionOccurred(t);
+				}
+    		}
+		});
     	if (synch) {
     		try {
     			if (queryTimeoutMS > 0) {
-    				result.get(queryTimeoutMS, TimeUnit.MILLISECONDS);
+    				pendingResult.get(queryTimeoutMS, TimeUnit.MILLISECONDS);
     			} else {
-    				result.get();
+    				pendingResult.get();
     			}
+    			result.get(); //throw an exception if needed
     			return result;
     		} catch (ExecutionException e) {
+    			if (e.getCause() instanceof SQLException) {
+    				throw (SQLException)e.getCause();
+    			}
     			throw TeiidSQLException.create(e);
     		} catch (InterruptedException e) {
     			timeoutOccurred();
@@ -547,7 +563,7 @@
     	return result;
     }
 
-	private ResultsFuture<Boolean> execute(final RequestMessage reqMsg) throws SQLException,
+	private ResultsFuture<ResultsMessage> execute(final RequestMessage reqMsg, boolean synch) throws SQLException,
 			TeiidSQLException {
 		this.getConnection().beginLocalTxnIfNeeded();
         this.currentRequestID = this.driverConnection.nextRequestID();
@@ -564,7 +580,7 @@
         reqMsg.setExecutionId(this.currentRequestID);
         
         ResultsFuture.CompletionListener<ResultsMessage> compeletionListener = null;
-		if (queryTimeoutMS > 0) {
+		if (queryTimeoutMS > 0 && !synch) {
 			final CancelTask c = new QueryTimeoutCancelTask(queryTimeoutMS, this);
 			cancellationTimer.add(c);
 			compeletionListener = new ResultsFuture.CompletionListener<ResultsMessage>() {
@@ -584,19 +600,7 @@
 		if (compeletionListener != null) {
 			pendingResult.addCompletionListener(compeletionListener);
 		}
-    	final ResultsFuture<Boolean> result = new ResultsFuture<Boolean>();
-    	pendingResult.addCompletionListener(new ResultsFuture.CompletionListener<ResultsMessage>() {
-    		@Override
-    		public void onCompletion(ResultsFuture<ResultsMessage> future) {
-    			try {
-					postReceiveResults(reqMsg, future.get());
-					result.getResultsReceiver().receiveResults(hasResultSet());
-				} catch (Throwable t) {
-					result.getResultsReceiver().exceptionOccurred(t);
-				}
-    		}
-		});
-    	return result;
+    	return pendingResult;
     }
 
 	public static ResultsFuture<Boolean> booleanFuture(boolean isTrue) {

Added: trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java	                        (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java	2011-04-15 01:43:34 UTC (rev 3091)
@@ -0,0 +1,93 @@
+/*
+ * 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.transport;
+
+import static org.junit.Assert.*;
+
+import java.net.InetSocketAddress;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.jdbc.TestMMDatabaseMetaData;
+
+ at SuppressWarnings("nls")
+public class TestJDBCSocketTransport {
+
+	static InetSocketAddress addr;
+	static SocketListener jdbcTransport;
+	
+	@BeforeClass public static void oneTimeSetup() throws Exception {
+		SocketConfiguration config = new SocketConfiguration();
+		config.setSSLConfiguration(new SSLConfiguration());
+		addr = new InetSocketAddress(0);
+		config.setBindAddress(addr.getHostName());
+		config.setPortNumber(0);
+		
+		FakeServer server = new FakeServer();
+		server.setUseCallingThread(false);
+		server.deployVDB("parts", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+		
+		jdbcTransport = new SocketListener(config, server, BufferManagerFactory.getStandaloneBufferManager(), 0);
+	}
+	
+	@AfterClass public static void oneTimeTearDown() throws Exception {
+		if (jdbcTransport != null) {
+			jdbcTransport.stop();
+		}
+	}
+	
+	Connection conn;
+	
+	@Before public void setUp() throws Exception {
+		Properties p = new Properties();
+		p.setProperty("user", "testuser");
+		p.setProperty("password", "testpassword");
+		conn = TeiidDriver.getInstance().connect("jdbc:teiid:parts at mm://"+addr.getHostName()+":" +jdbcTransport.getPort(), p);
+	}
+	
+	@After public void tearDown() throws Exception {
+		if (conn != null) {
+			conn.close();
+		}
+	}
+	
+	/**
+	 * Under the covers this still executes a prepared statement due to the driver handling
+	 */
+	@Test public void testSelect() throws Exception {
+		Statement s = conn.createStatement();
+		assertTrue(s.execute("select * from tables order by name"));
+		TestMMDatabaseMetaData.compareResultSet(s.getResultSet());
+	}
+	
+}


Property changes on: trunk/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/test-integration/common/src/test/resources/TestJDBCSocketTransport/testSelect.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestJDBCSocketTransport/testSelect.expected	                        (rev 0)
+++ trunk/test-integration/common/src/test/resources/TestJDBCSocketTransport/testSelect.expected	2011-04-15 01:43:34 UTC (rev 3091)
@@ -0,0 +1,48 @@
+string                                                             string                                                             string                                                             string                string                                                             boolean     boolean          string                                              integer      string                                                             boolean   boolean         integer    
+VDBName                                                            SchemaName                                                         Name                                                               Type                  NameInSource                                                       IsPhysical  SupportsUpdates  UID                                                 Cardinality  Description                                                        IsSystem  IsMaterialized  OID        
+parts                                                              SYS                                                                Columns                                                            Table                 <null>                                                             true        false            mmuuid:1c9a5cb2-17b1-4e4a-8b0e-3a42bd052509         0            <null>                                                             true      false           8          
+parts                                                              SYS                                                                DataTypes                                                          Table                 <null>                                                             true        false            mmuuid:9a8794f9-66f8-49e8-8576-89d212d0f957         0            <null>                                                             true      false           9          
+parts                                                              SYS                                                                KeyColumns                                                         Table                 <null>                                                             true        false            mmuuid:14946083-3bd5-42d5-8283-1c0694347c29         0            <null>                                                             true      false           10         
+parts                                                              SYS                                                                Keys                                                               Table                 <null>                                                             true        false            mmuuid:1e5135dc-ce5d-4b25-a8ff-63f5440b3108         0            <null>                                                             true      false           11         
+parts                                                              SYSADMIN                                                           MatViews                                                           Table                 <null>                                                             true        false            mmuuid:520ba1e8-3553-460f-8d18-9b43f089e256         0            <null>                                                             true      false           6          
+parts                                                              PartsSupplier                                                      PARTSSUPPLIER.PARTS                                                Table                 PARTS                                                              true        true             mmuuid:f6276601-73fe-1edc-a81c-ecf397b10590         16           <null>                                                             false     false           1          
+parts                                                              PartsSupplier                                                      PARTSSUPPLIER.SHIP_VIA                                             Table                 SHIP_VIA                                                           true        true             mmuuid:0f4e9b80-73ff-1edc-a81c-ecf397b10590         4            <null>                                                             false     false           2          
+parts                                                              PartsSupplier                                                      PARTSSUPPLIER.STATUS                                               Table                 STATUS                                                             true        true             mmuuid:1f297200-73ff-1edc-a81c-ecf397b10590         3            <null>                                                             false     false           3          
+parts                                                              PartsSupplier                                                      PARTSSUPPLIER.SUPPLIER                                             Table                 SUPPLIER                                                           true        true             mmuuid:2c371ec0-73ff-1edc-a81c-ecf397b10590         16           <null>                                                             false     false           5          
+parts                                                              PartsSupplier                                                      PARTSSUPPLIER.SUPPLIER_PARTS                                       Table                 SUPPLIER_PARTS                                                     true        true             mmuuid:3deafb00-73ff-1edc-a81c-ecf397b10590         227          <null>                                                             false     false           4          
+parts                                                              SYS                                                                ProcedureParams                                                    Table                 <null>                                                             true        false            mmuuid:a56bd7fe-c87a-411c-8f5d-661975a25626         0            <null>                                                             true      false           12         
+parts                                                              SYS                                                                Procedures                                                         Table                 <null>                                                             true        false            mmuuid:0bc132a5-9f8d-4a3c-9f5d-98156a98a962         0            <null>                                                             true      false           13         
+parts                                                              SYS                                                                Properties                                                         Table                 <null>                                                             true        false            mmuuid:7a45e50a-d03f-4548-ba35-761651bbca85         0            <null>                                                             true      false           14         
+parts                                                              SYS                                                                ReferenceKeyColumns                                                Table                 <null>                                                             true        false            mmuuid:6a9653e8-a337-41b2-86fa-77b98f409a29         0            <null>                                                             true      false           15         
+parts                                                              SYS                                                                Schemas                                                            Table                 <null>                                                             true        false            mmuuid:8648a554-b2ad-4e8e-84ca-2ec618b311a9         0            <null>                                                             true      false           16         
+parts                                                              SYS                                                                Tables                                                             Table                 <null>                                                             true        false            mmuuid:8551b3bd-11cc-4049-9bcf-fe91a0eb7ba7         0            <null>                                                             true      false           17         
+parts                                                              SYSADMIN                                                           VDBResources                                                       Table                 <null>                                                             true        false            mmuuid:1785804d-beaf-4831-9531-e59164fedd49         0            <null>                                                             true      false           7          
+parts                                                              SYS                                                                VirtualDatabases                                                   Table                 <null>                                                             true        false            mmuuid:47297c72-d621-4f4e-af4e-74060ac5f489         0            <null>                                                             true      false           18         
+parts                                                              pg_catalog                                                         matpg_datatype                                                     Table                 <null>                                                             false       false            mmuid:17448311-6679-4dfd-aeb6-4aabbd894729          0            <null>                                                             true      true            31         
+parts                                                              pg_catalog                                                         matpg_relatt                                                       Table                 <null>                                                             false       false            mmuid:8c0714d6-1c72-40b4-8528-3b2c63059107          0            <null>                                                             true      true            30         
+parts                                                              pg_catalog                                                         pg_am                                                              Table                 <null>                                                             false       false            mmuid:f6517a63-8c14-4b73-a18d-afaa5dfb35d9          0            <null>                                                             true      false           24         
+parts                                                              pg_catalog                                                         pg_attrdef                                                         Table                 <null>                                                             false       false            mmuid:76a7dd05-9a7d-4243-b561-f3056500dcaf          0            <null>                                                             true      false           27         
+parts                                                              pg_catalog                                                         pg_attribute                                                       Table                 <null>                                                             false       false            mmuid:fa463d98-365f-489a-a707-025193cb51eb          0            <null>                                                             true      true            21         
+parts                                                              pg_catalog                                                         pg_class                                                           Table                 <null>                                                             false       false            mmuid:7e21f2e6-06e3-4bca-9b01-72ea47821560          0            <null>                                                             true      true            20         
+parts                                                              pg_catalog                                                         pg_database                                                        Table                 <null>                                                             false       false            mmuid:382f9fc9-8c96-4df7-ab5d-04dfb47ee142          0            <null>                                                             true      false           28         
+parts                                                              pg_catalog                                                         pg_index                                                           Table                 <null>                                                             false       false            mmuid:09daed8d-b0b8-4552-a261-2b6c775b46b0          0            <null>                                                             true      true            23         
+parts                                                              pg_catalog                                                         pg_namespace                                                       Table                 <null>                                                             false       false            mmuid:6609866a-3d7b-4f4b-95fe-ebfac769d699          0            <null>                                                             true      false           19         
+parts                                                              pg_catalog                                                         pg_proc                                                            Table                 <null>                                                             false       false            mmuid:f20c9489-10ca-4596-8a37-24218b67f764          0            <null>                                                             true      true            25         
+parts                                                              pg_catalog                                                         pg_trigger                                                         Table                 <null>                                                             false       false            mmuid:2b75f0b1-7475-4ed5-9da3-d37a8a25f26a          0            <null>                                                             true      false           26         
+parts                                                              pg_catalog                                                         pg_type                                                            Table                 <null>                                                             false       false            mmuid:9462e3f8-cd3c-414f-a570-f6f33c40e36a          0            <null>                                                             true      false           22         
+parts                                                              pg_catalog                                                         pg_user                                                            Table                 <null>                                                             false       false            mmuid:e63613cb-01ee-4b37-8b91-99d1aac4dfcb          0            <null>                                                             true      false           29         
+Row Count : 31
+getColumnName    getColumnType  getCatalogName  getColumnClassName  getColumnLabel   getColumnTypeName  getSchemaName  getTableName  getColumnDisplaySize  getPrecision  getScale  isAutoIncrement  isCaseSensitive  isCurrency  isDefinitelyWritable  isNullable  isReadOnly  isSearchable  isSigned  isWritable  
+VDBName          12             parts           java.lang.String    VDBName          string             SYS            Tables        255                   255           0         false            true             false       true                  1           false       true          true      true        
+SchemaName       12             parts           java.lang.String    SchemaName       string             SYS            Tables        255                   255           0         false            true             false       true                  1           false       true          true      true        
+Name             12             parts           java.lang.String    Name             string             SYS            Tables        255                   255           0         false            true             false       false                 0           true        true          false     false       
+Type             12             parts           java.lang.String    Type             string             SYS            Tables        20                    20            0         false            false            false       false                 0           true        true          false     false       
+NameInSource     12             parts           java.lang.String    NameInSource     string             SYS            Tables        255                   255           0         false            true             false       false                 1           true        true          false     false       
+IsPhysical       -7             parts           java.lang.Boolean   IsPhysical       boolean            SYS            Tables        5                     1             0         false            true             false       false                 0           true        true          false     false       
+SupportsUpdates  -7             parts           java.lang.Boolean   SupportsUpdates  boolean            SYS            Tables        5                     1             0         false            false            false       false                 0           true        true          false     false       
+UID              12             parts           java.lang.String    UID              string             SYS            Tables        50                    50            0         false            false            false       false                 0           true        true          false     false       
+Cardinality      4              parts           java.lang.Integer   Cardinality      integer            SYS            Tables        11                    10            0         false            true             false       false                 0           true        true          true      false       
+Description      12             parts           java.lang.String    Description      string             SYS            Tables        255                   255           0         false            true             false       true                  1           false       true          true      true        
+IsSystem         -7             parts           java.lang.Boolean   IsSystem         boolean            SYS            Tables        5                     1             0         false            true             false       true                  1           false       true          true      true        
+IsMaterialized   -7             parts           java.lang.Boolean   IsMaterialized   boolean            SYS            Tables        5                     1             0         false            false            false       true                  0           false       true          false     true        
+OID              4              parts           java.lang.Integer   OID              integer            SYS            Tables        11                    10            0         false            false            false       false                 0           true        true          false     false       



More information about the teiid-commits mailing list