[teiid-commits] teiid SVN: r4249 - in trunk: admin/src/main/java/org/teiid/adminapi/impl and 22 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Jul 20 13:06:33 EDT 2012


Author: shawkins
Date: 2012-07-20 13:06:31 -0400 (Fri, 20 Jul 2012)
New Revision: 4249

Added:
   trunk/test-integration/common/src/test/resources/error-vdb.xml
Modified:
   trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
   trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
   trunk/admin/src/test/resources/vdb-describe.txt
   trunk/api/src/main/java/org/teiid/metadata/MetadataRepository.java
   trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
   trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
   trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java
   trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
   trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
   trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
   trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
   trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
   trunk/engine/src/main/java/org/teiid/query/metadata/BaseMetadataRepository.java
   trunk/engine/src/main/java/org/teiid/query/metadata/DDLMetadataRepository.java
   trunk/engine/src/main/java/org/teiid/query/metadata/NativeMetadataRepository.java
   trunk/engine/src/main/resources/org/teiid/query/i18n.properties
   trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
   trunk/runtime/src/main/java/org/teiid/deployers/EventDistributorImpl.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
   trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
   trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
   trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
   trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
   trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
   trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
Log:
TEIID-2105 refining vdb handling so that we still track structurally valid deployments in the vdbrepository

Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -48,7 +48,11 @@
     	/**
     	 * In the vdb repository and querable, but not necessarily valid
     	 */
-    	ACTIVE,      
+    	ACTIVE,  
+    	/**
+    	 * A invalid vdb that cannot transition to active
+    	 */
+    	FAILED,
     	REMOVED
     };
     

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -47,11 +47,11 @@
 		this.name = name;
 	}
 
+	/**
+	 * 
+	 * @return the jndi name or null if no connection factory is defined
+	 */
 	public String getConnectionJndiName() {
-		// this default could be controlled if needed.
-		if (this.jndiName == null) {
-			return "java:"+name; //$NON-NLS-1$
-		}
 		return jndiName;
 	}
 
@@ -68,6 +68,6 @@
 	}	
 	
 	public String toString() {
-		return getName()+"/"+getTranslatorName()+"/"+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
+		return getName()+", "+getTranslatorName()+", "+getConnectionJndiName(); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 }
\ No newline at end of file

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -77,10 +77,6 @@
 		return this.status;
 	}
 	
-	public boolean isLoading() {
-		return this.status == Status.LOADING;
-	}
-	
 	public synchronized void setStatus(Status s) {
 		this.notifyAll();
 		this.status = s;

Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -214,6 +214,7 @@
 		ModelNode statusAllowed = new ModelNode();
 		statusAllowed.add(Status.ACTIVE.toString());
 		statusAllowed.add(Status.LOADING.toString());
+		statusAllowed.add(Status.FAILED.toString());
 		statusAllowed.add(Status.REMOVED.toString());
 		addAttribute(node, STATUS, ModelType.STRING, true);
 		node.get(STATUS).get(ALLOWED).set(statusAllowed);
@@ -522,7 +523,9 @@
 			}
 			
 			node.get(SOURCE_NAME).set(source.getName());
-			node.get(JNDI_NAME).set(source.getConnectionJndiName());
+			if (source.getConnectionJndiName() != null) {
+				node.get(JNDI_NAME).set(source.getConnectionJndiName());
+			}
 			node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
 			return node;
 		}

Modified: trunk/admin/src/test/resources/vdb-describe.txt
===================================================================
--- trunk/admin/src/test/resources/vdb-describe.txt	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/admin/src/test/resources/vdb-describe.txt	2012-07-20 17:06:31 UTC (rev 4249)
@@ -27,6 +27,7 @@
         "allowed" : [
             "ACTIVE",
             "LOADING",
+            "FAILED",
             "REMOVED"
         ]
     },

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataRepository.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -34,8 +34,10 @@
 	/**
 	 * Loads the schema information for the vdb for the given schemaName. Loads table, procedures, functions, indexes etc.
 	 * @param factory
+	 * @param executionFactory may be null if loading a virtual source
+	 * @param connectionFactory may be null if source is not available
 	 * @return
-	 * @throws TranslatorException
+	 * @throws TranslatorException to indicate a recoverable error, otherwise a RuntimeException
 	 */
 	void loadMetadata(MetadataFactory factory, ExecutionFactory<F, C> executionFactory, F connectionFactory) throws TranslatorException;
 
@@ -112,5 +114,5 @@
 	 * Implementation class must delegete the call to 'next' instance after it is done with the processing of the call.
 	 * @param next
 	 */
-	void setNext(MetadataRepository next);
+	void setNext(MetadataRepository<?, ?> next);
 }

Modified: trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/api/src/main/java/org/teiid/translator/BaseDelegatingExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -439,4 +439,8 @@
 			throws TranslatorException {
 		return delegate.getCacheDirective(command, executionContext, metadata);
 	}
+	@Override
+	public boolean isSourceRequiredForMetadata() {
+		return delegate.isSourceRequiredForMetadata();
+	}
 }

Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -98,6 +98,7 @@
 	 */
 	private boolean immutable;
 	private boolean sourceRequired = true;
+	private Boolean sourceRequiredForMetadata;
 	
 	/*
 	 * Support properties
@@ -223,6 +224,23 @@
 		this.sourceRequired = value;
 	}
 	
+	/**
+     * Flag that indicates if a underlying source connection required for this execution factory to return metadata 
+     * @return {@link Boolean#TRUE} if required, null if possibly required, or {@link Boolean#FALSE} if not required
+     */
+	public boolean isSourceRequiredForMetadata() {
+		if (sourceRequiredForMetadata == null) {
+			//matches pre 8.1 behavior
+			return sourceRequired; 
+		}
+		//TODO we could also consider making this an annotation of the getMetadata call
+		return sourceRequiredForMetadata;
+	}
+	
+	public void setSourceRequiredForMetadata(boolean sourceRequiredForMetadata) {
+		this.sourceRequiredForMetadata = sourceRequiredForMetadata;
+	}
+	
     /**
      * Obtain a reference to the default LanguageFactory that can be used to construct
      * new language interface objects.  This is typically needed when modifying the language
@@ -836,8 +854,9 @@
      * Implement to provide metadata to the metadata for use by the engine.  This is the 
      * primary method of creating metadata for dynamic VDBs.
      * @param metadataFactory
-     * @param conn may be null if there was an error obtaining a connection
-     * @throws TranslatorException
+     * @param conn may be null if the source is not required 
+     * @throws TranslatorException to indicate a recoverable error, otherwise a RuntimeException
+     * @see #isSourceRequiredForMetadata()
      */
     public void getMetadata(MetadataFactory metadataFactory, C conn) throws TranslatorException {
     	

Modified: trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java
===================================================================
--- trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/api/src/test/java/org/teiid/translator/TestBaseDelegatingExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -34,7 +34,7 @@
 		Method[] methods = ExecutionFactory.class.getDeclaredMethods();
 		Method[] proxyMethods = BaseDelegatingExecutionFactory.class.getDeclaredMethods();
 		//excluding the setter methods the counts should be equal
-		assertEquals(methods.length - 9, proxyMethods.length);
+		assertEquals(methods.length - 10, proxyMethods.length);
 	}
 	
 }

Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2012-07-20 17:06:31 UTC (rev 4249)
@@ -29,6 +29,7 @@
   <li><B>VDB Reuse</B> a vdb.xml can now declare imported vdbs to reuse metadata.
   <LI><B>Comparable Object</B> - the system property org.teiid.comparableObject can be set to use OBJECT values in comparison/sorting/grouping operations.  It is expected that the object values correctly implement Comparable.compareTo.
   <LI><B>Admin Metadata</B> - you can now retrieve metadata in DDL from the admin api via the getSchema method.
+  <LI><B>Improved VDB loading</B> - vdb loading logic was refined to make administration easier.  ExecutionFactory now has is/setSourceRequiredForMetadata() to indicate whether a source connection is needed for the getMetadata call.
 </UL>
 
 <h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -46,7 +47,7 @@
   <li>DDL functions/procedures defined without the VIRTUAL keyword are by default VIRTUAL.  Use the FOREIGN keyword to indicate that they are source specific.
   <li>FunctionMethod.getFullName returns the proper schema, not category qualified name.
   <li>VDB.getUrl has been removed.
-  <li>VDB.Status now has three states - LOADING, ACTIVE, REMOVED.  To check for validity use the isValid method, rather than checking for the VALID state.
+  <li>VDB.Status now has four states - LOADING, ACTIVE, FAILED, REMOVED.  To check for validity use the isValid method, rather than checking for the VALID state.  FAILED deployments will still be accessible via the admin getVDB methods.
   <li>The standalone and cli configuration files specify a setting for the teiid subsystem policy-decider-module.  If a module is not specified, then data roles will not be checked.
   <li>local connections specifying a VDB version will wait for their VDB to finish loading before allowing a connection, see the waitForLoad connection property for more.
   <li>jsonToXml document elements will contain xsi:type attribute values of decimal and boolean respectively for number and boolean json values to allow for differentiation from string values.
@@ -54,6 +55,8 @@
   <li>Datatype default values have been corrected for Teiid built-in types.  All datatypes are now nullable by default, only character string types are case sensitive, numeric types have radix 10, and length/precision/scale have been set appropriately.
   <li>pg catalog and dynamic vdb created metadata will use a generated Teiid id rather than a random UUID.
   <li>transport ssl config no longer uses the enabled attribute.  Use mode=disabled to disable the usage of encryption.
+  <li>If a MetadataRepository throws a RuntimeException during load, that will be treated as a non-recoverable error and the VDB will have a FAILED status.
+  <li>It was an undocumented behavior that is a source did not specify a jndi connection that "java:/name" would be assumed.  That is no longer the case.  It the source needs a connection, then one must be specified.
 <ul>
 
 <h4>from 7.x</h4>

Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -44,6 +44,7 @@
 	
 	public YahooExecutionFactory() {
 		setMaxInCriteriaSize(YAHOO_MAX_SET_SIZE);
+		setSourceRequiredForMetadata(false);
 	}
 	
     @Override

Modified: trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
===================================================================
--- trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -147,6 +147,10 @@
 	private Charset encoding = Charset.defaultCharset();
 	private boolean exceptionIfFileNotFound;
 	
+	public FileExecutionFactory() {
+		setSourceRequired(false);
+	}
+	
 	@TranslatorProperty(display="File Encoding",advanced=true)
 	public String getEncoding() {
 		return encoding.name();

Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -48,6 +48,10 @@
 public class OlapExecutionFactory extends ExecutionFactory<DataSource, Connection> {
 	private static final String INVOKE_MDX = "invokeMdx"; //$NON-NLS-1$
 	
+	public OlapExecutionFactory() {
+		setSourceRequiredForMetadata(false);
+	}
+	
 	@Override
 	public void getMetadata(MetadataFactory metadataFactory, Connection conn) throws TranslatorException {
 		Procedure p = metadataFactory.addProcedure(INVOKE_MDX);

Modified: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -73,6 +73,10 @@
 	private Mode defaultServiceMode = Mode.PAYLOAD;
 	private Binding defaultBinding = Binding.SOAP12;
 	private String xmlParamName;
+	
+	public WSExecutionFactory() {
+		setSourceRequiredForMetadata(false);
+	}
 
 	@TranslatorProperty(description="Contols request/response message wrapping - set to MESSAGE for full control over SOAP messages.", display="Default Service Mode")
 	public Mode getDefaultServiceMode() {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManagerRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -29,8 +29,10 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SourceMappingMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.core.TeiidException;
+import org.teiid.core.util.EquivalenceUtil;
 import org.teiid.query.QueryPlugin;
 import org.teiid.translator.ExecutionFactory;
 
@@ -80,13 +82,13 @@
 			if (sourceNames.size() > 1 && !model.isSupportsMultiSourceBindings()) {
 				throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31102, model.getName(), deployment.getName(), deployment.getVersion()));
 			}
-			for (String source:sourceNames) {
-				ConnectorManager cm = getConnectorManager(source);
-				String name = model.getSourceTranslatorName(source);
-				String connection = model.getSourceConnectionJndiName(source);
+			for (SourceMappingMetadata source : model.getSourceMappings()) {
+				ConnectorManager cm = getConnectorManager(source.getName());
+				String name = source.getTranslatorName();
+				String connection = source.getConnectionJndiName();
 				if (cm != null) {
 					if (!cm.getTranslatorName().equals(name)
-							|| !cm.getConnectionName().equals(connection)) {
+							|| !EquivalenceUtil.areEqual(cm.getConnectionName(), connection)) {
 						throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31103, source, deployment.getName(), deployment.getVersion()));
 					}
 					continue;
@@ -94,7 +96,7 @@
 				cm = createConnectorManager(name, connection);
 				ExecutionFactory<Object, Object> ef = provider.getExecutionFactory(name);
 				cm.setExecutionFactory(ef);
-				addConnectorManager(source, cm);
+				addConnectorManager(source.getName(), cm);
 			}
 		}
 	}

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	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -43,6 +43,7 @@
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.Request.ProcessingState;
 import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.RequestMetadata;
 import org.teiid.adminapi.impl.TransactionMetadata;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
@@ -318,7 +319,7 @@
 
 	public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage requestMsg) throws TeiidProcessingException {
     	DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-    	checkLoading(workContext);
+    	checkActive(workContext);
 		RequestID requestID = workContext.getRequestID(reqID);
 		requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), this.config.getMaxRowsFetchSize()));
 		Request request = null;
@@ -874,14 +875,14 @@
 			boolean allowDoubleQuotedVariable)
 			throws TeiidComponentException, TeiidProcessingException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		checkLoading(workContext);
+		checkActive(workContext);
 		MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
 	}
 
-	private void checkLoading(DQPWorkContext workContext)
+	private void checkActive(DQPWorkContext workContext)
 			throws TeiidProcessingException {
-		if (workContext.getVDB().isLoading()) {
+		if (workContext.getVDB().getStatus() != Status.ACTIVE) {
 			throw new TeiidProcessingException(QueryPlugin.Event.TEIID31099, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31099, workContext.getVDB()));
 		}
 	}

Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -483,7 +483,6 @@
 		TEIID30564,
 		TEIID30565,
 		TEIID30580,
-		TEIID30581,
 		TEIID30590,
 		TEIID30591,
 		TEIID30600, 

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BaseMetadataRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/BaseMetadataRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BaseMetadataRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -28,16 +28,16 @@
 import org.teiid.metadata.MetadataRepository;
 import org.teiid.metadata.Procedure;
 import org.teiid.metadata.Table;
+import org.teiid.metadata.TableStats;
 import org.teiid.metadata.Table.TriggerEvent;
-import org.teiid.metadata.TableStats;
 import org.teiid.translator.ExecutionFactory;
 import org.teiid.translator.TranslatorException;
 
-public class BaseMetadataRepository<F, C> implements MetadataRepository {
+public class BaseMetadataRepository<F, C> implements MetadataRepository<F, C> {
 	protected MetadataRepository nextRepository;
 	
 	@Override
-	public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
+	public void loadMetadata(MetadataFactory factory, ExecutionFactory<F, C> executionFactory, F connectionFactory) throws TranslatorException {
 		if (this.nextRepository != null) {
 			this.nextRepository.loadMetadata(factory, executionFactory, connectionFactory);
 		}		

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/DDLMetadataRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/DDLMetadataRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/DDLMetadataRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -21,6 +21,7 @@
  */
 package org.teiid.query.metadata;
 
+import org.teiid.core.TeiidRuntimeException;
 import org.teiid.metadata.MetadataFactory;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.parser.ParseException;
@@ -36,7 +37,7 @@
 		try {
 			QueryParser.getQueryParser().parseDDL(factory, factory.getRawMetadata());
 		} catch (ParseException e) {
-			throw new TranslatorException(QueryPlugin.Event.TEIID30386, e);
+			throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30386, e);
 		}
 		super.loadMetadata(factory, executionFactory, connectionFactory);
 	}	

Modified: trunk/engine/src/main/java/org/teiid/query/metadata/NativeMetadataRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/NativeMetadataRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/NativeMetadataRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -24,11 +24,7 @@
 import javax.resource.ResourceException;
 
 import org.teiid.metadata.MetadataFactory;
-import org.teiid.metadata.Schema;
-import org.teiid.metadata.Table;
 import org.teiid.query.QueryPlugin;
-import org.teiid.query.function.metadata.FunctionMetadataValidator;
-import org.teiid.query.validator.ValidatorReport;
 import org.teiid.resource.spi.WrappedConnection;
 import org.teiid.translator.ExecutionFactory;
 import org.teiid.translator.TranslatorException;
@@ -42,7 +38,7 @@
 			throw new TranslatorException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30591, factory.getName()));
 		}
 		
-		if (connectionFactory == null && executionFactory.isSourceRequired()) {
+		if (connectionFactory == null && executionFactory.isSourceRequiredForMetadata()) {
 			throw new TranslatorException(QueryPlugin.Event.TEIID31097, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31097));
 		}
 		
@@ -53,7 +49,10 @@
 			try {
 				unwrapped = ((WrappedConnection)connection).unwrap();
 			} catch (ResourceException e) {
-				 throw new TranslatorException(QueryPlugin.Event.TEIID30477, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30477));
+				if (executionFactory.isSourceRequiredForMetadata()) {
+					throw new TranslatorException(QueryPlugin.Event.TEIID30477, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30477));
+				}
+				connection = null;
 			}	
 		}
 		
@@ -62,21 +61,7 @@
 		} finally {
 			executionFactory.closeConnection(connection, connectionFactory);
 		}
-		validateMetadata(factory.getSchema());
-		
 		super.loadMetadata(factory, executionFactory, connectionFactory);		
 	}
 	
-    private void validateMetadata(Schema schema) throws TranslatorException {
-    	for (Table t : schema.getTables().values()) {
-			if (t.getColumns() == null || t.getColumns().size() == 0) {
-				throw new TranslatorException(QueryPlugin.Event.TEIID30580, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30580, t.getFullName())); 
-			}
-		}
-    	ValidatorReport report = new ValidatorReport("Translator metadata load " + schema.getName()); //$NON-NLS-1$
-		FunctionMetadataValidator.validateFunctionMethods(schema.getFunctions().values(),report);
-		if(report.hasItems()) {
-		    throw new TranslatorException(QueryPlugin.Util.getString("ERR.015.001.0005", report)); //$NON-NLS-1$
-		}
-	}	
 }

Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties	2012-07-20 17:06:31 UTC (rev 4249)
@@ -974,7 +974,6 @@
 TEIID30519=Unknown START flags
 TEIID30517=Client thread already involved in a transaction. Transaction nesting is not supported. The current transaction must be completed first.
 
-TEIID30580=Invalid schema from translator metadata expected {0}, but the returned MetadataStore contained no such schema or more than 1 schema.
 TEIID30581=Invalid table {0}.  A table must have 1 or more columns. 
 
 TEIID30590=Transaction Is null
@@ -1016,7 +1015,7 @@
 
 TEIID31096=Canceling query {0} since it has exceeded the timeout of {1} milliseconds.
 
-TEIID31099=VDB {0} is still loading.  Resubmit your query after loading has completed.
+TEIID31099=VDB {0} is not active.  Resubmit your query after loading has completed or after the errors have been corrected.
 
 TEIID31101=Source names are not unique for model {0} in {1}.{2}
 TEIID31102=Multiple sources on non multi-source model {0} in {1}.{2}

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -21,15 +21,7 @@
  */
 package org.teiid.jboss;
 
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ALLOWED;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEFAULT;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ONLY;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REPLY_PROPERTIES;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE_TYPE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -37,7 +29,12 @@
 import java.sql.Clob;
 import java.sql.SQLException;
 import java.sql.SQLXML;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.ResourceBundle;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -56,7 +53,10 @@
 import org.jboss.jca.common.api.metadata.ra.ResourceAdapter1516;
 import org.jboss.msc.service.ServiceController;
 import org.jboss.msc.service.ServiceName;
-import org.teiid.adminapi.*;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.Admin.SchemaObjectType;
 import org.teiid.adminapi.VDB.ConnectionType;
 import org.teiid.adminapi.impl.CacheStatisticsMetadata;
@@ -65,10 +65,10 @@
 import org.teiid.adminapi.impl.TransactionMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.adminapi.impl.VDBMetadataMapper;
-import org.teiid.adminapi.impl.VDBMetadataMapper.TransactionMetadataMapper;
-import org.teiid.adminapi.impl.VDBMetadataMapper.VDBTranslatorMetaDataMapper;
 import org.teiid.adminapi.impl.VDBTranslatorMetaData;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.adminapi.impl.VDBMetadataMapper.TransactionMetadataMapper;
+import org.teiid.adminapi.impl.VDBMetadataMapper.VDBTranslatorMetaDataMapper;
 import org.teiid.client.RequestMessage;
 import org.teiid.client.ResultsMessage;
 import org.teiid.client.plan.PlanNode;
@@ -697,7 +697,7 @@
 		String user = "CLI ADMIN"; //$NON-NLS-1$
 		LogManager.logDetail(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("admin_executing", user, command)); //$NON-NLS-1$
 		
-        VDBMetaData vdb = this.vdbRepo.getVDB(vdbName, version);
+        VDBMetaData vdb = this.vdbRepo.getLiveVDB(vdbName, version);
         if (vdb == null) {
         	throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString("wrong_vdb")));//$NON-NLS-1$
         }
@@ -894,7 +894,7 @@
 		int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
 		String modelName = operation.get(OperationsConstants.MODEL_NAME).asString();
 
-		VDBMetaData vdb = repo.getVDB(vdbName, vdbVersion);
+		VDBMetaData vdb = repo.getLiveVDB(vdbName, vdbVersion);
 		if (vdb == null || (vdb.getStatus() != VDB.Status.ACTIVE)) {
 			throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.getString("no_vdb_found", vdbName, vdbVersion))); //$NON-NLS-1$
 		}
@@ -972,9 +972,6 @@
 		ModelNode result = context.getResult();
 		List<VDBMetaData> vdbs = repo.getVDBs();
 		for (VDBMetaData vdb:vdbs) {
-			if (vdb == null) {
-				continue; // when vdb deployed but metadata is still being loaded this reports as null
-			}			
 			VDBMetadataMapper.INSTANCE.wrap(vdb, result.add());
 		}
 	}

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -143,6 +143,8 @@
 			indexRepo = new IndexMetadataRepository(indexFactory);
 			visibilityMap = indexFactory.getEntriesPlusVisibilities();
 		}
+		VDBRepository repo = vdbStatusChecker.getVDBRepository();
+		repo.addPendingDeployment(deployment);
 		// build a VDB service
 		final VDBService vdb = new VDBService(deployment, visibilityMap);
 		if (indexRepo != null) {
@@ -325,6 +327,8 @@
 				LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+" metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
 			}		
 		}
+		final VDBMetaData deployment = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
+		this.vdbStatusChecker.getVDBRepository().removeVDB(deployment.getName(), deployment.getVersion());
 	}
 	
 }

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -366,20 +366,17 @@
 						ConnectorManager cm = getConnectorManager(model, cmr);
 						if (cm != null) {
 							ef = cm.getExecutionFactory();
-							if (ef.isSourceRequired()) {
-								cf = cm.getConnectionFactory();
-							}
+							cf = cm.getConnectionFactory();
 						}
-					} catch (TranslatorException e1) {
-						//ignore data source not availability, it may not be required.
+					} catch (TranslatorException e) {
+						//cf not available
 					}
-					
 					try {
 						metadataRepo.loadMetadata(factory, ef, cf);		
+						LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50030,vdb.getName(), vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date())));
 						metadataLoaded = true;
-						LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50030,vdb.getName(), vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date())));					
-					} catch (Exception e) {					
-				    	ex = e;
+					} catch (Exception e) {
+						ex = e;
 					}
 				}
 		    					
@@ -390,12 +387,16 @@
 							cacheMetadataStore(model, factory);
 			    		}
 						
-						metadataLoaded(vdb, model, vdbMetadataStore, loadCount, factory);
+						metadataLoaded(vdb, model, vdbMetadataStore, loadCount, factory, true);
 			    	} else {
 			    		model.addRuntimeError(ex.getMessage()); 
 						LogManager.logWarning(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50036,vdb.getName(), vdb.getVersion(), model.getName(), ex.getMessage()));
-						//defer the load to the status checker if/when a source is available/redeployed
-						model.addAttchment(Runnable.class, this);
+						if (ex instanceof RuntimeException) {
+							metadataLoaded(vdb, model, vdbMetadataStore, loadCount, factory, false);
+						} else {
+							//defer the load to the status checker if/when a source is available/redeployed
+							model.addAttchment(Runnable.class, this);
+						}
 			    	}
 		    	}
 			}

Modified: trunk/runtime/src/main/java/org/teiid/deployers/EventDistributorImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/EventDistributorImpl.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/deployers/EventDistributorImpl.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -50,7 +50,7 @@
 	@Override
 	public void updateMatViewRow(String vdbName, int vdbVersion, String schema,
 			String viewName, List<?> tuple, boolean delete) {
-		VDBMetaData metadata = getVdbRepository().getVDB(vdbName, vdbVersion);
+		VDBMetaData metadata = getVdbRepository().getLiveVDB(vdbName, vdbVersion);
 		if (metadata != null) {
 			GlobalTableStore gts = metadata.getAttachment(GlobalTableStore.class);
 			if (gts != null) {
@@ -124,7 +124,7 @@
 	}
 
 	private Schema getSchema(String vdbName, int vdbVersion, String schemaName) {
-		VDBMetaData vdb = getVdbRepository().getVDB(vdbName, vdbVersion);
+		VDBMetaData vdb = getVdbRepository().getLiveVDB(vdbName, vdbVersion);
 		if (vdb == null) {
 			return null;
 		}
@@ -143,7 +143,7 @@
 		if (t == null) {
 			return;
 		}
-		DdlPlan.alterInsteadOfTrigger(getVdbRepository().getVDB(vdbName, vdbVersion), t, triggerDefinition, enabled, triggerEvent);
+		DdlPlan.alterInsteadOfTrigger(getVdbRepository().getLiveVDB(vdbName, vdbVersion), t, triggerDefinition, enabled, triggerEvent);
 	}
 	
 	@Override
@@ -156,7 +156,7 @@
 		if (p == null) {
 			return;
 		}
-		DdlPlan.alterProcedureDefinition(getVdbRepository().getVDB(vdbName, vdbVersion), p, definition);
+		DdlPlan.alterProcedureDefinition(getVdbRepository().getLiveVDB(vdbName, vdbVersion), p, definition);
 	}
 	
 	@Override
@@ -165,13 +165,13 @@
 		if (t == null) {
 			return;
 		}
-		DdlPlan.alterView(getVdbRepository().getVDB(vdbName, vdbVersion), t, definition);
+		DdlPlan.alterView(getVdbRepository().getLiveVDB(vdbName, vdbVersion), t, definition);
 	}
 	
 	@Override
 	public void setProperty(String vdbName, int vdbVersion, String uuid,
 			String name, String value) {
-		VDBMetaData vdb = getVdbRepository().getVDB(vdbName, vdbVersion);
+		VDBMetaData vdb = getVdbRepository().getLiveVDB(vdbName, vdbVersion);
 		if (vdb == null) {
 			return;
 		}

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -23,6 +23,7 @@
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -64,6 +65,8 @@
 	private static final int DEFAULT_TIMEOUT_MILLIS = PropertiesUtils.getIntProperty(System.getProperties(), "org.teiid.clientVdbLoadTimeoutMillis", 300000); //$NON-NLS-1$
 	
 	private NavigableMap<VDBKey, CompositeVDB> vdbRepo = new ConcurrentSkipListMap<VDBKey, CompositeVDB>();
+	private NavigableMap<VDBKey, VDBMetaData> pendingDeployments = new ConcurrentSkipListMap<VDBKey, VDBMetaData>();
+
 	private MetadataStore systemStore = SystemMetadata.getInstance().getSystemStore();
 	private MetadataStore odbcStore;
 	private boolean odbcEnabled = false;
@@ -99,6 +102,7 @@
 				 throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40035, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion()));
 			}
 			this.vdbRepo.put(key, cvdb);
+			this.pendingDeployments.remove(key);
 			vdbAdded.signalAll();
 		} finally {
 			lock.unlock();
@@ -151,7 +155,13 @@
 		return this.vdbRepo.get(new VDBKey(name, version));
 	}
 	
-	public VDBMetaData getVDB(String name, int version) {
+	/**
+	 * A live vdb may be loading or active
+	 * @param name
+	 * @param version
+	 * @return
+	 */
+	public VDBMetaData getLiveVDB(String name, int version) {
 		CompositeVDB v = getCompositeVDB(name, version);
 		if (v != null) {
 			return v.getVDB();
@@ -164,14 +174,26 @@
 		for(CompositeVDB cVDB:this.vdbRepo.values()) {
 			vdbs.add(cVDB.getVDB());
 		}
+		//there is a minor chance of a duplicate entry
+		//but we're not locking to prevent that
+		vdbs.addAll(pendingDeployments.values());
 		return vdbs;
 	}
 	
+	Collection<CompositeVDB> getCompositeVDBs() {
+		return vdbRepo.values();
+	}
+	
     protected VDBKey vdbId(VDBMetaData vdb) {
         return new VDBKey(vdb.getName(), vdb.getVersion());
     } 	
 		
-	public VDBMetaData getVDB(String vdbName) {
+    /**
+     * A live vdb may be loading or active
+     * @param vdbName
+     * @return
+     */
+	public VDBMetaData getLiveVDB(String vdbName) {
     	int latestVersion = 0;
     	VDBMetaData result = null;
         for (Map.Entry<VDBKey, CompositeVDB> entry:this.vdbRepo.tailMap(new VDBKey(vdbName, 0)).entrySet()) {
@@ -229,6 +251,7 @@
 	}
 
 	private VDBMetaData removeVDB(VDBKey key) {
+		this.pendingDeployments.remove(key);
 		CompositeVDB removed = this.vdbRepo.remove(key);
 		if (removed == null) {
 			return null;
@@ -255,8 +278,11 @@
 		if (v == null) {
 			return;
 		}
+		VDBMetaData metadataAwareVDB = v.getVDB();			
+		if (metadataAwareVDB.getStatus() == Status.FAILED) {
+			return;
+		}
 		v.metadataLoadFinished();
-		VDBMetaData metadataAwareVDB = v.getVDB();			
 		synchronized (metadataAwareVDB) {
 			ValidatorReport report = new MetadataValidator().validate(metadataAwareVDB, metadataAwareVDB.removeAttachment(MetadataStore.class));
 
@@ -264,9 +290,9 @@
 				LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version));
 				if (!v.getVDB().isPreview()) {
 					processMetadataValidatorReport(key, report);
-					if (v.getVDB().getStatus() == Status.REMOVED) {
-						return;
-					}
+					v.getVDB().setStatus(Status.FAILED);
+					LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,name, version, metadataAwareVDB.getStatus()));
+					return;
 				}
 			} 
 			validateDataSources(metadataAwareVDB);
@@ -281,7 +307,6 @@
 	 * @param report  
 	 */
 	protected void processMetadataValidatorReport(VDBKey key, ValidatorReport report) {
-		this.removeVDB(key);
 	}
 
 	void validateDataSources(VDBMetaData vdb) {
@@ -333,5 +358,19 @@
 	
 	public void setSystemFunctionManager(SystemFunctionManager mgr) {
 		this.systemFunctionManager = mgr;
+	}
+
+	public void addPendingDeployment(VDBMetaData deployment) {
+		VDBKey key = vdbId(deployment);
+		this.pendingDeployments.put(key, deployment);
+	}
+
+	public VDBMetaData getVDB(String vdbName, int vdbVersion) {
+		VDBKey key = new VDBKey(vdbName, vdbVersion);
+		CompositeVDB cvdb = this.vdbRepo.get(key);
+		if (cvdb != null) {
+			return cvdb.getVDB();
+		}
+		return this.pendingDeployments.get(key);
 	}	
 }

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -79,7 +79,10 @@
 			dsName = dsName.substring(5);
 		}		
 		
-		VDBMetaData vdb = getVDBRepository().getVDB(vdbName, vdbVersion);
+		VDBMetaData vdb = getVDBRepository().getLiveVDB(vdbName, vdbVersion);
+		if (vdb.getStatus() == Status.FAILED) {
+			return;
+		}
 		ModelMetaData model = vdb.getModel(modelName);
 
 		synchronized (vdb) {
@@ -126,7 +129,11 @@
 
 	public void resourceAdded(String resourceName) {
 		List<Runnable> runnables = new ArrayList<Runnable>();
-		for (VDBMetaData vdb:getVDBRepository().getVDBs()) {
+		for (CompositeVDB cvdb:getVDBRepository().getCompositeVDBs()) {
+			VDBMetaData vdb = cvdb.getVDB();
+			if (vdb.getStatus() == Status.FAILED) {
+				continue;
+			}
 			synchronized (vdb) {
 				ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
 				boolean usesResourse = false;
@@ -183,7 +190,11 @@
 	}
 	
 	public void resourceRemoved(String resourceName) {
-		for (VDBMetaData vdb:getVDBRepository().getVDBs()) {
+		for (CompositeVDB cvdb:getVDBRepository().getCompositeVDBs()) {
+			VDBMetaData vdb = cvdb.getVDB();
+			if (vdb.getStatus() == Status.FAILED) {
+				continue;
+			}
 			synchronized (vdb) {
 				ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
 				for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
@@ -191,13 +202,14 @@
 					if (sourceName == null) {
 						continue;
 					}
+					Severity severity = Severity.WARNING;
 					ConnectorManager cm = cmr.getConnectorManager(sourceName);
-					if (cm.getExecutionFactory().isSourceRequired()) {
-						String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(), vdb.getVersion(), resourceName); 
-						Severity severity = vdb.getStatus() == Status.LOADING?Severity.WARNING:Severity.ERROR;
-						model.addRuntimeMessage(severity, msg);
-						LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
+					if (cm.getExecutionFactory().isSourceRequired() && vdb.getStatus() == Status.ACTIVE) {
+						severity = Severity.ERROR;
 					}
+					String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(), vdb.getVersion(), resourceName); 
+					model.addRuntimeMessage(severity, msg);
+					LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
 				}
 			}
 		}

Modified: trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -30,6 +30,7 @@
 
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.Model.Type;
+import org.teiid.adminapi.VDB.Status;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.SourceMappingMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
@@ -152,12 +153,16 @@
 	protected void metadataLoaded(final VDBMetaData vdb,
 			final ModelMetaData model,
 			final MetadataStore vdbMetadataStore,
-			final AtomicInteger loadCount, MetadataFactory factory) {
-		// merge into VDB metadata
-		factory.mergeInto(vdbMetadataStore);
+			final AtomicInteger loadCount, MetadataFactory factory, boolean success) {
+		if (success) {
+			// merge into VDB metadata
+			factory.mergeInto(vdbMetadataStore);
 		
-		//TODO: this is not quite correct, the source may be missing
-		model.clearRuntimeMessages();				
+			//TODO: this is not quite correct, the source may be missing
+			model.clearRuntimeMessages();
+		} else {
+			vdb.setStatus(Status.FAILED);
+		}
 		
 		if (loadCount.decrementAndGet() == 0) {
 			getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());

Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -509,16 +509,14 @@
 			ConnectorManager cm = getConnectorManager(model, cmr);
 			if (cm != null) {
 				ef = cm.getExecutionFactory();
-				if (ef.isSourceRequired()) {
-					cf = cm.getConnectionFactory();
-				}
+				cf = cm.getConnectionFactory();
 			}
-		} catch (TranslatorException e1) {
-			//ignore data source not availability, it may not be required.
+		} catch (TranslatorException e) {
+			//cf not available
 		}
 		
 		metadataRepository.loadMetadata(factory, ef, cf);		
-		metadataLoaded(vdb, model, store, loadCount, factory);
+		metadataLoaded(vdb, model, store, loadCount, factory, true);
 	}
 	
 	public void undeployVDB(String vdbName) {

Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -247,10 +247,10 @@
 		try {
 			if (vdbVersion == null) {
 				vdbVersion = "latest"; //$NON-NLS-1$
-				vdb = this.vdbRepository.getVDB(vdbName);
+				vdb = this.vdbRepository.getLiveVDB(vdbName);
 			}
 			else {
-				vdb = this.vdbRepository.getVDB(vdbName, Integer.parseInt(vdbVersion));
+				vdb = this.vdbRepository.getLiveVDB(vdbName, Integer.parseInt(vdbVersion));
 			}         
 		} catch (NumberFormatException e) {
 			 throw new SessionServiceException(RuntimePlugin.Event.TEIID40045, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40045, vdbVersion));

Modified: trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -41,13 +41,13 @@
 		vdb.setStatus(Status.ACTIVE);
 		
 		
-		Mockito.stub(repo.getVDB("name")).toReturn(vdb);
+		Mockito.stub(repo.getLiveVDB("name")).toReturn(vdb);
 		
 		ssi.setVDBRepository(repo);
 		
 		ssi.getActiveVDB("name", null);
 		
-		Mockito.verify(repo, Mockito.times(1)).getVDB("name");
+		Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name");
 	}
 	
 	@Test
@@ -59,13 +59,13 @@
 		vdb.setStatus(Status.ACTIVE);
 		
 		
-		Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
+		Mockito.stub(repo.getLiveVDB("name", 1)).toReturn(vdb);
 		
 		ssi.setVDBRepository(repo);
 		
 		ssi.getActiveVDB("name", "1");
 		
-		Mockito.verify(repo, Mockito.times(1)).getVDB("name", 1);
+		Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name", 1);
 	}
 	
 	
@@ -78,13 +78,13 @@
 		vdb.setStatus(Status.ACTIVE);
 		
 		
-		Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
+		Mockito.stub(repo.getLiveVDB("name", 1)).toReturn(vdb);
 		
 		ssi.setVDBRepository(repo);
 		
 		ssi.getActiveVDB("name.1", null);
 		
-		Mockito.verify(repo, Mockito.times(1)).getVDB("name", 1);
+		Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name", 1);
 	}
 	
 	@Test
@@ -96,7 +96,7 @@
 		vdb.setStatus(Status.ACTIVE);
 		
 		
-		Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
+		Mockito.stub(repo.getLiveVDB("name", 1)).toReturn(vdb);
 		
 		ssi.setVDBRepository(repo);
 		
@@ -116,7 +116,7 @@
 		vdb.setStatus(Status.ACTIVE);
 		
 		
-		Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
+		Mockito.stub(repo.getLiveVDB("name", 1)).toReturn(vdb);
 		
 		ssi.setVDBRepository(repo);
 		

Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -498,10 +498,22 @@
 		String ddl = admin.getSchema(vdbName, 1, "loopy", null, null);
 
 		String expected = "CREATE FOREIGN TABLE Matadata (\n" + 
-				"	execCount int OPTIONS (SEARCHABLE 'Searchable')\n" + 
+				"	execCount integer\n" + 
 				");";
 		assertEquals(expected, ddl);
 		
 		admin.undeploy("loopy.jar");
 	}	
+	
+	@Test public void testErrorDeployment() throws Exception {
+		Collection<?> vdbs = admin.getVDBs();
+		assertTrue(vdbs.isEmpty());
+		
+		admin.deploy("error-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("error-vdb.xml")));
+		
+		AdminUtil.waitForVDBLoad(admin, "error", 1, 3);
+		VDB vdb = admin.getVDB("error", 1);
+		assertEquals(Status.FAILED, vdb.getStatus());
+	}
+
 }

Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -29,7 +29,11 @@
 import org.teiid.metadata.MetadataFactory;
 import org.teiid.metadata.RuntimeMetadata;
 import org.teiid.metadata.Table;
-import org.teiid.translator.*;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
 import org.teiid.translator.loopback.LoopbackExecution;
 import org.teiid.translator.loopback.LoopbackExecutionFactory;
 
@@ -42,6 +46,8 @@
 		setSupportsSelectDistinct(true);
 		setWaitTime(10);
 		setRowCount(200);
+		setSourceRequiredForMetadata(false);
+		setSourceRequired(false);
 	}
 	
 	@Override

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	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -178,7 +178,7 @@
         	
 			this.repo.addVDB(vdbMetaData, metadata, (metadata instanceof IndexMetadataStore)?((IndexMetadataStore)metadata).getEntriesPlusVisibilities():null, udfMetaData, cmr);
 			this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
-			this.repo.getVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
+			this.repo.getLiveVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
 		} catch (VirtualDatabaseException e) {
 			throw new RuntimeException(e);
 		}
@@ -198,7 +198,7 @@
 	}
 	
 	public VDBMetaData getVDB(String vdbName) {
-		return this.repo.getVDB(vdbName, 1);
+		return this.repo.getLiveVDB(vdbName, 1);
 	}
 	
 	public void undeployVDB(String vdbName) {

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java	2012-07-20 00:58:49 UTC (rev 4248)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java	2012-07-20 17:06:31 UTC (rev 4249)
@@ -109,7 +109,7 @@
     	importProperties.setProperty("importer.excludeTables", "VDB\\.SYS\\..*");
     	importProperties.setProperty("importer.excludeProcedures", "VDB\\..*");
     	MetadataFactory mf = getMetadata(importProperties, conn);
-    	assertEquals(17, mf.asMetadataStore().getSchemas().get("TEST").getTables().size());
+    	assertEquals(String.valueOf(mf.asMetadataStore().getSchemas().get("TEST").getTables()), 17, mf.asMetadataStore().getSchemas().get("TEST").getTables().size());
     	assertEquals(0, mf.asMetadataStore().getSchemas().get("TEST").getProcedures().size());
     }
         

Added: trunk/test-integration/common/src/test/resources/error-vdb.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/error-vdb.xml	                        (rev 0)
+++ trunk/test-integration/common/src/test/resources/error-vdb.xml	2012-07-20 17:06:31 UTC (rev 4249)
@@ -0,0 +1,8 @@
+<vdb name="error" version= "1">
+    <model visible = "true" type = "VIRTUAL" name = "x">
+         <metadata type = "DDL"><![CDATA[
+              i'm not valid
+         ]]>
+         </metadata>
+    </model>
+</vdb>
\ No newline at end of file


Property changes on: trunk/test-integration/common/src/test/resources/error-vdb.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the teiid-commits mailing list