Author: shawkins
Date: 2012-07-31 09:13:50 -0400 (Tue, 31 Jul 2012)
New Revision: 4279
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
Log:
TEIID-2115 fix for issue loading a document model
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-07-30 23:32:11
UTC (rev 4278)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-07-31 13:13:50
UTC (rev 4279)
@@ -62,8 +62,9 @@
private FunctionTree systemFunctions;
private boolean metadataloadFinished = false;
private VDBMetaData mergedVDB;
+ private VDBMetaData originalVDB;
- public CompositeVDB(VDBMetaData vdb, MetadataStore metadataStore,
LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, FunctionTree
systemFunctions, ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
+ public CompositeVDB(VDBMetaData vdb, MetadataStore metadataStore,
LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, FunctionTree
systemFunctions, ConnectorManagerRepository cmr, VDBRepository vdbRepository,
MetadataStore... additionalStores) throws VirtualDatabaseException {
this.vdb = vdb;
this.store = metadataStore;
this.visibilityMap = visibilityMap;
@@ -72,6 +73,8 @@
this.cmr = cmr;
this.additionalStores = additionalStores;
this.mergedVDB = vdb;
+ this.originalVDB = vdb;
+ buildCompositeState(vdbRepository);
}
private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStore store, UDFMetaData udf,
FunctionTree systemFunctions, MetadataStore[] additionalStores) {
@@ -101,7 +104,7 @@
return this.mergedVDB;
}
- void buildCompositeState(VDBRepository vdbRepository) throws VirtualDatabaseException {
+ private void buildCompositeState(VDBRepository vdbRepository) throws
VirtualDatabaseException {
if (vdb.getVDBImports().isEmpty()) {
this.vdb.addAttchment(ConnectorManagerRepository.class, this.cmr);
return;
@@ -308,7 +311,11 @@
metadataRepository.endLoadVdb(vdbName, vdbVersion);
}
- public synchronized void metadataLoadFinished() {
+ VDBMetaData getOriginalVDB() {
+ return originalVDB;
+ }
+
+ public void metadataLoadFinished() {
if (this.metadataloadFinished) {
return;
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-07-30 23:32:11
UTC (rev 4278)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-07-31 13:13:50
UTC (rev 4279)
@@ -94,8 +94,7 @@
} else {
stores = new MetadataStore[] {this.systemStore, odbcStore};
}
- CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, stores);
- cvdb.buildCompositeState(this);
+ CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this, stores);
lock.lock();
try {
if (vdbRepo.containsKey(key)) {
@@ -279,7 +278,10 @@
return;
}
VDBMetaData metadataAwareVDB = v.getVDB();
- if (metadataAwareVDB.getStatus() == Status.FAILED) {
+ if (v.getOriginalVDB().getStatus() == Status.FAILED) {
+ if (v.getOriginalVDB() != metadataAwareVDB && metadataAwareVDB.getStatus() ==
Status.LOADING) {
+ metadataAwareVDB.setStatus(Status.FAILED);
+ }
return;
}
v.metadataLoadFinished();
Modified: trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-07-30
23:32:11 UTC (rev 4278)
+++ trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-07-31
13:13:50 UTC (rev 4279)
@@ -136,9 +136,6 @@
}
else {
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " skipped being loaded because of its type
", model.getModelType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (loadCount.decrementAndGet() == 0) {
- getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
- }
}
}
}
@@ -162,9 +159,10 @@
model.clearRuntimeMessages();
} else {
vdb.setStatus(Status.FAILED);
+ //TODO: abort the other loads
}
- if (loadCount.decrementAndGet() == 0) {
+ if (loadCount.decrementAndGet() == 0 || vdb.getStatus() == Status.FAILED) {
getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
}
}
Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2012-07-30
23:32:11 UTC (rev 4278)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java 2012-07-31
13:13:50 UTC (rev 4279)
@@ -60,8 +60,7 @@
cmr.addConnectorManager("source",
getConnectorManager("FakeTranslator", "FakeConnection",
getFuncsOne()));
cmr.addConnectorManager("source2",
getConnectorManager("FakeTranslator2", "FakeConnection2",
getFuncsTwo()));
- CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, null,
RealMetadataFactory.SFM.getSystemFunctions(),cmr);
- cvdb.buildCompositeState(null);
+ CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metadataStore, null, null,
RealMetadataFactory.SFM.getSystemFunctions(),cmr, null);
cvdb.metadataLoadFinished();
return cvdb;
}