Author: shawkins
Date: 2009-10-24 22:04:53 -0400 (Sat, 24 Oct 2009)
New Revision: 1539
Added:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
Removed:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/DefaultIndexConnectorBinding.java
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedVDBService.java
Log:
TEIID-871 TEIID-792 TEIID-102 TEIID-254 TEIID-869 TEIID-875 further clean up of metadata
related logic. The index connector has been removed and the system virtual views promoted
to physical tables. some of the tables/procedures have been removed. and minor changes
have been made to MMDatabaseMetadata queries.
Deleted:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/DefaultIndexConnectorBinding.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/DefaultIndexConnectorBinding.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/DefaultIndexConnectorBinding.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -1,242 +0,0 @@
-/*
- * 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 com.metamatrix.dqp.embedded.services;
-
-import java.util.Date;
-import java.util.Properties;
-
-import org.teiid.connector.api.ConnectorPropertyNames;
-
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.model.ConfigurationVisitor;
-import com.metamatrix.common.namedobject.BaseID;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-
-/**
- * This is default class which will used by the VDBs as ConnectorBinding for the
- * CoreConstants.SYSTEM_PHYSICAL_MODEL_NAME. This is same connector in all the
- * VDBs, however this is not included in the VDB.
- *
- * @since 4.3
- */
-class DefaultIndexConnectorBinding implements ConnectorBinding {
-
- private static final String INDEX_CONNECTOR_NAME = "Index_Connector";
//$NON-NLS-1$
- private static final String INDEX_CONNECTOR_CLASS_NAME =
"com.metamatrix.connector.metadata.IndexConnector"; //$NON-NLS-1$
- private static final String INDEX_CONNECTOR_MAX_ROWS = "0"; //$NON-NLS-1$
-
- private Properties props = new Properties();
- private Date creationTime = new Date(System.currentTimeMillis());
-
- /**
- * ctor
- * @since 4.3
- */
- public DefaultIndexConnectorBinding() {
- this.props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS,
INDEX_CONNECTOR_CLASS_NAME );
- this.props.setProperty(ConnectorPropertyNames.MAX_RESULT_ROWS,
INDEX_CONNECTOR_MAX_ROWS );
- }
-
- /**
- * @see com.metamatrix.common.config.api.ConnectorBinding#getDeployedName()
- */
- public String getDeployedName() {
- return INDEX_CONNECTOR_NAME;
- }
-
-
- /**
- * @see
com.metamatrix.common.config.api.ServiceComponentDefn#accept(com.metamatrix.common.config.model.ConfigurationVisitor)
- * @since 4.3
- */
- public void accept(ConfigurationVisitor visitor) {
- // no configuratio needed
- }
-
- /**
- * @see com.metamatrix.common.config.api.ServiceComponentDefn#getRoutingUUID()
- * @since 4.3
- */
- public String getRoutingUUID() {
- return INDEX_CONNECTOR_NAME;
- }
-
-
- /**
- * @since 6.1
- */
- public boolean isXASupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentDefn#getConfigurationID()
- * @since 4.3
- */
- public ConfigurationID getConfigurationID() {
- return null;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentDefn#isEnabled()
- * @since 4.3
- */
- public boolean isEnabled() {
- return true;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getName()
- * @since 4.3
- */
- public String getName() {
- return INDEX_CONNECTOR_NAME;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getProperties()
- * @since 4.3
- */
- public Properties getProperties() {
- return props;
- }
-
- /**
- * @see
com.metamatrix.common.config.api.ComponentObject#getProperty(java.lang.String)
- * @since 4.3
- */
- public String getProperty(String name) {
- return props.getProperty(name);
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getComponentTypeID()
- * @since 4.3
- */
- public ComponentTypeID getComponentTypeID() {
- return new ComponentTypeID(INDEX_CONNECTOR_NAME);
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getDescription()
- * @since 4.3
- */
- public String getDescription() {
- return INDEX_CONNECTOR_NAME;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getCreatedBy()
- * @since 4.3
- */
- public String getCreatedBy() {
- return "system.runtime"; //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getCreatedDate()
- * @since 4.3
- */
- public Date getCreatedDate() {
- return creationTime;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getLastChangedBy()
- * @since 4.3
- */
- public String getLastChangedBy() {
- return "none"; //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentObject#getLastChangedDate()
- * @since 4.3
- */
- public Date getLastChangedDate() {
- return creationTime;
- }
-
- /**
- * @see
com.metamatrix.common.config.api.ComponentObject#isDependentUpon(com.metamatrix.common.namedobject.BaseID)
- * @since 4.3
- */
- public boolean isDependentUpon(BaseID componentObjectId) {
- return false;
- }
-
- /**
- * @see com.metamatrix.common.namedobject.BaseObject#getID()
- * @since 4.3
- */
- public BaseID getID() {
- return null;
- }
-
- /**
- * @see com.metamatrix.common.namedobject.BaseObject#getFullName()
- * @since 4.3
- */
- public String getFullName() {
- return INDEX_CONNECTOR_NAME;
- }
-
- /**
- * @see com.metamatrix.common.namedobject.BaseObject#compareTo(java.lang.Object)
- * @since 4.3
- */
- public int compareTo(Object obj) {
- return 0;
- }
- /**
- * Return a deep cloned instance of this object. Subclasses must override
- * this method.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- /**
- * @see com.metamatrix.common.config.api.ConnectorBinding#getConnectorClass()
- * @since 4.3
- */
- public String getConnectorClass() {
- return INDEX_CONNECTOR_CLASS_NAME;
- }
-
- /**
- * @see com.metamatrix.common.config.api.ComponentDefn#isEssential()
- */
- public boolean isEssential() {
- return false;
- }
-}
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -32,7 +32,6 @@
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.core.CoreConstants;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
@@ -44,8 +43,6 @@
* @since 4.3
*/
public abstract class EmbeddedBaseDQPService implements ApplicationService {
- public static final String SYSTEM_PHYSICAL_MODEL_NAME =
CoreConstants.SYSTEM_PHYSICAL_MODEL_NAME;
-
private boolean started = false;
private boolean initialized = false;
private ApplicationEnvironment environment;
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -34,7 +34,7 @@
import org.teiid.adminapi.ConnectionPool;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorPropertyNames;
-import org.teiid.connector.metadata.runtime.ConnectorMetadata;
+import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -129,7 +129,7 @@
}
@Override
- public ConnectorMetadata getConnectorMetadata(String vdbName,
+ public MetadataStore getConnectorMetadata(String vdbName,
String vdbVersion, String modelName, Properties importProperties) throws
MetaMatrixComponentException {
VDBService vdbService =
(VDBService)this.lookupService(DQPServiceNames.VDB_SERVICE);
List<String> bindingNames = vdbService.getConnectorBindingNames(vdbName,
vdbVersion, modelName);
@@ -363,9 +363,6 @@
getConfigurationService().register(this.listener);
try {
- // Start System Model connector Binding
- startConnectorBinding(SYSTEM_PHYSICAL_MODEL_NAME);
-
// Loop through the available ACTIVE VDBS and only start those
// connector bindings that are ACTIVE VDBS.
List otherBindings = new ArrayList();
@@ -462,13 +459,8 @@
ConnectorBinding binding =
(ConnectorBinding)loadedConnectorBindingsMap.get(deployedConnectorBindingName);
if (binding == null) {
- if (SYSTEM_PHYSICAL_MODEL_NAME.equals(deployedConnectorBindingName)) {
- binding = getSystemModelBinding();
- }
- else {
- // if connector binding not found load from the configuration service.
- binding =
getConfigurationService().getConnectorBinding(deployedConnectorBindingName);
- }
+ // if connector binding not found load from the configuration service.
+ binding =
getConfigurationService().getConnectorBinding(deployedConnectorBindingName);
}
return binding;
}
@@ -569,13 +561,4 @@
return value;
}
- /**
- * Create a Connector Binding for the System Model.
- * @return
- * @since 4.3
- */
- ConnectorBinding getSystemModelBinding() {
- return new DefaultIndexConnectorBinding();
- }
-
}
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -26,20 +26,19 @@
import java.util.Properties;
import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.metadata.QueryMetadataCache;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.connector.metadata.internal.IObjectSource;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.MetadataService;
import com.metamatrix.dqp.service.VDBLifeCycleListener;
import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
@@ -90,7 +89,7 @@
* @see com.metamatrix.dqp.service.MetadataService#lookupMetadata(java.lang.String,
java.lang.String)
* @since 4.3
*/
- public QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion)
+ public TransformationMetadata lookupMetadata(String vdbName, String vdbVersion)
throws MetaMatrixComponentException {
VDBService vdbService = ((VDBService)lookupService(DQPServiceNames.VDB_SERVICE));
DataService dataService =
((DataService)lookupService(DQPServiceNames.DATA_SERVICE));
@@ -98,9 +97,8 @@
}
- public IObjectSource getMetadataObjectSource(String vdbName, String vdbVersion) throws
MetaMatrixComponentException {
- VDBService vdbService = (VDBService)lookupService(DQPServiceNames.VDB_SERVICE);
- return this.metadataCache.getCompositeMetadataObjectSource(vdbName, vdbVersion,
vdbService);
+ public CompositeMetadataStore getMetadataObjectSource(String vdbName, String vdbVersion)
throws MetaMatrixComponentException {
+ return lookupMetadata(vdbName, vdbVersion).getMetadataStore();
}
@Override
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -79,10 +79,6 @@
return vdb;
}
- private boolean isSystemModel(String modelName) {
- return modelName.equalsIgnoreCase(SYSTEM_PHYSICAL_MODEL_NAME);
- }
-
private ModelInfo getModel(VDBDefn vdb, String modelName) {
Collection c = vdb.getModels();
Iterator it = c.iterator();
@@ -103,13 +99,6 @@
public List getConnectorBindingNames(String vdbName, String vdbVersion, String
modelName)
throws MetaMatrixComponentException {
- // If the request for System model, we have a single name always
- if (isSystemModel(modelName)) {
- List list = new ArrayList();
- list.add(SYSTEM_PHYSICAL_MODEL_NAME);
- return list;
- }
-
// Otherwise get these from the database.
VDBArchive vdb = getVDB(vdbName, vdbVersion);
BasicVDBDefn def = vdb.getConfigurationDef();
@@ -143,11 +132,6 @@
public int getModelVisibility(String vdbName, String vdbVersion, String modelName)
throws MetaMatrixComponentException {
- // If this is system Model
- if (isSystemModel(modelName)) {
- return ModelInfo.PRIVATE;
- }
-
// If this is any of the Public System Models, like JDBC,ODBC system models
if(SystemVdbUtility.isSystemModelWithSystemTableType(modelName)){
return ModelInfo.PUBLIC;
@@ -174,11 +158,6 @@
String modelName = StringUtil.getFirstToken(StringUtil.getLastToken(pathInVDB,
"/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
- // If this is system Model
- if (isSystemModel(modelName)) {
- return ModelInfo.PRIVATE;
- }
-
// If this is any of the Public System Models, like JDBC,ODBC system models
if(SystemVdbUtility.isSystemModelWithSystemTableType(modelName)){
return ModelInfo.PUBLIC;
Copied:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
(from rev 1529, trunk/metadata/src/main/java/org/teiid/metadata/QueryMetadataCache.java)
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
(rev 0)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -0,0 +1,225 @@
+/*
+ * 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 com.metamatrix.dqp.embedded.services;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.index.IndexMetadataFactory;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.vdb.runtime.VDBKey;
+
+
+/**
+ * This caches QueryMetadataInterface implementations for all vdbs, each implementation
has access to
+ * metadata for a given vdb and the system vdb.
+ * @since 4.2
+ */
+public class QueryMetadataCache {
+
+ private static class QueryMetadataHolder {
+ TransformationMetadata qmi;
+ }
+
+ // vdbID to QueryMetadataInterfaceHolder map
+ private Map<VDBKey, QueryMetadataHolder> vdbToQueryMetadata =
Collections.synchronizedMap(new HashMap<VDBKey, QueryMetadataHolder>());
+ // RuntimeIndexSelector for the system vdb
+ private final VDBArchive systemVDBSelector;
+
+ // boolean for the cache being valid
+ private boolean isCacheValid = true;
+ private MetadataStore systemMetadataStore;
+
+ /**
+ * Constructor given a URL to a system vdb.
+ * @since 4.2
+ */
+ public QueryMetadataCache(final URL systemVdbUrl) throws MetaMatrixComponentException
{
+ try {
+ this.systemVDBSelector = new VDBArchive(systemVdbUrl.openStream());
+ this.systemMetadataStore = new
IndexMetadataFactory(this.systemVDBSelector).getMetadataStore();
+ } catch(IOException e) {
+ throw new MetaMatrixComponentException(e,
DQPPlugin.Util.getString("QueryMetadataCache.Failed_creating_Runtime_Index_Selector._4",
CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Look up metadata for the given vdbName, version at the given filecontent.
+ * @throws MetaMatrixComponentException
+ */
+ public TransformationMetadata lookupMetadata(final String vdbName, final String
vdbVersion, MetadataSource iss, DataService dataService) throws
MetaMatrixComponentException {
+ assertIsValidCache();
+ VDBKey vdbID = toVdbID(vdbName, vdbVersion);
+ QueryMetadataHolder qmiHolder = null;
+ // Enter a synchronized block to find the holder of a QueryMetadataInterface for
a VDB
+ synchronized(vdbToQueryMetadata) {
+ qmiHolder = vdbToQueryMetadata.get(vdbID);
+ if ( qmiHolder == null ) {
+ qmiHolder = new QueryMetadataHolder();
+ vdbToQueryMetadata.put(vdbID, qmiHolder);
+ }
+ }
+ synchronized (qmiHolder) {
+ if (qmiHolder.qmi == null) {
+ qmiHolder.qmi = loadMetadata(vdbID, iss, dataService);
+ }
+ }
+ return qmiHolder.qmi;
+ }
+
+ private void assertIsValidCache() {
+ if(!this.isCacheValid) {
+ throw new
MetaMatrixRuntimeException(DQPPlugin.Util.getString("QueryMetadataCache.cache_not_valid"));
//$NON-NLS-1$
+ }
+ }
+
+ private TransformationMetadata loadMetadata(final VDBKey vdbID, final MetadataSource
runtimeSelector, DataService dataService) throws MetaMatrixComponentException {
+ // check cache status
+ assertIsValidCache();
+
+ List<MetadataStore> metadataStores = new ArrayList<MetadataStore>();
+ try {
+ metadataStores.add(new IndexMetadataFactory(runtimeSelector).getMetadataStore());
+ Set<String> modelNames =
runtimeSelector.getConnectorMetadataModelNames();
+ if (!modelNames.isEmpty()) {
+ for (String modelName : modelNames) {
+ MetadataStore connectorMetadata = null;
+ String savedMetadata = "/META-INF/" + modelName.toLowerCase() +
".ser"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (runtimeSelector.cacheConnectorMetadata()) {
+ File f = runtimeSelector.getFile(savedMetadata);
+ if (f != null) {
+ ObjectInputStream ois = null;
+ try {
+ ois = new ObjectInputStream(new FileInputStream(f));
+ connectorMetadata = (MetadataStore)ois.readObject();
+ } catch (Exception e) {
+
+ } finally {
+ if (ois != null) {
+ ois.close();
+ }
+ }
+ }
+ }
+ if (connectorMetadata == null) {
+ connectorMetadata = dataService.getConnectorMetadata(vdbID.getName(),
vdbID.getVersion(), modelName, runtimeSelector.getModelInfo(modelName).getProperties());
+ }
+ if (runtimeSelector.cacheConnectorMetadata()) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(connectorMetadata);
+ oos.close();
+ runtimeSelector.saveFile(new ByteArrayInputStream(baos.toByteArray()),
savedMetadata);
+ }
+ metadataStores.add(connectorMetadata);
+ }
+ }
+ metadataStores.add(systemMetadataStore);
+ } catch (IOException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ // build a composite selector for the runtimeselectors of this vdb and system
vdb
+ CompositeMetadataStore composite = new CompositeMetadataStore(metadataStores,
runtimeSelector);
+ return new TransformationMetadata(composite);
+ }
+
+ public Map<String, DatatypeRecordImpl> getBuiltinDatatypes() {
+ Collection<DatatypeRecordImpl> datatypes =
this.systemMetadataStore.getDatatypes();
+ Map<String, DatatypeRecordImpl> datatypeMap = new HashMap<String,
DatatypeRecordImpl>();
+ for (Class<?> typeClass : DataTypeManager.getAllDataTypeClasses()) {
+ for (DatatypeRecordImpl datatypeRecordImpl : datatypes) {
+ if (datatypeRecordImpl.getJavaClassName().equals(typeClass.getName())) {
+ datatypeMap.put(DataTypeManager.getDataTypeName(typeClass), datatypeRecordImpl);
+ break;
+ }
+ }
+ }
+ return datatypeMap;
+ }
+
+ /**
+ * Clears all state on this cache and also deletes any indexfiles
+ * associated with the cache.
+ * @since 4.2
+ */
+ public void clearCache() {
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache
Clearing VDB cache"}); //$NON-NLS-1$
+ // mark cache invalid
+ isCacheValid = false;
+ // Clear the holders ...
+ vdbToQueryMetadata.clear();
+
+ // Clean up the directory for the System VDB ...
+ if (this.systemVDBSelector != null) {
+ // selector should no longer be used
+ this.systemVDBSelector.close();
+ }
+ }
+
+ /**
+ * Remove cache for a given vdb, called when a vdb is actually deleted.
+ * Also deletes any temp files associated with the vdb.
+ */
+ public void removeFromCache(final String vdbName, final String vdbVersion) {
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache
Removing vdb from cache", vdbName, vdbVersion}); //$NON-NLS-1$
+ if(vdbName != null && vdbVersion != null) {
+ final VDBKey vdbID = toVdbID(vdbName, vdbVersion);
+ vdbToQueryMetadata.remove(vdbID);
+ }
+ }
+
+ /**
+ * Return unique id for a vdb
+ */
+ private VDBKey toVdbID(final String vdbName, final String vdbVersion) {
+ return new VDBKey(vdbName, vdbVersion);
+ }
+
+}
Property changes on:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedVDBService.java
===================================================================
---
trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedVDBService.java 2009-10-25
02:03:40 UTC (rev 1538)
+++
trunk/runtime/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedVDBService.java 2009-10-25
02:04:53 UTC (rev 1539)
@@ -81,17 +81,6 @@
}
}
- public void testSystemModelConnectorBinding() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties();
- configService.setUserPreferences(p);
- configService.initializeService(p);
-
- // asking "vdb.name" and stored "vdb.name"
- List names = vdbService.getConnectorBindingNames("QT_Ora9DS",
"1", EmbeddedBaseDQPService.SYSTEM_PHYSICAL_MODEL_NAME); //$NON-NLS-1$
//$NON-NLS-2$
- assertEquals(1, names.size());
- assertEquals(EmbeddedBaseDQPService.SYSTEM_PHYSICAL_MODEL_NAME,
(String)names.get(0));
- }
-
// new VDB connector binding scope names
//---------------------------------------
// | stored |