[teiid-commits] teiid SVN: r3158 - in branches/7.4.x: runtime/src/main/java/org/teiid/deployers and 1 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue May 10 10:44:57 EDT 2011
Author: shawkins
Date: 2011-05-10 10:44:57 -0400 (Tue, 10 May 2011)
New Revision: 3158
Modified:
branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml
branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
branches/7.4.x/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1580 fix for CME during dynamic vdb load
Modified: branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml
===================================================================
--- branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/runtime-updates.xml 2011-05-10 14:44:57 UTC (rev 3158)
@@ -35,6 +35,7 @@
System procedures and DDL statements should be used instead since the effects will be distributed through the cluster and will not introduce inconsistencies.</para></note>
<para><code>org.teiid.metadata.AbstractMetadataRecord</code> objects passed to the <code>MetadataRepository</code> have not yet been modified.
If the <code>MetadataRepository</code> cannot persist the update, then a <code>RuntimeException</code> should be thrown to prevent the update from being applied by the runtime engine.</para>
+ <note><para>The MetadataRepository can be accessed by multiple threads both during load (if using dynamic vdbs) or at runtime with through DDL statements. Your implementation should handle any needed synchronization.</para></note>
<section>
<title>Costing Updates</title>
<para>See the Reference for the system procedures <code>SYSADMIN.setColumnStats</code> and <code>SYSADMIN.setTableStats</code>.
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2011-05-10 14:44:57 UTC (rev 3158)
@@ -71,7 +71,8 @@
this.cmr = cmr;
this.additionalStores = additionalStores;
this.vdb.addAttchment(ConnectorManagerRepository.class, cmr);
- update(this.vdb, this.systemFunctions);
+ this.mergedVDB = vdb;
+ update();
}
public void addChild(CompositeVDB child) {
@@ -90,15 +91,15 @@
this.mergedVDB = null;
}
- void update(VDBMetaData vdbMetadata, FunctionTree systemFunctions) {
- TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata, getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions);
- vdbMetadata.addAttchment(QueryMetadataInterface.class, metadata);
- vdbMetadata.addAttchment(TransformationMetadata.class, metadata);
+ void update() {
+ TransformationMetadata metadata = buildTransformationMetaData(mergedVDB, getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions, this.additionalStores);
+ mergedVDB.addAttchment(QueryMetadataInterface.class, metadata);
+ mergedVDB.addAttchment(TransformationMetadata.class, metadata);
TempTableStore globalTables = new TempTableStore("SYSTEM"); //$NON-NLS-1$
- vdbMetadata.addAttchment(TempTableStore.class, globalTables);
+ mergedVDB.addAttchment(TempTableStore.class, globalTables);
}
- private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores, UDFMetaData udf, FunctionTree systemFunctions) {
+ private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) {
Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
if (udf != null) {
for (Map.Entry<String, Collection<FunctionMethod>> entry : udf.getFunctions().entrySet()) {
@@ -107,7 +108,7 @@
}
CompositeMetadataStore compositeStore = new CompositeMetadataStore(stores.getStores());
- for (MetadataStore s:this.additionalStores) {
+ for (MetadataStore s:additionalStores) {
compositeStore.addMetadataStore(s);
for (Schema schema:s.getSchemas().values()) {
if (!schema.getFunctions().isEmpty()) {
@@ -126,43 +127,39 @@
}
public VDBMetaData getVDB() {
- if (this.children == null || this.children.isEmpty()) {
- return vdb;
- }
if (this.mergedVDB == null) {
this.mergedVDB = buildVDB();
- update(mergedVDB, this.systemFunctions);
+ update();
}
return this.mergedVDB;
}
-
private VDBMetaData buildVDB() {
- VDBMetaData mergedVDB = new VDBMetaData();
- mergedVDB.setName(this.vdb.getName());
- mergedVDB.setVersion(this.vdb.getVersion());
- mergedVDB.setModels(this.vdb.getModels());
- mergedVDB.setDataPolicies(this.vdb.getDataPolicies());
- mergedVDB.setDescription(this.vdb.getDescription());
- mergedVDB.setStatus(this.vdb.getStatus());
- mergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
- mergedVDB.setConnectionType(this.vdb.getConnectionType());
+ VDBMetaData newMergedVDB = new VDBMetaData();
+ newMergedVDB.setName(this.vdb.getName());
+ newMergedVDB.setVersion(this.vdb.getVersion());
+ newMergedVDB.setModels(this.vdb.getModels());
+ newMergedVDB.setDataPolicies(this.vdb.getDataPolicies());
+ newMergedVDB.setDescription(this.vdb.getDescription());
+ newMergedVDB.setStatus(this.vdb.getStatus());
+ newMergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
+ newMergedVDB.setConnectionType(this.vdb.getConnectionType());
ConnectorManagerRepository mergedRepo = new ConnectorManagerRepository();
mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers());
for (CompositeVDB child:this.children.values()) {
// add models
for (Model m:child.getVDB().getModels()) {
- mergedVDB.addModel((ModelMetaData)m);
+ newMergedVDB.addModel((ModelMetaData)m);
}
for (DataPolicy p:child.getVDB().getDataPolicies()) {
- mergedVDB.addDataPolicy((DataPolicyMetadata)p);
+ newMergedVDB.addDataPolicy((DataPolicyMetadata)p);
}
mergedRepo.getConnectorManagers().putAll(child.cmr.getConnectorManagers());
}
- mergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
- return mergedVDB;
+ newMergedVDB.addAttchment(ConnectorManagerRepository.class, mergedRepo);
+ return newMergedVDB;
}
private UDFMetaData getUDF() {
@@ -216,7 +213,7 @@
return mergedvisibilityMap;
}
- private MetadataStoreGroup getMetadataStores() {
+ public MetadataStoreGroup getMetadataStores() {
if (this.children == null || this.children.isEmpty()) {
return this.stores;
}
@@ -226,9 +223,9 @@
mergedStores.addStores(this.stores.getStores());
}
for (CompositeVDB child:this.children.values()) {
- MetadataStoreGroup stores = child.getMetadataStores();
- if ( stores != null) {
- mergedStores.addStores(stores.getStores());
+ MetadataStoreGroup childStores = child.getMetadataStores();
+ if ( childStores != null) {
+ mergedStores.addStores(childStores.getStores());
}
}
return mergedStores;
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2011-05-10 14:44:57 UTC (rev 3158)
@@ -22,15 +22,15 @@
package org.teiid.deployers;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.teiid.metadata.MetadataStore;
public class MetadataStoreGroup implements Serializable{
private static final long serialVersionUID = -3702321839716725121L;
- List<MetadataStore> stores = new ArrayList<MetadataStore>();
+ List<MetadataStore> stores = new CopyOnWriteArrayList<MetadataStore>();
public void addStores(List<MetadataStore> stores) {
this.stores.addAll(stores);
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2011-05-10 14:44:57 UTC (rev 3158)
@@ -157,11 +157,12 @@
valid = validateSources(cmr, deployment);
// Check if the VDB is fully configured.
- if (valid) {
+ if (!valid) {
+ deployment.setStatus(VDB.Status.INACTIVE);
+ } else if (!deployment.isDynamic()) {
+ this.vdbRepository.finishDeployment(deployment.getName(), deployment.getVersion());
deployment.setStatus(VDB.Status.ACTIVE);
- } else {
- deployment.setStatus(VDB.Status.INACTIVE);
- }
+ }
}
else {
deployment.setStatus(VDB.Status.ACTIVE);
@@ -369,7 +370,7 @@
LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("metadata_loaded",vdb.getName(), vdb.getVersion(), model.getName())); //$NON-NLS-1$
model.clearErrors();
if (vdb.isValid()) {
- this.vdbRepository.updateVDB(vdb.getName(), vdb.getVersion());
+ this.vdbRepository.finishDeployment(vdb.getName(), vdb.getVersion());
vdb.setStatus(VDB.Status.ACTIVE);
LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
}
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-05-10 14:44:57 UTC (rev 3158)
@@ -100,19 +100,17 @@
else {
cvdb = new CompositeVDB(vdb, stores, visibilityMap, udf, this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore);
}
- updateFromMetadataRepository(stores, cvdb);
this.vdbRepo.put(vdbId(vdb), cvdb);
notifyAdd(vdb.getName(), vdb.getVersion());
}
- private void updateFromMetadataRepository(MetadataStoreGroup stores,
- CompositeVDB cvdb) {
+ private void updateFromMetadataRepository(CompositeVDB cvdb) {
if (metadataRepository == null) {
return;
}
String vdbName = cvdb.getVDB().getName();
int vdbVersion = cvdb.getVDB().getVersion();
- LinkedList<MetadataStore> allStores = new LinkedList<MetadataStore>(stores.getStores());
+ LinkedList<MetadataStore> allStores = new LinkedList<MetadataStore>(cvdb.getMetadataStores().getStores());
allStores.addAll(Arrays.asList(cvdb.getAdditionalStores()));
metadataRepository.startLoadVdb(vdbName, vdbVersion);
for (MetadataStore metadataStore : allStores) {
@@ -316,10 +314,11 @@
}
}
- void updateVDB(String name, int version) {
+ public void finishDeployment(String name, int version) {
CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
if (v!= null) {
- v.update(v.getVDB(), systemFunctionManager.getSystemFunctions());
+ updateFromMetadataRepository(v);
+ v.update();
}
}
Modified: branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-05-09 19:00:00 UTC (rev 3157)
+++ branches/7.4.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-05-10 14:44:57 UTC (rev 3158)
@@ -146,6 +146,7 @@
MetadataStoreGroup stores = new MetadataStoreGroup();
stores.addStore(metadata);
this.repo.addVDB(vdbMetaData, stores, entries, null, cmr);
+ this.repo.finishDeployment(vdbName, 1);
} catch (DeploymentException e) {
throw new RuntimeException(e);
}
More information about the teiid-commits
mailing list