[teiid-commits] teiid SVN: r2891 - in trunk: build/kits/jboss-container/deploy/teiid and 20 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon Jan 31 16:12:17 EST 2011


Author: shawkins
Date: 2011-01-31 16:12:16 -0500 (Mon, 31 Jan 2011)
New Revision: 2891

Added:
   trunk/runtime/src/test/java/org/teiid/transport/TestFailover.java
Modified:
   trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
   trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
   trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
   trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
   trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
   trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
   trunk/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
   trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
   trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
   trunk/engine/src/main/java/org/teiid/cache/Cache.java
   trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
   trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java
   trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
   trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
   trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
   trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
   trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
   trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java
Log:
forward merge of 7.3

Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -22,7 +22,9 @@
 
 package org.teiid.metadata;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
@@ -103,8 +105,9 @@
     private boolean nullOnNull;
     
     private Determinism determinism = Determinism.DETERMINISTIC;
-        
-    private FunctionParameter[] inputParameters;
+    
+    @XmlElement(name="inputParameters")
+    protected List<FunctionParameter> inParameters = new ArrayList<FunctionParameter>();
     private FunctionParameter outputParameter;
     
     protected FunctionMethod() {
@@ -131,7 +134,9 @@
         setPushdown(pushdown);
         setInvocationClass(invocationClass);
         setInvocationMethod(invocationMethod);
-        setInputParameters(inputParams);
+        if (inputParams != null) {
+        	setInputParameters(Arrays.asList(inputParams));
+        }
         setOutputParameter(outputParam); 
         setNullOnNull(nullOnNull);
         setDeterminism(deterministic);
@@ -269,27 +274,28 @@
      * @return Number of input parameters
      */
     public int getInputParameterCount() {
-        if(this.inputParameters == null) { 
+        if(this.inParameters == null) { 
             return 0;
         }
-        return this.inputParameters.length;
+        return this.inParameters.size();
     }
     
     /**
      * Get input parameters
      * @return Array of input parameters, may be null if 0 parameters
      */
-    @XmlElement
-    public FunctionParameter[] getInputParameters() { 
-        return this.inputParameters;
+    
+    public List<FunctionParameter> getInputParameters() { 
+        return this.inParameters;
     }
     
     /**
      * Set input parameters.
      * @param params Input parameters
      */
-    public void setInputParameters(FunctionParameter[] params) { 
-        this.inputParameters = params;
+    public void setInputParameters(List<FunctionParameter> params) { 
+        this.inParameters.clear();
+        this.inParameters.addAll(params);
     }
     
     /**
@@ -322,8 +328,8 @@
      */
     public int hashCode() { 
         int hash = HashCodeUtil.hashCode(0, super.getName());
-        if(inputParameters != null) { 
-            hash = HashCodeUtil.hashCode(hash, Arrays.hashCode(inputParameters));
+        if(inParameters != null) { 
+            hash = HashCodeUtil.hashCode(hash, inParameters.hashCode());
         }             
         return hash;
     }
@@ -356,16 +362,16 @@
             }
             
             // Compare types of parameters
-            FunctionParameter[] thisInputs = this.getInputParameters();
-            if(thisInputs != null && thisInputs.length > 0) { 
+            List<FunctionParameter> thisInputs = this.getInputParameters();
+            if(thisInputs != null && thisInputs.size() > 0) { 
                 // If thisInputs is not null and >0 and other parameter
                 // count matched this parameter count, otherInputs MUST be 
                 // non null to have more than one parameter - so we don't 
                 // need to check it here.
-                FunctionParameter[] otherInputs = other.getInputParameters();
+                List<FunctionParameter> otherInputs = other.getInputParameters();
                 
-                for(int i=0; i<thisInputs.length; i++) { 
-                    boolean paramMatch = compareWithNull(thisInputs[i], otherInputs[i]);
+                for(int i=0; i<thisInputs.size(); i++) { 
+                    boolean paramMatch = compareWithNull(thisInputs.get(i), otherInputs.get(i));
                     if(! paramMatch) { 
                         return false;
                     }    
@@ -412,15 +418,15 @@
         
         // Print parameters
         str.append("("); //$NON-NLS-1$
-        if(inputParameters != null) { 
-            for(int i=0; i<inputParameters.length; i++) {
-                if(inputParameters[i] != null) { 
-                    str.append(inputParameters[i].toString());                   
+        if(inParameters != null) { 
+            for(int i=0; i<inParameters.size(); i++) {
+                if(inParameters.get(i) != null) { 
+                    str.append(inParameters.get(i).toString());                   
                 } else {
                     str.append("<unknown>"); //$NON-NLS-1$
                 }
                 
-                if(i < (inputParameters.length-1)) { 
+                if(i < (inParameters.size()-1)) { 
                     str.append(", "); //$NON-NLS-1$
                 }
             }    
@@ -462,8 +468,8 @@
     }
     
     public boolean isVarArgs() {
-    	if (this.inputParameters != null && this.inputParameters.length > 0) {
-    		return inputParameters[inputParameters.length - 1].isVarArg();
+    	if (this.inParameters != null && this.inParameters.size() > 0) {
+    		return inParameters.get(inParameters.size() - 1).isVarArg();
     	}
     	return false;
     }

Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml	2011-01-31 21:12:16 UTC (rev 2891)
@@ -66,7 +66,8 @@
         <!-- Allowed values are LRU, EXPIRATION.  
              Setting this value to LRU will cause cache hint TTL values
              to be ignored. (default EXPIRATION) -->
-        <property name="type">EXPIRATION</property>               
+        <property name="type">EXPIRATION</property>
+        <property name="location">resultset</property>               
     </bean>    
     
     <bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">

Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -31,7 +31,6 @@
 import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.CacheFactory;
 import org.teiid.cache.DefaultCacheFactory;
-import org.teiid.cache.Cache.Type;
 import org.teiid.core.TeiidRuntimeException;
 
 public class ClusterableCacheFactory implements CacheFactory, Serializable {
@@ -42,7 +41,7 @@
 	private String cacheManagerName;
 	
 	@Override
-	public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+	public <K, V> Cache<K, V> get(String location, CacheConfiguration config) {
 		if (this.delegate == null) {
 			Object cacheManager = getClusteredCache();
 			if (cacheManager == null) {
@@ -56,7 +55,7 @@
 				}
 			}
 		}
-		return delegate.get(type, config);
+		return delegate.get(location, config);
 	}
 
 	public void setResultsetCacheName(String name) {

Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -36,7 +36,6 @@
 import org.teiid.cache.Cache;
 import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.CacheFactory;
-import org.teiid.cache.Cache.Type;
 import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.core.TeiidRuntimeException;
 
@@ -55,7 +54,7 @@
 	/**
 	 * {@inheritDoc}
 	 */
-	public Cache get(Type type, CacheConfiguration config) {
+	public Cache get(String location, CacheConfiguration config) {
 		if (!destroyed) {
 			
 			if (!this.cacheStore.getCacheStatus().allowInvocations()) {
@@ -63,7 +62,7 @@
 			}
 			
 			Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
-			Node node = cacheRoot.addChild(Fqn.fromString(type.location()));
+			Node node = cacheRoot.addChild(Fqn.fromString(location));
 			node.setResident(true);
 			
 			Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -214,7 +214,7 @@
 		this.errors = errors;
 	}	
 	
-	public List<ValidationError> getValidationErrors(ValidationError.Severity severity){
+	public synchronized List<ValidationError> getValidationErrors(ValidationError.Severity severity){
 		if (this.errors == null) {
 			return Collections.emptyList();
 		}
@@ -227,7 +227,7 @@
 		return list;
 	}	
 	
-    public ValidationError addError(String severity, String message) {
+    public synchronized ValidationError addError(String severity, String message) {
         if (this.errors == null) {
             this.errors = new ArrayList<ValidationError>();
         }
@@ -236,14 +236,14 @@
         return ve;
     }
     
-    public boolean removeError(ValidationError remove) {
+    public synchronized boolean removeError(ValidationError remove) {
     	if (this.errors == null) {
     		return false;
     	}
     	return this.errors.remove(remove);
     }
     
-    public void clearErrors() {
+    public synchronized void clearErrors() {
     	this.errors.clear();
     }
 	

Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -48,6 +48,7 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.teiid.client.ResultsMessage;
@@ -146,6 +147,9 @@
 			rmetadata = new FilteredResultsMetadata(rmetadata, resultColumns);
 		}
 		this.fetchSize = statement.getFetchSize();
+		if (logger.isLoggable(Level.FINER)) {
+			logger.finer("Creating ResultSet requestID: " + requestID + " beginRow: " + resultsMsg.getFirstRow() + " resultsColumns: " + resultColumns + " parameters: " + parameters); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		}
 	}
 	
 	public void setMaxFieldSize(int maxFieldSize) {
@@ -356,7 +360,9 @@
     }
     
     public Batch requestBatch(int beginRow) throws SQLException{
-    	logger.fine("CursorResultsImpl.requestBatch] thread name: " + Thread.currentThread().getName() + " requestID: " + requestID + " beginRow: " + beginRow ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    	if (logger.isLoggable(Level.FINER)) {
+    		logger.finer("requestBatch requestID: " + requestID + " beginRow: " + beginRow ); //$NON-NLS-1$ //$NON-NLS-2$
+    	}
     	checkClosed();
         try {
         	ResultsFuture<ResultsMessage> results = statement.getDQP().processCursorRequest(requestID, beginRow, fetchSize);
@@ -365,6 +371,11 @@
         		timeoutSeconds = Integer.MAX_VALUE;
         	}
         	ResultsMessage currentResultMsg = results.get(timeoutSeconds, TimeUnit.SECONDS);
+        	
+            if (currentResultMsg.getException() != null) {
+                throw TeiidSQLException.create(currentResultMsg.getException());
+            }
+
     		this.accumulateWarnings(currentResultMsg);
     		return getCurrentBatch(currentResultMsg);
         } catch (TeiidProcessingException e) {

Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -28,6 +28,7 @@
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
@@ -387,7 +388,9 @@
         throws SQLException {
         checkStatement();
         resetExecutionState();
-        
+        if (logger.isLoggable(Level.FINER)) {
+			logger.finer("Executing: requestID " + getCurrentRequestID() + " commands: " + Arrays.toString(commands) + " expecting: " + resultsMode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		}
         if (commands.length == 1) {
         	Matcher match = SET_STATEMENT.matcher(commands[0]);
         	if (match.matches()) {
@@ -406,6 +409,7 @@
         	}
         	match = TRANSACTION_STATEMENT.matcher(commands[0]);
         	if (match.matches()) {
+    			logger.finer("Executing as transaction statement"); //$NON-NLS-1$
         		if (resultsMode == ResultsMode.RESULTSET) {
         			throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.set_result_set")); //$NON-NLS-1$
         		}
@@ -422,6 +426,7 @@
         	}
         	match = SHOW_STATEMENT.matcher(commands[0]);
         	if (match.matches()) {
+    			logger.finer("Executing as show statement"); //$NON-NLS-1$
         		if (resultsMode == ResultsMode.UPDATECOUNT) {
         			throw new TeiidSQLException(JDBCPlugin.Util.getString("StatementImpl.show_update_count")); //$NON-NLS-1$
         		}
@@ -503,7 +508,9 @@
             for (int i = 0; i < results.length; i++) {
             	updateCounts[i] = (Integer)results[i].get(0);
             }
-            
+            if (logger.isLoggable(Level.FINER)) {
+            	logger.fine(JDBCPlugin.Util.getString("Recieved update counts: " + Arrays.toString(updateCounts))); //$NON-NLS-1$
+            }
             // In update scenarios close the statement implicitly
             try {
 				getDQP().closeRequest(getCurrentRequestID());

Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -282,6 +282,7 @@
 		this.logonResults.remove(this.serverInstance.getHostInfo());
 		if (this.logonResult != null) {
 			this.connectionFactory.disconnected(this.serverInstance, this.logonResult.getSessionToken());
+			this.logonResult = null;
 		}
 	}
 	

Modified: trunk/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestAllResultsImpl.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -41,6 +41,7 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Matchers;
+import org.mockito.Mockito;
 import org.teiid.client.DQP;
 import org.teiid.client.RequestMessage;
 import org.teiid.client.ResultsMessage;
@@ -696,6 +697,19 @@
 			assertTrue(rs.previous());
 		}
 	}
+    
+    @Test(expected=TeiidSQLException.class) public void testResultsMessageException() throws Exception {
+        ResultsMessage resultsMsg = exampleMessage(exampleResults1(1), new String[] { "IntNum" }, new String[] { JDBCSQLTypeInfo.INTEGER }); //$NON-NLS-1$
+        resultsMsg.setFinalRow(-1);
+        ResultsMessage next = new ResultsMessage();
+        next.setException(new Throwable());
+        ResultsFuture<ResultsMessage> rf = new ResultsFuture<ResultsMessage>();
+        rf.getResultsReceiver().receiveResults(next);
+        Mockito.stub(statement.getDQP().processCursorRequest(0, 2, 0)).toReturn(rf);
+        ResultSetImpl cs = new ResultSetImpl(resultsMsg, statement, null, 2);
+        cs.next();
+        cs.next();
+    }
 	
 	static ResultSetImpl helpTestBatching(StatementImpl statement, int fetchSize, int batchLength,
 			int totalLength) throws InterruptedException, ExecutionException,

Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -138,6 +138,9 @@
 			String nameInSource = procedureName;
 			if (useProcedureSpecificName && rsColumns >= 9) {
 				procedureName = procedures.getString(9);
+				if (procedureName == null) {
+					procedureName = nameInSource;
+				}
 			}
 			String fullProcedureName = getFullyQualifiedName(procedureCatalog, procedureSchema, procedureName);
 			Procedure procedure = metadataFactory.addProcedure(useFullSchemaName?fullProcedureName:procedureName);

Modified: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -24,6 +24,7 @@
 import static org.junit.Assert.*;
 
 import java.util.Arrays;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.TimeZone;
 
@@ -34,15 +35,19 @@
 import org.teiid.language.Select;
 import org.teiid.metadata.Column;
 import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
 import org.teiid.metadata.Schema;
 import org.teiid.metadata.Table;
 import org.teiid.metadata.Column.SearchType;
 import org.teiid.query.metadata.CompositeMetadataStore;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.sql.lang.SPParameter;
 import org.teiid.query.unittest.FakeMetadataFactory;
 import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TypeFacility;
 import org.teiid.translator.salesforce.Constants;
 import org.teiid.translator.salesforce.SalesforceConnection;
 import org.teiid.translator.salesforce.execution.QueryExecutionImpl;
@@ -101,6 +106,16 @@
             Column obj = contactCols.get(i);
             obj.setNameInSource(contactNameInSource[i]);
         }
+
+        
+        List<ProcedureParameter> params = new LinkedList<ProcedureParameter>();
+        params.add(RealMetadataFactory.createParameter("type", SPParameter.IN, TypeFacility.RUNTIME_NAMES.STRING));
+        params.add(RealMetadataFactory.createParameter("start", SPParameter.IN, TypeFacility.RUNTIME_NAMES.TIMESTAMP));
+        params.add(RealMetadataFactory.createParameter("end", SPParameter.IN, TypeFacility.RUNTIME_NAMES.TIMESTAMP));
+        
+        Procedure getUpdated = RealMetadataFactory.createStoredProcedure("GetUpdated", salesforceModel, params, "GetUpdated");
+        getUpdated.setResultSet(RealMetadataFactory.createResultSet("rs", new String[] {"updated"}, new String[] {TypeFacility.RUNTIME_NAMES.STRING}));
+        
         return new TransformationMetadata(null, new CompositeMetadataStore(store), null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
     }    
 

Modified: trunk/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -28,29 +28,7 @@
  * Abstraction over cache providers
  */
 public interface Cache<K, V>  {
-	
-	public enum Type {
-		MATTABLES("MatTables"), //$NON-NLS-1$ 
-		MATTABLEUPDATES("MatTableUpdates"), //$NON-NLS-1$
-		RESULTSET("ResultSet"), //$NON-NLS-1$
-		RESULTSET_BATCHES(RESULTSET, "batches"), //$NON-NLS-1$
-		PREPAREDPLAN("PreparaedPlan"); //$NON-NLS-1$
 		
-		private String location;
-		
-		Type(String location){
-			this.location = location;
-		}
-		
-		Type(Type base, String location){
-			this.location = base.location+"/"+location; //$NON-NLS-1$
-		}
-		
-		public String location() {
-			return this.location;
-		}
-	}
-	
    /**
     * Retrieves the value for the given Key 
     *

Modified: trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -30,9 +30,7 @@
 
 @ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
 public class CacheConfiguration {
-	
-	public static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100); // 1 hours with 100 nodes.
-		
+			
 	public enum Policy {
 		LRU,  // Least Recently Used
 		EXPIRATION
@@ -43,14 +41,16 @@
 	private int maxEntries;
 	private boolean enabled = true;
 	private String name;
-	
+	private String location;
+
 	public CacheConfiguration() {
 	}
 	
-	public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes) {
+	public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes, String location) {
 		this.policy = policy;
 		this.maxage = maxAgeInSeconds;
 		this.maxEntries = maxNodes;
+		this.location = location;
 	}
 	
 	public Policy getPolicy() {
@@ -89,6 +89,15 @@
 		this.name = name;
 	}
 	
+	@ManagementProperty(description="location prefix in cache", readOnly=true)
+	public String getLocation() {
+		return location;
+	}
+
+	public void setLocation(String location) {
+		this.location = location;
+	}	
+	
 	@Override
 	public int hashCode() {
 		final int prime = 31;

Modified: trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -30,7 +30,7 @@
 	 * @param config configuration setup for the cache
 	 * @return
 	 */
-	<K,V> Cache<K, V> get(Cache.Type type, CacheConfiguration config);
+	<K,V> Cache<K, V> get(String location, CacheConfiguration config);
 
 	/**
 	 * Destroy the cache factory and any caches underneath.

Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -23,18 +23,19 @@
 
 import java.io.Serializable;
 
-import org.teiid.cache.Cache.Type;
+import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.core.TeiidRuntimeException;
 
 
 public class DefaultCacheFactory implements CacheFactory, Serializable {
 	private static final long serialVersionUID = -5541424157695857527L;
+	private static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100, "default"); // 1 hours with 100 nodes. //$NON-NLS-1$
 	
 	DefaultCache cacheRoot;
 	private volatile boolean destroyed = false;
 	
 	public DefaultCacheFactory() {
-		this(CacheConfiguration.DEFAULT);
+		this(DEFAULT);
 	}
 		
 	public DefaultCacheFactory(CacheConfiguration config) {
@@ -47,9 +48,9 @@
 	}
 
 	@Override
-	public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+	public <K, V> Cache<K, V> get(String location, CacheConfiguration config) {
 		if (!destroyed) {
-			return cacheRoot.addChild(type.location());
+			return cacheRoot.addChild(location);
 		}
 		throw new TeiidRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
 	}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -44,7 +44,6 @@
 import org.teiid.adminapi.impl.CacheStatisticsMetadata;
 import org.teiid.adminapi.impl.RequestMetadata;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.cache.Cache;
 import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.CacheFactory;
 import org.teiid.cache.CacheConfiguration.Policy;
@@ -683,24 +682,23 @@
         //result set cache
         CacheConfiguration rsCacheConfig = config.getResultsetCacheConfig();
         if (rsCacheConfig != null && rsCacheConfig.isEnabled()) {
-			this.rsCache = new SessionAwareCache<CachedResults>(this.cacheFactory, Cache.Type.RESULTSET, rsCacheConfig);
+			this.rsCache = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, rsCacheConfig);
 			this.rsCache.setBufferManager(this.bufferManager);
         }
 
         //prepared plan cache
-        prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN,  new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount()));
+        prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, SessionAwareCache.Type.PREPAREDPLAN,  new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount(), "PreparedCache")); //$NON-NLS-1$
         prepPlanCache.setBufferManager(this.bufferManager);
 		
         
         this.processWorkerPool = new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
         
         if (cacheFactory.isReplicated()) {
-        	matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, -1, -1));
+        	matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, -1, -1, "MaterilizationTables")); //$NON-NLS-1$
         	matTables.setBufferManager(this.bufferManager);
         }
         
-        dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,
-                                            this.bufferService), this.bufferManager, this.processWorkerPool, this.rsCache, matTables, this.cacheFactory); 
+        dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,this.bufferService), this.bufferManager, this.processWorkerPool, this.rsCache, this.matTables, this.cacheFactory); 
 	}
 	
 	public void setBufferService(BufferService service) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -51,6 +51,10 @@
  */
 public class SessionAwareCache<T> {
 	public static final int DEFAULT_MAX_SIZE_TOTAL = 512;
+	public enum Type {
+		RESULTSET,
+		PREPAREDPLAN;
+	}
 
 	private Cache<CacheID, T> localCache;
 	private Cache<CacheID, T> distributedCache;
@@ -68,23 +72,24 @@
 	}
 	
 	SessionAwareCache(int maxSize){
-		this(new DefaultCacheFactory(), Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, maxSize));
+		this(new DefaultCacheFactory(), Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, maxSize, "default")); //$NON-NLS-1$
 	}
 	
-	SessionAwareCache (final CacheFactory cacheFactory, final Cache.Type type, final CacheConfiguration config){
+	SessionAwareCache (final CacheFactory cacheFactory, final Type type, final CacheConfiguration config){
 		this.maxSize = config.getMaxEntries();
 		if(this.maxSize < 0){
 			this.maxSize = Integer.MAX_VALUE;
 		}		
 		this.localCache = new DefaultCache<CacheID, T>("local", maxSize, config.getMaxAgeInSeconds()*1000); //$NON-NLS-1$
 		
-		if (type == Cache.Type.PREPAREDPLAN) {
+		if (type == Type.PREPAREDPLAN) {
 			this.distributedCache = localCache;
 		}
 		else {
-			this.distributedCache = cacheFactory.get(type, config);
-			if (type == Cache.Type.RESULTSET) {
-				this.tupleBatchCache = cacheFactory.get(Cache.Type.RESULTSET_BATCHES, config);
+			String location = config.getLocation()+"/"+type.name(); //$NON-NLS-1$
+			this.distributedCache = cacheFactory.get(location, config);
+			if (type == Type.RESULTSET) {
+				this.tupleBatchCache = cacheFactory.get(location+"/batches", config); //$NON-NLS-1$
 			}
 			else {
 				this.tupleBatchCache = this.distributedCache;

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -66,17 +66,17 @@
         this.category = method.getCategory().toUpperCase();
         
         // Get input parameter stuff
-        FunctionParameter[] inputParams = method.getInputParameters();
+        List<FunctionParameter> inputParams = method.getInputParameters();
         if(inputParams == null) { 
             inputParamNames = new ArrayList(0);
             inputParamDescs = new ArrayList(0);
         } else {
-            inputParamNames = new ArrayList(inputParams.length);
-            inputParamDescs = new ArrayList(inputParams.length);
+            inputParamNames = new ArrayList(inputParams.size());
+            inputParamDescs = new ArrayList(inputParams.size());
             
-            for(int i=0; i<inputParams.length; i++) { 
-                inputParamNames.add(inputParams[i].getName().toUpperCase());
-                inputParamDescs.add(inputParams[i].getDescription());
+            for(int i=0; i<inputParams.size(); i++) { 
+                inputParamNames.add(inputParams.get(i).getName().toUpperCase());
+                inputParamDescs.add(inputParams.get(i).getDescription());
             }
         }
         

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -228,7 +228,7 @@
                 
         for (FunctionMethod nextMethod : functionMethods) {
             int currentScore = 0; 
-            final FunctionParameter[] methodTypes = nextMethod.getInputParameters();
+            final List<FunctionParameter> methodTypes = nextMethod.getInputParameters();
             //Holder for current signature with converts where required
             FunctionDescriptor[] currentSignature = new FunctionDescriptor[types.length];
             
@@ -237,7 +237,7 @@
             int i = 0;
             for(; i < types.length; i++) {
             	//treat all varags as the same type
-                final String tmpTypeName = methodTypes[Math.min(i, methodTypes.length - 1)].getType();
+                final String tmpTypeName = methodTypes.get(Math.min(i, methodTypes.size() - 1)).getType();
                 Class<?> targetType = DataTypeManager.getDataTypeClass(tmpTypeName);
 
                 Class<?> sourceType = types[i];

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -263,11 +263,11 @@
         String methodName = method.getName();
 
         // Get input types for path
-        FunctionParameter[] inputParams = method.getInputParameters();
+        List<FunctionParameter> inputParams = method.getInputParameters();
         List<Class> inputTypes = new LinkedList<Class>();
         if(inputParams != null) {
-            for(int i=0; i<inputParams.length; i++) {
-                String typeName = inputParams[i].getType();
+            for(int i=0; i<inputParams.size(); i++) {
+                String typeName = inputParams.get(i).getType();
                 inputTypes.add(DataTypeManager.getDataTypeClass(typeName));
             }
         }

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -23,6 +23,7 @@
 package org.teiid.query.function.metadata;
 
 import java.util.Collection;
+import java.util.List;
 
 import org.teiid.api.exception.query.FunctionMetadataException;
 import org.teiid.core.types.DataTypeManager;
@@ -90,10 +91,10 @@
 	        validateInvocationMethod(method.getInvocationClass(), method.getInvocationMethod(), method.getPushdown());
 
 	        // Validate input parameters
-	        FunctionParameter[] params = method.getInputParameters();
-	        if(params != null) {
-	            for(int i=0; i<params.length; i++) {
-	                validateFunctionParameter(params[i]);
+	       List<FunctionParameter> params = method.getInputParameters();
+	        if(params != null && !params.isEmpty()) {
+	            for(int i=0; i<params.size(); i++) {
+	                validateFunctionParameter(params.get(i));
 	            }
 	        }
 

Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -179,10 +179,11 @@
     		return false;
     	}
     	//metadata hack
-    	if (!(this.expression.getMetadataID() instanceof TempMetadataID)) {
+    	if (this.expression.getGroupSymbol() == null || !(this.expression.getGroupSymbol().getMetadataID() instanceof TempMetadataID)) {
     		return true;
     	}
-    	TempMetadataID tid = (TempMetadataID)this.expression.getMetadataID();
+    	
+    	TempMetadataID tid = (TempMetadataID)this.expression.getGroupSymbol().getMetadataID();
     	return !tid.isScalarGroup();
     }
     

Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -153,8 +153,8 @@
         this.cache = cache;
         this.distributedCache = distibutedCache;
         if (distibutedCache != null) {
-	        CacheConfiguration cc = new CacheConfiguration(Policy.LRU, -1, -1);
-	        tables = cacheFactory.get(Cache.Type.MATTABLES, cc);
+	        CacheConfiguration cc = new CacheConfiguration(Policy.LRU, -1, -1, "MaterializationUpdates"); //$NON-NLS-1$
+	        tables = cacheFactory.get(cc.getLocation(), cc);
         }
     }
     

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -54,7 +54,7 @@
 				assertNull(m.getDescription());
 				
 				assertEquals(1, m.getInputParameterCount());
-				FunctionParameter in = m.getInputParameters()[0];
+				FunctionParameter in = m.getInputParameters().get(0);
 				assertEquals("prop", in.getName());
 				assertEquals("string", in.getType());
 				assertNull(in.getDescription());

Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -45,6 +45,16 @@
         UnitTestUtil.helpTestEquivalence(0, m1, m1);
     }
     
+    public void testEquivalence11() {
+        FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$
+        
+        FunctionMethod m1 = new FunctionMethod("length", "", FunctionCategoryConstants.STRING, //$NON-NLS-1$ //$NON-NLS-2$
+            "com.metamatrix.query.function.FunctionMethods", "length",  //$NON-NLS-1$ //$NON-NLS-2$
+            null, pout );    
+            
+        UnitTestUtil.helpTestEquivalence(0, m1, m1);
+    }    
+    
     public void testEquivalence2() {
         FunctionParameter p1 = new FunctionParameter("in", "string"); //$NON-NLS-1$ //$NON-NLS-2$
         FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -2675,7 +2675,8 @@
         StringBuffer procedure = new StringBuffer("CREATE VIRTUAL PROCEDURE \n"); //$NON-NLS-1$
         procedure.append("BEGIN\n"); //$NON-NLS-1$
         procedure.append("create local temporary table x (y string);\n"); //$NON-NLS-1$
-        procedure.append("update x set y = in1 || 'foo';\n"); //$NON-NLS-1$
+        procedure.append("declare string s = 'foo';\n"); //$NON-NLS-1$
+        procedure.append("update x set y = in1 || s;\n"); //$NON-NLS-1$
         procedure.append("update pm1.g1 set e1 = lookup('pm1.g1', 'e1', 'e2', in1);\n"); //$NON-NLS-1$
         procedure.append("exec pm1.sq2(in1 || 'foo');\n"); //$NON-NLS-1$
         procedure.append("END"); //$NON-NLS-1$

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -150,21 +150,23 @@
 		} catch (IOException e1) {
 			LogManager.logWarning(LogConstants.CTX_RUNTIME, e1, RuntimePlugin.Util.getString("vdb_save_failed", deployment.getName()+"."+deployment.getVersion())); //$NON-NLS-1$ //$NON-NLS-2$			
 		}
+			
+		boolean valid = true;
+		synchronized (deployment) {
+			if (!preview) {
+				valid = validateSources(cmr, deployment);
 				
-		boolean valid = true;
-		if (!preview) {
-			valid = validateSources(cmr, deployment);
-			
-			// Check if the VDB is fully configured.
-			if (valid) {
+				// Check if the VDB is fully configured.
+				if (valid) {
+					deployment.setStatus(VDB.Status.ACTIVE);
+				} else {
+					deployment.setStatus(VDB.Status.INACTIVE);
+				}			
+			}
+			else {
 				deployment.setStatus(VDB.Status.ACTIVE);
-			} else {
-				deployment.setStatus(VDB.Status.INACTIVE);
-			}			
+			}
 		}
-		else {
-			deployment.setStatus(VDB.Status.ACTIVE);
-		}
 		LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_deployed",deployment, valid?"active":"inactive")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
@@ -341,7 +343,7 @@
 			}
     	}
     	
-    	synchronized (this) {
+    	synchronized (vdb) {
 	    	if (!loaded) {
 	    		vdb.setStatus(VDB.Status.INACTIVE);
 	    		String msg = RuntimePlugin.Util.getString("failed_to_retrive_metadata", vdb.getName()+"-"+vdb.getVersion(), model.getName()); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -146,7 +146,7 @@
 			// check to see if the vdb has been modified when server is down; if it is then clear the old files
 			if (this.serializer.isStale(cacheFile, unit.getRoot().getLastModified())) {
 				this.serializer.removeAttachments(unit);
-				LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$				
+				LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", unit.getRoot().getName(), "old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$				
 			}
 			MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile, MetadataStoreGroup.class);
 			if (stores == null) {				
@@ -155,7 +155,7 @@
 				stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
 			}
 			else {
-				LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" has being loaded from cached metadata"); //$NON-NLS-1$ //$NON-NLS-2$
+				LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", unit.getRoot().getName(), "was loaded from cached metadata"); //$NON-NLS-1$ //$NON-NLS-2$
 			}
 			unit.addAttachment(MetadataStoreGroup.class, stores);				
 		}
@@ -176,7 +176,7 @@
 			unit.addAttachment(UDFMetaData.class, udf);
 		}
 				
-		LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
+		LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", unit.getRoot().getName(), "has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
 		return vdb;
 	}
 	

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -67,39 +67,41 @@
 			if (vdb.getStatus() == VDB.Status.ACTIVE || vdb.isPreview()) {
 				continue;
 			}
-			ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
-			
-			for (Model m:vdb.getModels()) {
-				ModelMetaData model = (ModelMetaData)m;
-				if (model.getErrors().isEmpty()) {
-					continue;
+			synchronized (vdb) {
+				ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
+				
+				for (Model m:vdb.getModels()) {
+					ModelMetaData model = (ModelMetaData)m;
+					if (model.getErrors().isEmpty()) {
+						continue;
+					}
+	
+					String sourceName = getSourceName(resourceName, model, translator);
+					if (sourceName != null) {
+						ConnectorManager cm = cmr.getConnectorManager(sourceName);
+						model.clearErrors();
+						String status = cm.getStausMessage();
+						if (status != null && status.length() > 0) {
+							model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), status);
+							LogManager.logInfo(LogConstants.CTX_RUNTIME, status);					
+						}					
+					}
 				}
-
-				String sourceName = getSourceName(resourceName, model, translator);
-				if (sourceName != null) {
-					ConnectorManager cm = cmr.getConnectorManager(sourceName);
-					model.clearErrors();
-					String status = cm.getStausMessage();
-					if (status != null && status.length() > 0) {
-						model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), status);
-						LogManager.logInfo(LogConstants.CTX_RUNTIME, status);					
-					}					
+	
+				boolean valid = true;
+				for (Model m:vdb.getModels()) {
+					ModelMetaData model = (ModelMetaData)m;
+					if (!model.getErrors().isEmpty()) {
+						valid = false;
+						break;
+					}
 				}
-			}
-
-			boolean valid = true;
-			for (Model m:vdb.getModels()) {
-				ModelMetaData model = (ModelMetaData)m;
-				if (!model.getErrors().isEmpty()) {
-					valid = false;
-					break;
+				
+				if (valid) {
+					vdb.setStatus(VDB.Status.ACTIVE);
+					LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
 				}
 			}
-			
-			if (valid) {
-				vdb.setStatus(VDB.Status.ACTIVE);
-				LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
-			}
 		}
 	}
 	
@@ -108,25 +110,26 @@
 			if (vdb.isPreview()) {
 				continue;
 			}
-			
-			for (Model m:vdb.getModels()) {
-				ModelMetaData model = (ModelMetaData)m;
-				
-				String sourceName = getSourceName(resourceName, model, translator);
-				if (sourceName != null) {
-					vdb.setStatus(VDB.Status.INACTIVE);
-					String msg = null;
-					if (translator) {
-						msg = RuntimePlugin.Util.getString("translator_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
+			synchronized (vdb) {
+				for (Model m:vdb.getModels()) {
+					ModelMetaData model = (ModelMetaData)m;
+					
+					String sourceName = getSourceName(resourceName, model, translator);
+					if (sourceName != null) {
+						vdb.setStatus(VDB.Status.INACTIVE);
+						String msg = null;
+						if (translator) {
+							msg = RuntimePlugin.Util.getString("translator_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
+						}
+						else {
+							msg = RuntimePlugin.Util.getString("datasource_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
+						}
+						model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+						LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);					
+						LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_inactivated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$							
 					}
-					else {
-						msg = RuntimePlugin.Util.getString("datasource_not_found", vdb.getName(), vdb.getVersion(), model.getSourceTranslatorName(sourceName)); //$NON-NLS-1$
-					}
-					model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
-					LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);					
-					LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_inactivated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$							
 				}
-			}			
+			}
 		}
 	}
 

Copied: trunk/runtime/src/test/java/org/teiid/transport/TestFailover.java (from rev 2887, branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java)
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestFailover.java	                        (rev 0)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestFailover.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+package org.teiid.transport;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.net.InetSocketAddress;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Test;
+import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.client.security.LogonException;
+import org.teiid.client.security.LogonResult;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.net.CommunicationException;
+import org.teiid.net.ConnectionException;
+import org.teiid.net.HostInfo;
+import org.teiid.net.TeiidURL;
+import org.teiid.net.socket.SocketServerConnection;
+import org.teiid.net.socket.SocketServerConnectionFactory;
+import org.teiid.net.socket.UrlServerDiscovery;
+import org.teiid.transport.TestSocketRemoting.FakeService;
+
+
+ at SuppressWarnings("nls")
+public class TestFailover {
+
+	SocketListener listener;
+	SocketListener listener1;
+
+	private SocketServerConnectionFactory sscf;
+	private InetSocketAddress addr = new InetSocketAddress(0);
+	private int logonAttempts;
+	
+	@After public void tearDown() {
+		if (this.listener != null) {
+			this.listener.stop();
+		}
+		if (this.listener1 != null) {
+			this.listener1.stop();
+		}
+	}
+
+	private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException,
+			ConnectionException {
+		listener = createListener(addr, config);
+		listener1 = createListener(addr, config);
+		listener1.stop();
+		Properties p = new Properties();
+		TeiidURL teiidUrl = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure);
+		teiidUrl.getHostInfo().add(new HostInfo(addr.getHostName(), listener1.getPort()));
+		String url = teiidUrl.getAppServerURL();
+		p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url); 
+		p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
+		p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
+		if (sscf == null) {
+			sscf = new SocketServerConnectionFactory();
+			sscf.initialize(socketConfig);
+		}
+		return sscf.getConnection(p);
+	}
+
+	private SocketListener createListener(InetSocketAddress address, SSLConfiguration config) {
+		ClientServiceRegistryImpl server = new ClientServiceRegistryImpl();
+		server.registerClientService(ILogon.class, new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
+			@Override
+			public LogonResult logon(Properties connProps)
+					throws LogonException, ComponentNotFoundException {
+				logonAttempts++;
+				return new LogonResult(new SessionToken("dummy"), "x", 1, "z");
+			}
+			
+			@Override
+			public ResultsFuture<?> ping() throws InvalidSessionException,
+					TeiidComponentException {
+				return ResultsFuture.NULL_FUTURE;
+			}
+			
+			@Override
+			public void assertIdentity(SessionToken checkSession)
+					throws InvalidSessionException, TeiidComponentException {
+				throw new InvalidSessionException();
+			}
+
+		}, null); 
+		server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
+		return new SocketListener(address.getPort(), address.getAddress().getHostAddress(), 1024, 1024, 1, config, server, BufferManagerFactory.getStandaloneBufferManager());
+	}
+	
+	@Test public void testFailover() throws Exception {
+		SSLConfiguration config = new SSLConfiguration();
+		Properties p = new Properties();
+		SocketServerConnection conn = helpEstablishConnection(false, config, p);
+		assertTrue(conn.isOpen(1000));
+		//restart the second instance now that we know the connection was made to the first
+		listener1 = createListener(new InetSocketAddress(addr.getAddress(), listener1.getPort()), config);
+		listener.stop();
+		conn.isOpen(1000); //there is a chance this call can fail
+		assertTrue(conn.isOpen(1000));
+		listener1.stop();
+		//both instances are down
+		assertFalse(conn.isOpen(1000));
+		//bring the first back up
+		listener = createListener(new InetSocketAddress(addr.getAddress(), listener.getPort()), config);
+		assertTrue(conn.isOpen(1000));
+		assertEquals(3, logonAttempts);
+		conn.close();
+	}
+	
+}

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -87,7 +87,7 @@
         });
         
         DQPConfiguration config = new DQPConfiguration();
-        config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250));
+        config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250, "resultsetcache")); //$NON-NLS-1$
         this.dqp.setCacheFactory(new DefaultCacheFactory());
         this.dqp.start(config);
         this.sessionService.setDqp(this.dqp);

Modified: 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	2011-01-31 16:09:14 UTC (rev 2890)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/TestResultSetUtil.java	2011-01-31 21:12:16 UTC (rev 2891)
@@ -39,8 +39,10 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.teiid.jdbc.TeiidSQLException;
 
 
+
 /** 
  * TestResultSetUtil was built in order to override the {@link #printThrowable(Throwable, PrintStream)} method
  * in order to call  out.print  instead of out.println
@@ -73,8 +75,22 @@
     
     public static void printThrowable(Throwable t, String sql, PrintStream out) {
       out.println(sql);
+      
+      Throwable answer = t;
+      if (t instanceof TeiidSQLException) {
+    	  TeiidSQLException sqle = (TeiidSQLException) t;
+    	  SQLException se = sqle.getNextException();
+    	  if (se != null) {
+    		  SQLException s = null;
+	    	  while( (s = se.getNextException()) != null) {
+	    		  se = s;
+	    	  }
+	    	  
+	    	  answer = se;
+    	  } 
+      }
         
-      out.print(t.getClass().getName() + " : " + t.getMessage()); //$NON-NLS-1$
+      out.print(t.getClass().getName() + " : " + answer.getMessage()); //$NON-NLS-1$
         	
     }
     



More information about the teiid-commits mailing list