Author: shawkins
Date: 2012-06-18 12:09:18 -0400 (Mon, 18 Jun 2012)
New Revision: 4184
Added:
trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
trunk/runtime/src/test/java/org/teiid/runtime/
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
trunk/test-integration/common/src/test/resources/reuse-vdb.xml
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.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/EmbeddedConfiguration.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-2062 adding metadata load to the embedded logic
Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-06-18 14:37:59 UTC (rev
4183)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-06-18 16:09:18 UTC (rev
4184)
@@ -92,12 +92,6 @@
public List<String> getValidityErrors();
/**
- * Shows any validity errors present in the VDB
- * @return
- */
- public List<String> getRuntimeErrors();
-
- /**
* Shows if VDB is a valid entity
* @return
*/
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -24,8 +24,8 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
-
import org.teiid.adminapi.DataPolicy;
@@ -39,7 +39,7 @@
protected PermissionMap permissions = new PermissionMap();
- protected List<String> mappedRoleNames = new ArrayList<String>();
+ protected List<String> mappedRoleNames = new
CopyOnWriteArrayList<String>();
@Override
public String getName() {
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -49,15 +49,6 @@
protected String schemaSourceType;
protected String schemaText;
- public String getName() {
- return super.getName();
- }
-
- // This is needed by JAXB
- public void setName(String name) {
- super.setName(name);
- }
-
@Override
public String getDescription() {
return description;
@@ -170,53 +161,39 @@
this.addSourceMapping(source.getName(), source.getTranslatorName(),
source.getConnectionJndiName());
}
- public List<ValidationError> getErrors(){
- return getValidationErrors(Severity.ERROR);
- }
+ public synchronized List<ValidationError> getErrors(){
+ return getErrors(true);
+ }
- public synchronized List<ValidationError>
getValidationErrors(ValidationError.Severity severity){
- if (this.validationErrors == null) {
+ public synchronized List<ValidationError> getErrors(boolean includeRuntime){
+ if (this.validationErrors == null && this.runtimeErrors == null) {
return Collections.emptyList();
}
List<ValidationError> list = new ArrayList<ValidationError>();
- for (ValidationError ve: this.validationErrors) {
- if (Severity.valueOf(ve.severity) == severity) {
- list.add(ve);
- }
+ if (this.validationErrors != null) {
+ list.addAll(validationErrors);
}
+ if (includeRuntime && this.runtimeErrors != null) {
+ list.addAll(runtimeErrors);
+ }
return list;
- }
+ }
- public synchronized ValidationError addError(String severity, String message) {
- if (this.validationErrors == null) {
- this.validationErrors = new LinkedList<ValidationError>();
- }
+ public ValidationError addError(String severity, String message) {
ValidationError ve = new ValidationError(severity, message);
- this.validationErrors.add(ve);
- if (this.validationErrors.size() > DEFAULT_ERROR_HISTORY) {
- this.validationErrors.remove(0);
- }
+ addError(ve);
return ve;
}
- public List<ValidationError> getRuntimeErrors(){
- if (this.runtimeErrors == null) {
- return Collections.emptyList();
- }
- List<ValidationError> list = new ArrayList<ValidationError>();
- for (ValidationError ve: this.runtimeErrors) {
- if (Severity.valueOf(ve.severity) == Severity.ERROR) {
- list.add(ve);
- }
- }
- return list;
+ public synchronized boolean hasRuntimeErrors(){
+ return this.runtimeErrors != null && !this.runtimeErrors.isEmpty();
}
- public synchronized ValidationError addRuntimeError(String severity, String message)
{
+ public synchronized ValidationError addRuntimeError(String message) {
+ ValidationError ve = new ValidationError(Severity.ERROR.name(), message);
if (this.runtimeErrors == null) {
this.runtimeErrors = new LinkedList<ValidationError>();
}
- ValidationError ve = new ValidationError(severity, message);
this.runtimeErrors.add(ve);
if (this.runtimeErrors.size() > DEFAULT_ERROR_HISTORY) {
this.runtimeErrors.remove(0);
@@ -229,18 +206,13 @@
this.validationErrors = new LinkedList<ValidationError>();
}
this.validationErrors.add(ve);
- if (this.validationErrors.size() > DEFAULT_ERROR_HISTORY) {
- this.validationErrors.remove(0);
- }
return ve;
}
- public synchronized void clearErrors() {
- this.validationErrors.clear();
- }
-
public synchronized void clearRuntimeErrors() {
- this.runtimeErrors.clear();
+ if (runtimeErrors != null) {
+ runtimeErrors = null;
+ }
}
public static class ValidationError implements Serializable{
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -170,41 +170,8 @@
}
@Override
- public List<String> getRuntimeErrors(){
- List<String> allErrors = new ArrayList<String>();
- for (ModelMetaData model:this.models.values()) {
- List<ValidationError> errors = model.getRuntimeErrors();
- if (errors != null && !errors.isEmpty()) {
- for (ValidationError m:errors) {
- if
(ValidationError.Severity.valueOf(m.getSeverity()).equals(ValidationError.Severity.ERROR))
{
- allErrors.add(m.getValue());
- }
- }
- }
- }
- return allErrors;
- }
-
- @Override
public boolean isValid() {
- if (!getValidityErrors().isEmpty()) {
- return false;
- }
- if (!getRuntimeErrors().isEmpty()) {
- return false;
- }
- if (getModels().isEmpty()) {
- return false;
- }
- for(ModelMetaData m: this.models.values()) {
- if (m.isSource()) {
- List<String> resourceNames = m.getSourceNames();
- if (resourceNames.isEmpty()) {
- return false;
- }
- }
- }
- return true;
+ return Status.ACTIVE.equals(this.status);
}
public String toString() {
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -519,7 +519,7 @@
}
// model validation errors
- for (ValidationError ve:model.getErrors()) {
+ for (ValidationError ve:model.getErrors(false)) {
writer.writeStartElement(Element.VALIDATION_ERROR.getLocalName());
writer.writeAttribute(Element.VALIDATION_SEVERITY_ATTR.getLocalName(),
ve.getSeverity());
if (ve.getPath() != null) {
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -47,6 +47,7 @@
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.TypeFacility.RUNTIME_CODES;
+import org.teiid.translator.TypeFacility.RUNTIME_NAMES;
@@ -687,6 +688,14 @@
return pushdownFunctionMethods;
}
+ /**
+ * Adds a pushdown function.
+ * @param qualifier will be pre-pended to the name
+ * @param name
+ * @param returnType see {@link RUNTIME_NAMES} for type names
+ * @param paramTypes see {@link RUNTIME_NAMES} for type names
+ * @return the FunctionMethod created.
+ */
protected FunctionMethod addPushDownFunction(String qualifier, String name, String
returnType, String...paramTypes) {
FunctionMethod method = FunctionMethod.createFunctionMethod(qualifier + '.'
+ name, name, qualifier,
returnType, paramTypes);
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2012-06-18
14:37:59 UTC (rev 4183)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TransactionServerImpl.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -62,7 +62,7 @@
public class TransactionServerImpl implements TransactionService {
- private static class TransactionMapping {
+ protected static class TransactionMapping {
// (connection -> transaction for global and local)
private Map<String, TransactionContext> threadToTransactionContext = new
HashMap<String, TransactionContext>();
@@ -112,10 +112,10 @@
}
}
- private TransactionMapping transactions = new TransactionMapping();
+ protected TransactionMapping transactions = new TransactionMapping();
private XATerminator xaTerminator;
- private TransactionManager transactionManager;
+ protected TransactionManager transactionManager;
private WorkManager workManager;
public void setXaTerminator(XATerminator xaTerminator) {
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -177,8 +177,8 @@
}
private static void log(ValidatorReport report, ModelMetaData model, String msg) {
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
- LogManager.logInfo(LogConstants.CTX_QUERY_RESOLVER, msg);
+ model.addRuntimeError(msg);
+ LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, msg);
report.handleValidationError(msg);
}
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-06-18
14:37:59 UTC (rev 4183)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -100,50 +100,51 @@
for (SetState setState : dependentSetStates) {
setState.valueIterator =
dvs.getValueIterator(setState.valueExpression);
int distinctCount = dvs.getTupleBuffer().getRowCount();
- if (setState.maxNdv > 0 && setState.maxNdv <
distinctCount) {
- if (dvs.getTupleBuffer().getSchema().size() > 1) {
- distinctCount = 0;
- ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
- if
(dvs.getTupleBuffer().getSchema().indexOf(setState.valueExpression) == 0) {
- Object last = null;
- while (vi.hasNext()) {
- Object next = vi.next();
- if (next != null && (last == null ||
Constant.COMPARATOR.compare(next, last) != 0)) {
- distinctCount++;
- }
- last = next;
- }
- } else {
- //secondary attributes are not in sorted order, so we use an
approximate count
- Set<Object> set = null;
- int maxSize = Math.min(10000,
dvs.getTupleBuffer().getRowCount());
- List<Object> buffer = Arrays.asList(new Object[maxSize]);
- if
(!DataTypeManager.isHashable(setState.valueExpression.getType())) {
- set = new TreeSet<Object>(Constant.COMPARATOR);
- } else {
- set = new HashSet<Object>();
- }
- int i = 0;
- while (vi.hasNext()) {
- Object next = vi.next();
- if (next == null) {
- continue;
- }
- if (set.add(next)) {
- distinctCount++;
- }
- Object old = buffer.set(i++%maxSize, next);
- if (set.size() > maxSize) {
- set.remove(old);
- }
- }
- }
+ if (setState.maxNdv <= 0 || setState.maxNdv >= distinctCount)
{
+ continue;
+ }
+ if (dvs.getTupleBuffer().getSchema().size() > 1) {
+ distinctCount = 0;
+ ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
+ if
(dvs.getTupleBuffer().getSchema().indexOf(setState.valueExpression) == 0) {
+ Object last = null;
+ while (vi.hasNext()) {
+ Object next = vi.next();
+ if (next != null && (last == null ||
Constant.COMPARATOR.compare(next, last) != 0)) {
+ distinctCount++;
+ }
+ last = next;
+ }
+ } else {
+ //secondary attributes are not in sorted order, so we use an
approximate count
+ Set<Object> set = null;
+ int maxSize = Math.min(10000, dvs.getTupleBuffer().getRowCount());
+ List<Object> buffer = Arrays.asList(new Object[maxSize]);
+ if
(!DataTypeManager.isHashable(setState.valueExpression.getType())) {
+ set = new TreeSet<Object>(Constant.COMPARATOR);
+ } else {
+ set = new HashSet<Object>();
+ }
+ int i = 0;
+ while (vi.hasNext()) {
+ Object next = vi.next();
+ if (next == null) {
+ continue;
+ }
+ if (set.add(next)) {
+ distinctCount++;
+ }
+ Object old = buffer.set(i++%maxSize, next);
+ if (set.size() > maxSize) {
+ set.remove(old);
+ }
+ }
}
- if (!setState.overMax && distinctCount > setState.maxNdv)
{
- LogManager.logWarning(LogConstants.CTX_DQP,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30011, valueSource, setState.valueExpression,
setState.maxNdv));
- setState.overMax = true;
- }
- }
+ }
+ if (!setState.overMax && distinctCount > setState.maxNdv) {
+ LogManager.logWarning(LogConstants.CTX_DQP,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30011, valueSource, setState.valueExpression,
setState.maxNdv));
+ setState.overMax = true;
+ }
}
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-18
14:37:59 UTC (rev 4183)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -65,7 +65,6 @@
TEIID50026, // VDB undeployed
TEIID50029, // dynamic metadata loaded
TEIID50030,
- TEIID50032, // duplicate VDB
TEIID50035, // translator not found
TEIID50036,
TEIID50037, // odbc enabled
@@ -85,8 +84,6 @@
TEIID50055,
TEIID50056,
TEIID50057,
- TEIID50064,
- TEIID50065,
TEIID50066,
TEIID50067,
TEIID50069,
@@ -98,8 +95,6 @@
TEIID50076,
TEIID50077,
TEIID50078,
- TEIID50086,
- TEIID50087,
TEIID50088
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -23,8 +23,6 @@
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.ServiceLoader;
-import java.util.StringTokenizer;
import java.util.concurrent.Executor;
import org.jboss.as.naming.deployment.ContextNames;
@@ -34,24 +32,20 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.modules.Module;
-import org.jboss.modules.ModuleIdentifier;
-import org.jboss.modules.ModuleLoadException;
-import org.jboss.modules.ModuleLoader;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
-import org.jboss.msc.service.ServiceBuilder.DependencyType;
import org.jboss.msc.service.ServiceController;
-import org.jboss.msc.service.ServiceController.Mode;
-import org.jboss.msc.service.ServiceController.State;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
+import org.jboss.msc.service.ServiceBuilder.DependencyType;
+import org.jboss.msc.service.ServiceController.Mode;
+import org.jboss.msc.service.ServiceController.State;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDBImport;
import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.common.buffer.BufferManager;
@@ -62,12 +56,9 @@
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.MetadataRepository;
import org.teiid.metadata.index.IndexMetadataRepository;
import org.teiid.metadata.index.IndexMetadataStore;
import org.teiid.query.ObjectReplicator;
-import org.teiid.query.metadata.DDLMetadataRepository;
-import org.teiid.query.metadata.NativeMetadataRepository;
import org.teiid.query.metadata.TransformationMetadata.Resource;
@@ -122,8 +113,8 @@
Translator translator =
this.translatorRepository.getTranslatorMetaData(translatorName);
if ( translator == null) {
String msg = IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50077,
translatorName, deployment.getName(), deployment.getVersion());
- model.addError(ValidationError.Severity.ERROR.name(), msg);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
+ model.addRuntimeError(msg);
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, msg);
}
}
}
@@ -150,17 +141,11 @@
indexRepo = new IndexMetadataRepository(indexFactory);
visibilityMap = indexFactory.getEntriesPlusVisibilities();
}
-
- for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
- if (model.isSource() && model.getSourceNames().isEmpty()) {
- throw new
DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50087,
model.getName(), deployment.getName(), deployment.getVersion()));
- }
- MetadataRepository repo = getMetadataRepository(deployment, model.getName(),
indexRepo);
- model.addAttchment(MetadataRepository.class, repo);
- }
-
// build a VDB service
VDBService vdb = new VDBService(deployment, visibilityMap);
+ if (indexRepo != null) {
+ vdb.addMetadataRepository("index", indexRepo); //$NON-NLS-1$
+ }
final ServiceBuilder<RuntimeVDB> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
// add dependencies to data-sources
@@ -241,7 +226,7 @@
@Override
public void start(StartContext context) throws StartException {
- ServiceController s =
context.getController().getServiceContainer().getService(this.svcName);
+ ServiceController<?> s =
context.getController().getServiceContainer().getService(this.svcName);
if (s != null) {
this.vdbStatusChecker.dataSourceAdded(this.dsName);
}
@@ -249,7 +234,7 @@
@Override
public void stop(StopContext context) {
- ServiceController s =
context.getController().getServiceContainer().getService(this.svcName);
+ ServiceController<?> s =
context.getController().getServiceContainer().getService(this.svcName);
if (s.getMode().equals(Mode.REMOVE) || s.getState().equals(State.STOPPING)) {
this.vdbStatusChecker.dataSourceRemoved(this.dsName);
}
@@ -282,74 +267,4 @@
}
}
- private MetadataRepository getMetadataRepository(VDBMetaData vdb, String modelName,
IndexMetadataRepository indexRepo) throws DeploymentUnitProcessingException {
- final ModelMetaData model = vdb.getModel(modelName);
-
- if (model.getSchemaSourceType() == null) {
- if (!vdb.isDynamic()) {
- return indexRepo;
- }
-
- if (vdb.isDynamic() && model.isSource()) {
- return new NativeMetadataRepository();
- }
- return null;
- }
-
- MetadataRepository first = null;
- MetadataRepository current = null;
- MetadataRepository previous = null;
- StringTokenizer st = new StringTokenizer(model.getSchemaSourceType(), ",");
//$NON-NLS-1$
- while (st.hasMoreTokens()) {
- String repoType = st.nextToken().trim();
- if (repoType.equalsIgnoreCase("DDL")) { //$NON-NLS-1$
- current = new DDLMetadataRepository();
- }
- else if (repoType.equalsIgnoreCase("INDEX")) { //$NON-NLS-1$
- current = indexRepo;
- }
- else if (repoType.equalsIgnoreCase("NATIVE")) { //$NON-NLS-1$
- current = new NativeMetadataRepository();
- }
- else {
- // if the schema type is a module based
- current = getModuleBasedMetadataRepository(repoType);
- }
-
- if (current != null) {
- if (first == null) {
- first = current;
- }
-
- if (previous != null) {
- previous.setNext(current);
- }
- previous = current;
- current = null;
- }
- }
- return first;
- }
-
- private MetadataRepository getModuleBasedMetadataRepository(final String moduleName)
throws DeploymentUnitProcessingException {
- final Module module;
- ClassLoader moduleLoader = this.getClass().getClassLoader();
- ModuleLoader ml = Module.getCallerModuleLoader();
- if (moduleName != null && ml != null) {
- try {
- module = ml.loadModule(ModuleIdentifier.create(moduleName));
- moduleLoader = module.getClassLoader();
- } catch (ModuleLoadException e) {
- throw new
DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50057,
moduleName));
- }
- }
-
- final ServiceLoader<MetadataRepository> serviceLoader =
ServiceLoader.load(MetadataRepository.class, moduleLoader);
- if (serviceLoader != null) {
- for (MetadataRepository loader:serviceLoader) {
- return loader;
- }
- }
- return null;
- }
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -31,12 +31,17 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.stream.XMLStreamException;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleIdentifier;
+import org.jboss.modules.ModuleLoadException;
+import org.jboss.modules.ModuleLoader;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceContainer;
@@ -46,11 +51,9 @@
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.SourceMappingMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBMetadataParser;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
@@ -66,8 +69,8 @@
import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException;
-import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
@@ -80,11 +83,12 @@
import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl;
+import org.teiid.runtime.AbstractVDBDeployer;
import org.teiid.translator.DelegatingExecutionFactory;
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorException;
-class VDBService implements Service<RuntimeVDB> {
+class VDBService extends AbstractVDBDeployer implements Service<RuntimeVDB> {
private VDBMetaData vdb;
private RuntimeVDB runtimeVDB;
protected final InjectedValue<VDBRepository> vdbRepositoryInjector = new
InjectedValue<VDBRepository>();
@@ -136,19 +140,19 @@
final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
this.vdbListener = new VDBLifeCycleListener() {
@Override
- public void added(String name, int version, CompositeVDB vdb) {
+ public void added(String name, int version, CompositeVDB cvdb) {
}
@Override
- public void removed(String name, int version, CompositeVDB vdb) {
+ public void removed(String name, int version, CompositeVDB cvdb) {
}
@Override
- public void finishedDeployment(String name, int version, CompositeVDB vdb) {
+ public void finishedDeployment(String name, int version, CompositeVDB cvdb) {
if (!name.equals(VDBService.this.vdb.getName()) || version !=
VDBService.this.vdb.getVersion()) {
return;
}
- VDBMetaData vdbInstance = vdb.getVDB();
+ VDBMetaData vdbInstance = cvdb.getVDB();
// add object replication to temp/matview tables
GlobalTableStore gts = new GlobalTableStoreImpl(getBuffermanager(),
vdbInstance.getAttachment(TransformationMetadata.class));
if (objectReplicatorInjector.getValue() != null) {
@@ -168,31 +172,20 @@
MetadataStore store = new MetadataStore();
try {
+ this.assignMetadataRepositories(vdb, super.getMetadataRepository("index"));
//$NON-NLS-1$
// add transformation metadata to the repository.
getVDBRepository().addVDB(this.vdb, store, visibilityMap, udf, cmr);
} catch (VirtualDatabaseException e) {
- throw new StartException(IntegrationPlugin.Event.TEIID50032.name(), e);
+ throw new StartException(e);
}
this.vdb.removeAttachment(UDFMetaData.class);
-
- // load metadata from the models
- AtomicInteger loadCount = new
AtomicInteger(this.vdb.getModelMetaDatas().values().size());
- for (ModelMetaData model: this.vdb.getModelMetaDatas().values()) {
- MetadataRepository metadataRepository =
model.getAttachment(MetadataRepository.class);
- if (metadataRepository == null) {
- throw new
StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50086,
model.getName(), vdb.getName(), vdb.getVersion()));
- }
- model.addAttchment(MetadataRepository.class, metadataRepository);
- if (model.getModelType() == Model.Type.PHYSICAL || model.getModelType() ==
Model.Type.VIRTUAL) {
- loadMetadata(this.vdb, model, cmr, metadataRepository, store, loadCount);
- LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " was being loaded from its repository in
separate thread"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- 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$
- }
+ try {
+ loadMetadata(this.vdb, cmr, store);
+ } catch (TranslatorException e) {
+ throw new StartException(e);
}
-
+
this.runtimeVDB = buildRuntimeVDB(this.vdb);
}
@@ -232,13 +225,13 @@
}
@Override
- public void start(StartContext context)
+ public void start(StartContext sc)
throws StartException {
}
@Override
- public void stop(StopContext context) {
+ public void stop(StopContext sc) {
}
});
@@ -324,14 +317,12 @@
}
}
+ protected void loadMetadata(final VDBMetaData vdb, final ModelMetaData model, final
ConnectorManagerRepository cmr, final MetadataRepository metadataRepo, final MetadataStore
vdbMetadataStore, final AtomicInteger loadCount) {
- private boolean loadMetadata(final VDBMetaData vdb, final ModelMetaData model, final
ConnectorManagerRepository cmr, final MetadataRepository metadataRepo, final MetadataStore
vdbMetadataStore, final AtomicInteger loadCount) {
-
String msg =
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50029,vdb.getName(),
vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date()));
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
+ model.addRuntimeError(msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
- boolean asynch = false;
Runnable job = new Runnable() {
@Override
public void run() {
@@ -368,7 +359,6 @@
try {
metadataRepo.loadMetadata(factory, ef, cf);
- model.setSchemaText(null); // avoid carrying non required data around.
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 (TranslatorException e) {
@@ -385,18 +375,11 @@
cacheMetadataStore(model, factory);
}
- // merge into VDB metadata
- factory.mergeInto(vdbMetadataStore);
-
- model.clearErrors();
-
- if (loadCount.decrementAndGet() == 0) {
- getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
- }
+ metadataLoaded(vdb, model, vdbMetadataStore, loadCount, factory);
}
else {
for (String errorMsg:errorMessages) {
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(),
errorMsg);
+ model.addRuntimeError(errorMsg);
LogManager.logWarning(LogConstants.CTX_RUNTIME, errorMsg);
}
}
@@ -414,22 +397,10 @@
job.run();
}
else {
- asynch = true;
executor.execute(job);
}
- return asynch;
}
- private ConnectorManager getConnectorManager(final ModelMetaData model, final
ConnectorManagerRepository cmr) {
- if (model.isSource()) {
- List<SourceMappingMetadata> mappings = model.getSourceMappings();
- for (SourceMappingMetadata mapping:mappings) {
- return cmr.getConnectorManager(mapping.getName());
- }
- }
- return null;
- }
-
// if is not dynamic always cache; else check for the flag (this may need to be
revisited with index vdb)
private void cacheMetadataStore(final ModelMetaData model, MetadataFactory schema) {
boolean cache = !vdb.isDynamic();
@@ -447,7 +418,7 @@
}
}
- private VDBRepository getVDBRepository() {
+ protected VDBRepository getVDBRepository() {
return vdbRepositoryInjector.getValue();
}
@@ -467,14 +438,46 @@
return bufferManagerInjector.getValue();
}
- private void save() throws AdminProcessingException {
+ private void save() throws AdminProcessingException{
try {
ObjectSerializer os = getSerializer();
VDBMetadataParser.marshell(this.vdb, os.getVdbXmlOutputStream(this.vdb));
} catch (IOException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50064, e);
+ throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50048, e);
} catch (XMLStreamException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50065, e);
+ throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50049, e);
}
}
+
+ /**
+ * Override for module based loading
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected MetadataRepository<?, ?> getMetadataRepository(String repoType) throws
VirtualDatabaseException {
+ MetadataRepository<?, ?> repo = super.getMetadataRepository(repoType);
+ if (repo != null) {
+ return repo;
+ }
+ final Module module;
+ ClassLoader moduleLoader = this.getClass().getClassLoader();
+ ModuleLoader ml = Module.getCallerModuleLoader();
+ if (repoType != null && ml != null) {
+ try {
+ module = ml.loadModule(ModuleIdentifier.create(repoType));
+ moduleLoader = module.getClassLoader();
+ } catch (ModuleLoadException e) {
+ throw new
VirtualDatabaseException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50057,
repoType));
+ }
+ }
+
+ final ServiceLoader<MetadataRepository> serviceLoader =
ServiceLoader.load(MetadataRepository.class, moduleLoader);
+ if (serviceLoader != null) {
+ for (MetadataRepository loader:serviceLoader) {
+ return loader;
+ }
+ }
+ return null;
+ }
+
}
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-18
16:09:18 UTC (rev 4184)
@@ -51,9 +51,7 @@
TEIID50023=replication failed {0}
TEIID50024=Failed to load metadata for VDB {0}.{1}
TEIID50044=Failed to save metadata for VDB {0}.{1} for model {2}
-TEIID50086=No metadata defined for model {0} for VDB {1}.{2}
TEIID50025=VDB "{0}" deployed in {1} state.
-TEIID50087=Model {0} specified with no source information in VDB {1}.{2}
TEIID50026=VDB "{0}" undeployed.
TEIID50029=VDB {0}.{1} model "{2}" metadata is currently being loaded. Start
Time: {3}
TEIID50030=VDB {0}.{1} model "{2}" metadata loaded. End Time: {3}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java
===================================================================
---
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java 2012-06-18
14:37:59 UTC (rev 4183)
+++
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataStore.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -240,27 +240,7 @@
if (!this.loaded) {
if (systemDatatypes == null) {
- InputStream is =
this.getClass().getClassLoader().getResourceAsStream("org/teiid/metadata/types.dat");
//$NON-NLS-1$
- try {
- InputStreamReader isr = new InputStreamReader(is,
Charset.forName("UTF-8")); //$NON-NLS-1$
- BufferedReader br = new BufferedReader(isr);
- String s = br.readLine();
- String[] props = s.split("\\|"); //$NON-NLS-1$
- while ((s = br.readLine()) != null) {
- Datatype dt = new Datatype();
- String[] vals = s.split("\\|"); //$NON-NLS-1$
- Properties p = new Properties();
- for (int i = 0; i < props.length; i++) {
- if (vals[i].length() != 0) {
- p.setProperty(props[i], new String(vals[i]));
- }
- }
- PropertiesUtils.setBeanProperties(dt, p, null);
- addDatatype(dt);
- }
- } finally {
- is.close();
- }
+ loadSystemDatatypes(this);
}
ArrayList<Index> tmp = new ArrayList<Index>();
for (VirtualFile f : indexFiles) {
@@ -299,6 +279,30 @@
}
}
+ public static void loadSystemDatatypes(MetadataStore ms) throws IOException {
+ InputStream is =
IndexMetadataStore.class.getClassLoader().getResourceAsStream("org/teiid/metadata/types.dat");
//$NON-NLS-1$
+ try {
+ InputStreamReader isr = new InputStreamReader(is, Charset.forName("UTF-8"));
//$NON-NLS-1$
+ BufferedReader br = new BufferedReader(isr);
+ String s = br.readLine();
+ String[] props = s.split("\\|"); //$NON-NLS-1$
+ while ((s = br.readLine()) != null) {
+ Datatype dt = new Datatype();
+ String[] vals = s.split("\\|"); //$NON-NLS-1$
+ Properties p = new Properties();
+ for (int i = 0; i < props.length; i++) {
+ if (vals[i].length() != 0) {
+ p.setProperty(props[i], new String(vals[i]));
+ }
+ }
+ PropertiesUtils.setBeanProperties(dt, p, null);
+ ms.addDatatype(dt);
+ }
+ } finally {
+ is.close();
+ }
+ }
+
public void addIndexFile(VirtualFile f) {
this.indexFiles.add(f);
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -78,7 +78,7 @@
Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
if (udf != null) {
for (Map.Entry<String, Collection<FunctionMethod>> entry :
udf.getFunctions().entrySet()) {
- udfs.add(new FunctionTree(entry.getKey(), new UDFSource(entry.getValue()), true));
+ udfs.add(new FunctionTree(entry.getKey(), new UDFSource(entry.getValue()), true,
udf.getClassLoader()));
}
}
@@ -87,7 +87,7 @@
compositeStore.merge(s);
for (Schema schema:s.getSchemas().values()) {
if (!schema.getFunctions().isEmpty()) {
- udfs.add(new FunctionTree(schema.getName(), new
UDFSource(schema.getFunctions().values()), true));
+ udfs.add(new FunctionTree(schema.getName(), new
UDFSource(schema.getFunctions().values()), true, udf.getClassLoader()));
}
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -43,6 +43,7 @@
public class UDFMetaData {
private HashMap<String, Collection <FunctionMethod>> methods = new
HashMap<String, Collection<FunctionMethod>>();
private HashMap<String, VirtualFile> files = new HashMap<String,
VirtualFile>();
+ private ClassLoader classLoader;
public void addModelFile(VirtualFile file) {
this.files.put(file.getPathName(), file);
@@ -92,11 +93,10 @@
}
public void setFunctionClassLoader(ClassLoader functionClassLoader) {
- for (String name : this.methods.keySet()) {
- Collection <FunctionMethod> funcs = this.methods.get(name);
- for(FunctionMethod fm:funcs) {
- fm.setClassloader(functionClassLoader);
- }
- }
- }
+ this.classLoader = functionClassLoader;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -284,7 +284,7 @@
valid = true;
}
else {
- LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version));
+ LogManager.logWarning(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version));
}
// check the data sources available
@@ -314,7 +314,7 @@
if (cm != null) {
String msg = cm.getStausMessage();
if (msg != null && msg.length() > 0) {
- model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(),
cm.getStausMessage());
+ model.addRuntimeError(cm.getStausMessage());
LogManager.logInfo(LogConstants.CTX_RUNTIME, cm.getStausMessage());
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -86,7 +86,7 @@
if (!cm.getConnectionName().equals(dsName)){
markInvalid(vdb);
String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40076, vdb.getName(),
vdb.getVersion(), model.getSourceTranslatorName(sourceName), dsName);
- model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ model.addRuntimeError(msg);
cm = new ConnectorManager(translatorName, dsName);
cm.setExecutionFactory(ef);
cmr.addConnectorManager(sourceName, cm);
@@ -137,7 +137,7 @@
ConnectorManagerRepository cmr =
vdb.getAttachment(ConnectorManagerRepository.class);
for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
- if (model.getRuntimeErrors().isEmpty()) {
+ if (!model.hasRuntimeErrors()) {
continue;
}
@@ -149,7 +149,7 @@
ConnectorManager cm = cmr.getConnectorManager(sourceName);
String status = cm.getStausMessage();
if (status != null && status.length() > 0) {
- model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(),
status);
+ model.addRuntimeError(status);
LogManager.logInfo(LogConstants.CTX_RUNTIME, status);
} else {
//get the pending metadata load
@@ -164,7 +164,7 @@
boolean valid = true;
for (ModelMetaData model:vdb.getModelMetaDatas().values()) {
- if (!model.getRuntimeErrors().isEmpty()) {
+ if (model.hasRuntimeErrors()) {
valid = false;
break;
}
@@ -203,7 +203,7 @@
else {
msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(),
vdb.getVersion(), resourceName);
}
- model.addRuntimeError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ model.addRuntimeError(msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion(),
vdb.getStatus()));
}
Added: trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.runtime;
+
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Model.Type;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SourceMappingMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VirtualDatabaseException;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataRepository;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.query.metadata.DDLMetadataRepository;
+import org.teiid.query.metadata.NativeMetadataRepository;
+import org.teiid.translator.TranslatorException;
+
+public abstract class AbstractVDBDeployer {
+
+ private Map<String, MetadataRepository<?, ?>> repositories = new
ConcurrentSkipListMap<String, MetadataRepository<?,
?>>(String.CASE_INSENSITIVE_ORDER);
+
+ public AbstractVDBDeployer() {
+ repositories.put("ddl", new DDLMetadataRepository()); //$NON-NLS-1$
+ repositories.put("native", new NativeMetadataRepository()); //$NON-NLS-1$
+ }
+
+ public void addMetadataRepository(String name, MetadataRepository<?, ?>
metadataRepository) {
+ this.repositories.put(name, metadataRepository);
+ }
+
+ protected void assignMetadataRepositories(VDBMetaData deployment,
MetadataRepository<?, ?> defaultRepo) throws VirtualDatabaseException {
+ for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
+ if (model.isSource() && model.getSourceNames().isEmpty()) {
+ throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40093,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40093, model.getName(),
deployment.getName(), deployment.getVersion()));
+ }
+ if (model.getModelType() == Type.FUNCTION || model.getModelType() == Type.OTHER) {
+ continue;
+ }
+ MetadataRepository<?, ?> repo = getMetadataRepository(deployment, model,
defaultRepo);
+ model.addAttchment(MetadataRepository.class, repo);
+ }
+ }
+
+ private MetadataRepository<?, ?> getMetadataRepository(VDBMetaData vdb,
ModelMetaData model, MetadataRepository<?, ?> defaultRepo) throws
VirtualDatabaseException {
+ if (model.getSchemaSourceType() == null) {
+ if (!vdb.isDynamic()) {
+ return defaultRepo;
+ }
+
+ if (model.isSource()) {
+ return new NativeMetadataRepository();
+ }
+ throw new
VirtualDatabaseException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40094,
model.getName(), vdb.getName(), vdb.getVersion(), null));
+ }
+
+ MetadataRepository<?, ?> first = null;
+ MetadataRepository<?, ?> current = null;
+ MetadataRepository<?, ?> previous = null;
+ StringTokenizer st = new StringTokenizer(model.getSchemaSourceType(), ",");
//$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String repoType = st.nextToken().trim();
+ current = getMetadataRepository(repoType);
+ if (current == null) {
+ throw new
VirtualDatabaseException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40094,
model.getName(), vdb.getName(), vdb.getVersion(), repoType));
+ }
+
+ if (first == null) {
+ first = current;
+ }
+
+ if (previous != null) {
+ previous.setNext(current);
+ }
+ previous = current;
+ current = null;
+ }
+ return first;
+ }
+
+ protected ConnectorManager getConnectorManager(final ModelMetaData model, final
ConnectorManagerRepository cmr) {
+ if (model.isSource()) {
+ List<SourceMappingMetadata> mappings = model.getSourceMappings();
+ for (SourceMappingMetadata mapping:mappings) {
+ return cmr.getConnectorManager(mapping.getName());
+ }
+ }
+ return null;
+ }
+
+ protected void loadMetadata(VDBMetaData vdb, ConnectorManagerRepository cmr,
+ MetadataStore store) throws TranslatorException {
+ // load metadata from the models
+ AtomicInteger loadCount = new AtomicInteger();
+ for (ModelMetaData model: vdb.getModelMetaDatas().values()) {
+ if (model.getModelType() == Model.Type.PHYSICAL || model.getModelType() ==
Model.Type.VIRTUAL) {
+ loadCount.incrementAndGet();
+ }
+ }
+ for (ModelMetaData model: vdb.getModelMetaDatas().values()) {
+ MetadataRepository metadataRepository =
model.getAttachment(MetadataRepository.class);
+ if (model.getModelType() == Model.Type.PHYSICAL || model.getModelType() ==
Model.Type.VIRTUAL) {
+ loadMetadata(vdb, model, cmr, metadataRepository, store, loadCount);
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " was being loaded from its repository");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ 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());
+ }
+ }
+ }
+ }
+
+ protected abstract VDBRepository getVDBRepository();
+
+ protected abstract void loadMetadata(VDBMetaData vdb, ModelMetaData model,
+ ConnectorManagerRepository cmr,
+ MetadataRepository metadataRepository, MetadataStore store,
+ AtomicInteger loadCount) throws TranslatorException;
+
+ protected void metadataLoaded(final VDBMetaData vdb,
+ final ModelMetaData model,
+ final MetadataStore vdbMetadataStore,
+ final AtomicInteger loadCount, MetadataFactory factory) {
+ // merge into VDB metadata
+ factory.mergeInto(vdbMetadataStore);
+
+ //TODO: this is not quite correct, the source may be missing
+ model.clearRuntimeErrors();
+
+ if (loadCount.decrementAndGet() == 0) {
+ getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
+ }
+ }
+
+ /**
+ * @throws VirtualDatabaseException
+ */
+ protected MetadataRepository<?, ?> getMetadataRepository(String repoType) throws
VirtualDatabaseException {
+ return repositories.get(repoType);
+ }
+}
Property changes on:
trunk/runtime/src/main/java/org/teiid/runtime/AbstractVDBDeployer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java 2012-06-18
14:37:59 UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -42,6 +42,7 @@
private MetadataStore systemStore;
private ObjectReplicator objectReplicator;
private WorkManager workManager;
+ private boolean useDisk = true;
public SecurityHelper getSecurityHelper() {
return securityHelper;
@@ -98,6 +99,17 @@
if (workManager == null) {
return super.getTeiidExecutor();
}
+ //TODO: if concurrency is 1, then use a direct executor
+ //the only scheduled task right now just restarts a workitem,
+ //so that can be done in the scheduler thread
return new WorkManagerTeiidExecutor(workManager);
}
+
+ public boolean isUseDisk() {
+ return useDisk;
+ }
+
+ public void setUseDisk(boolean useDisk) {
+ this.useDisk = useDisk;
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -22,6 +22,7 @@
package org.teiid.runtime;
+import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -29,9 +30,15 @@
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.teiid.Replicated;
@@ -55,12 +62,15 @@
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException;
+import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ExecutionFactoryProvider;
import org.teiid.dqp.internal.process.CachedResults;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.PreparedPlan;
import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.dqp.internal.process.TransactionServerImpl;
import org.teiid.dqp.service.BufferService;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.events.EventDistributor;
import org.teiid.events.EventDistributorFactory;
import org.teiid.jdbc.ConnectionImpl;
@@ -69,7 +79,11 @@
import org.teiid.jdbc.TeiidSQLException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataRepository;
import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.index.IndexMetadataStore;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.query.ObjectReplicator;
@@ -95,8 +109,47 @@
* Needs to be started prior to use with a call to {@link #start(EmbeddedConfiguration)}
*/
@SuppressWarnings("serial")
-public class EmbeddedServer implements EventDistributorFactory {
+public class EmbeddedServer extends AbstractVDBDeployer implements
EventDistributorFactory, ExecutionFactoryProvider {
+ protected final class TransactionDetectingTransactionServer extends
+ TransactionServerImpl {
+
+ /**
+ * Override to detect existing thread bound transactions.
+ * This may be of interest for local connections as well, but
+ * we assume there that a managed datasource will be used.
+ * A managed datasource is not possible here.
+ */
+ public TransactionContext getOrCreateTransactionContext(final String threadId) {
+ TransactionContext tc = super.getOrCreateTransactionContext(threadId);
+ if (useCallingThread && detectTransactions && tc.getTransaction() ==
null) {
+ try {
+ Transaction tx = transactionManager.getTransaction();
+ if (tx != null) {
+ tx.registerSynchronization(new Synchronization() {
+
+ @Override
+ public void beforeCompletion() {
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ transactions.removeTransactionContext(threadId);
+ }
+ });
+ tc.setTransaction(tx);
+ tc.setTransactionType(Scope.LOCAL);
+ }
+ } catch (SystemException e) {
+ } catch (IllegalStateException e) {
+ } catch (RollbackException e) {
+ }
+ }
+
+ return tc;
+ }
+ }
+
protected class ProviderAwareConnectorManagerRepository extends
ConnectorManagerRepository {
protected ConnectorManager createConnectorManager(
@@ -143,7 +196,7 @@
protected SessionServiceImpl sessionService = new SessionServiceImpl();
protected ObjectReplicator replicator;
protected BufferServiceImpl bufferService = new BufferServiceImpl();
- protected TransactionServerImpl transactionService = new TransactionServerImpl();
+ protected TransactionDetectingTransactionServer transactionService = new
TransactionDetectingTransactionServer();
protected ClientServiceRegistryImpl services = new ClientServiceRegistryImpl();
protected LogonImpl logon;
private TeiidDriver driver = new TeiidDriver();
@@ -197,6 +250,9 @@
}
};
protected boolean useCallingThread = true;
+ //TODO: allow for configurablity - in environments that support subtransations it would
be fine
+ //to allow teiid to start a request transaction under an existing thread bound
transaction
+ protected boolean detectTransactions = true;
private Boolean running;
public EmbeddedServer() {
@@ -215,7 +271,17 @@
this.eventDistributorFactoryService.start();
this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
this.replicator = dqpConfiguration.getObjectReplicator();
- this.repo.setSystemStore(dqpConfiguration.getSystemStore());
+ if (dqpConfiguration.getSystemStore() == null) {
+ MetadataStore ms = new MetadataStore();
+ try {
+ IndexMetadataStore.loadSystemDatatypes(ms);
+ } catch (IOException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ this.repo.setSystemStore(ms);
+ } else {
+ this.repo.setSystemStore(dqpConfiguration.getSystemStore());
+ }
if (dqpConfiguration.getTransactionManager() == null) {
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
this.transactionService.setTransactionManager((TransactionManager)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new
Class<?>[] {TransactionManager.class}, new InvocationHandler() {
@@ -226,6 +292,7 @@
throw new
UnsupportedOperationException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
}
}));
+ this.detectTransactions = false;
} else {
this.transactionService.setTransactionManager(dqpConfiguration.getTransactionManager());
}
@@ -241,7 +308,7 @@
}
this.sessionService.setVDBRepository(repo);
-
+ this.bufferService.setUseDisk(dqpConfiguration.isUseDisk());
BufferService bs = getBufferService();
this.dqp.setBufferManager(bs.getBufferManager());
@@ -349,42 +416,75 @@
return bufferService;
}
+ /**
+ * Add an {@link ExecutionFactory}. The {@link ExecutionFactory#start()} method
+ * should have already been called.
+ * @param ef
+ */
public void addTranslator(ExecutionFactory<?, ?> ef) {
Translator t = ef.getClass().getAnnotation(Translator.class);
String name = ef.getClass().getName();
if (t != null) {
name = t.name();
}
+ addTranslator(name, ef);
+ }
+
+ void addTranslator(String name, ExecutionFactory<?, ?> ef) {
translators.put(name, ef);
}
+ /**
+ * Deploy the given set of models as vdb name.1
+ * @param name
+ * @param models
+ * @throws ConnectorManagerException
+ * @throws VirtualDatabaseException
+ * @throws TranslatorException
+ */
public void deployVDB(String name, List<ModelMetaData> models)
- throws ConnectorManagerException, VirtualDatabaseException {
+ throws ConnectorManagerException, VirtualDatabaseException, TranslatorException {
checkStarted();
VDBMetaData vdb = new VDBMetaData();
+ vdb.setDynamic(true);
vdb.setName(name);
vdb.setModels(models);
- cmr.createConnectorManagers(vdb,
- new ConnectorManagerRepository.ExecutionFactoryProvider() {
-
- @SuppressWarnings("unchecked")
- @Override
- public ExecutionFactory<Object, Object> getExecutionFactory(
- String translator) throws ConnectorManagerException {
- ExecutionFactory<?, ?> ef = translators.get(translator);
- if (ef == null) {
- throw new ConnectorManagerException(translator);
- }
- return (ExecutionFactory<Object, Object>) ef;
- }
- });
+ cmr.createConnectorManagers(vdb, this);
MetadataStore metadataStore = new MetadataStore();
- repo.addVDB(vdb, metadataStore, new LinkedHashMap<String, Resource>(),
- new UDFMetaData(), cmr);
- // metadata load
-
+ UDFMetaData udfMetaData = new UDFMetaData();
+ udfMetaData.setFunctionClassLoader(Thread.currentThread().getContextClassLoader());
+ this.assignMetadataRepositories(vdb, null);
+ repo.addVDB(vdb, metadataStore, new LinkedHashMap<String, Resource>(),
udfMetaData, cmr);
+ this.loadMetadata(vdb, cmr, metadataStore);
}
-
+
+ /**
+ * TODO: consolidate this logic more into the abstract deployer
+ */
+ @Override
+ protected void loadMetadata(VDBMetaData vdb, ModelMetaData model,
+ ConnectorManagerRepository cmr,
+ MetadataRepository metadataRepository, MetadataStore store,
+ AtomicInteger loadCount) throws TranslatorException {
+ Map<String, Datatype> datatypes = this.repo.getBuiltinDatatypes();
+ MetadataFactory factory = new MetadataFactory(vdb.getName(), vdb.getVersion(),
model.getName(), datatypes, model.getProperties(), model.getSchemaText());
+ factory.getSchema().setPhysical(model.isSource());
+
+ ExecutionFactory ef = null;
+ Object cf = null;
+
+ try {
+ ConnectorManager cm = getConnectorManager(model, cmr);
+ ef = ((cm == null)?null:cm.getExecutionFactory());
+ cf = ((cm == null)?null:cm.getConnectionFactory());
+ } catch (TranslatorException e1) {
+ //ignore data source not availability, it may not be required.
+ }
+
+ metadataRepository.loadMetadata(factory, ef, cf);
+ metadataLoaded(vdb, model, store, loadCount, factory);
+ }
+
public void undeployVDB(String vdbName) {
this.repo.removeVDB(vdbName, 1);
}
@@ -416,4 +516,21 @@
return this.eventDistributorFactoryService.getEventDistributor();
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public ExecutionFactory<Object, Object> getExecutionFactory(String name)
+ throws ConnectorManagerException {
+ ExecutionFactory<?, ?> ef = translators.get(name);
+ if (ef == null) {
+ //TODO: consolidate this exception into the connectormanagerrepository
+ throw new ConnectorManagerException(name);
+ }
+ return (ExecutionFactory<Object, Object>) ef;
+ }
+
+ @Override
+ protected VDBRepository getVDBRepository() {
+ return this.repo;
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-18 16:09:18
UTC (rev 4184)
@@ -104,6 +104,9 @@
TEIID40089, //txn disabled
TEIID40090,
TEIID40091,
- TEIID40092
+ TEIID40092,
+ TEIID40093, //no sources
+ TEIID40094, //invalid metadata repso
+
}
}
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-18 14:37:59
UTC (rev 4183)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-18 16:09:18
UTC (rev 4184)
@@ -95,3 +95,5 @@
TEIID40090=Model name "{0}" not found in the VDB with name "{1}"
version "{2}"
TEIID40091=Source name "{0}" not found for model {1} in the VDB with name
"{2}" version "{3}"
TEIID40092=Policy {0} not found in VDB {1}.{2}
+TEIID40093=Model {0} specified with no source information in VDB {1}.{2}
+TEIID40094=No metadata repository of type {3} defined for model {0} for VDB {1}.{2}
Added: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
(rev 0)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.runtime;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.runtime.EmbeddedServer.ConnectionFactoryProvider;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+@SuppressWarnings("nls")
+public class TestEmbeddedServer {
+ EmbeddedServer es;
+
+ @Before public void setup() {
+ es = new EmbeddedServer();
+ }
+
+ @After public void teardown() {
+ es.stop();
+ }
+
+ @Test public void testDeploy() throws Exception {
+ EmbeddedConfiguration ec = new EmbeddedConfiguration();
+ ec.setUseDisk(false);
+ es.start(ec);
+
+ es.addTranslator("y", new ExecutionFactory<AtomicInteger, Object> () {
+ @Override
+ public Object getConnection(AtomicInteger factory)
+ throws TranslatorException {
+ return factory.incrementAndGet();
+ }
+
+ @Override
+ public void closeConnection(Object connection, AtomicInteger factory) {
+
+ }
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, Object conn)
+ throws TranslatorException {
+ assertEquals(conn, Integer.valueOf(1));
+ Table t = metadataFactory.addTable("my-table");
+ metadataFactory.addColumn("my-column", TypeFacility.RUNTIME_NAMES.STRING,
t);
+ }
+
+ @Override
+ public ResultSetExecution createResultSetExecution(
+ QueryExpression command, ExecutionContext executionContext,
+ RuntimeMetadata metadata, Object connection)
+ throws TranslatorException {
+ ResultSetExecution rse = new ResultSetExecution() {
+
+ @Override
+ public void execute() throws TranslatorException {
+
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return null;
+ }
+ };
+ return rse;
+ }
+ });
+ final AtomicInteger counter = new AtomicInteger();
+ ConnectionFactoryProvider<AtomicInteger> cfp = new
ConnectionFactoryProvider<AtomicInteger>() {
+ @Override
+ public AtomicInteger getConnectionFactory()
+ throws TranslatorException {
+ return counter;
+ }
+ };
+
+ es.addConnectionFactoryProvider("z", cfp);
+
+ ModelMetaData mmd = new ModelMetaData();
+ mmd.setName("my-schema");
+ mmd.addSourceMapping("x", "y", "z");
+
+ es.deployVDB("test", Arrays.asList(mmd));
+
+ TeiidDriver td = es.getDriver();
+ Connection c = td.connect("jdbc:teiid:test", null);
+ Statement s = c.createStatement();
+ ResultSet rs = s.executeQuery("select * from \"my-table\"");
+ assertFalse(rs.next());
+ assertEquals("my-column", rs.getMetaData().getColumnLabel(1));
+ }
+
+}
Property changes on:
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-06-18
14:37:59 UTC (rev 4183)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2012-06-18
16:09:18 UTC (rev 4184)
@@ -105,6 +105,7 @@
config.setTransactionManager(SimpleMock.createSimpleMock(TransactionManager.class));
this.transactionService.setXaTerminator(SimpleMock.createSimpleMock(XATerminator.class));
this.transactionService.setWorkManager(new FakeWorkManager());
+ detectTransactions = false;
}
this.repo.odbcEnabled();
this.realBufferManager = realBufferMangaer;
Added: trunk/test-integration/common/src/test/resources/reuse-vdb.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/reuse-vdb.xml
(rev 0)
+++ trunk/test-integration/common/src/test/resources/reuse-vdb.xml 2012-06-18 16:09:18 UTC
(rev 4184)
@@ -0,0 +1,13 @@
+<vdb name="reuse" version= "1">
+ <import-vdb name="dynamic" version="1"/>
+ <model visible = "true" type = "VIRTUAL" name =
"portfolio1">
+ <metadata type = "DDL"><![CDATA[
+ CREATE VIEW stock1 (
+ symbol varchar,
+ price decimal
+ ) AS
+ select * from stock;
+ ]]>
+ </metadata>
+ </model>
+</vdb>
\ No newline at end of file
Property changes on: trunk/test-integration/common/src/test/resources/reuse-vdb.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain