Author: shawkins
Date: 2010-04-13 12:28:08 -0400 (Tue, 13 Apr 2010)
New Revision: 2051
Added:
trunk/test-integration/db/src/test/java/com/IntTest.java
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
Log:
TEIID-1043 fix to ensure that attachment information errors do not prevent vdb loading
Modified: trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-04-12
03:02:54 UTC (rev 2050)
+++ trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-04-13
16:28:08 UTC (rev 2051)
@@ -30,14 +30,17 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
+import org.teiid.runtime.RuntimePlugin;
+import com.metamatrix.common.log.LogConstants;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.FileUtils;
public class ObjectSerializer {
private static final Logger log = Logger.getLogger(ObjectSerializer.class);
- private static final String ATTACHMENT_SUFFIX = ".ser";
+ private static final String ATTACHMENT_SUFFIX = ".ser"; //$NON-NLS-1$
private String storagePath;
@@ -45,10 +48,9 @@
this.storagePath = path;
}
- @SuppressWarnings("unchecked")
public <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws
IOException, ClassNotFoundException {
if (log.isTraceEnabled()) {
- log.trace("loadAttachment, attachmentsStore=" + attachmentsStore);
+ log.trace("loadAttachment, attachmentsStore=" + attachmentsStore);
//$NON-NLS-1$
}
ObjectInputStream ois = null;
@@ -64,7 +66,7 @@
public void saveAttachment(File attachmentsStore, Object attachment) throws IOException
{
if (log.isTraceEnabled()) {
- log.trace("saveAttachment, attachmentsStore=" + attachmentsStore + ",
attachment=" + attachment);
+ log.trace("saveAttachment, attachmentsStore=" + attachmentsStore + ",
attachment=" + attachment); //$NON-NLS-1$ //$NON-NLS-2$
}
ObjectOutputStream oos = null;
@@ -100,4 +102,17 @@
String dirName = this.storagePath + File.separator + fileName + File.separator;
return dirName;
}
+
+ public <T> T loadSafe(File cacheFile, Class<T> clazz) {
+ try {
+ if (cacheFile.exists()) {
+ return clazz.cast(loadAttachment(cacheFile, clazz));
+ }
+ return null;
+ } catch (Exception e) {
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, e,
RuntimePlugin.Util.getString("invalid_metadata_file",
cacheFile.getAbsolutePath())); //$NON-NLS-1$
+ }
+ cacheFile.delete();
+ return null;
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-04-12 03:02:54
UTC (rev 2050)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-04-13 16:28:08
UTC (rev 2051)
@@ -223,19 +223,13 @@
boolean cache =
"cached".equalsIgnoreCase(vdb.getPropertyValue("UseConnectorMetadata"));
//$NON-NLS-1$ //$NON-NLS-2$
File cacheFile = null;
if (cache) {
- try {
- cacheFile = buildCachedFileName(unit, vdb,model.getName());
- if (cacheFile.exists()) {
- return this.serializer.loadAttachment(cacheFile, MetadataStore.class);
- }
- } catch (IOException e) {
- LogManager.logWarning(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.getString("invalid_metadata_file",
cacheFile.getAbsolutePath())); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- LogManager.logWarning(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.getString("invalid_metadata_file",
cacheFile.getAbsolutePath())); //$NON-NLS-1$
- }
+ cacheFile = buildCachedFileName(unit, vdb,model.getName());
+ MetadataStore store = this.serializer.loadSafe(cacheFile, MetadataStore.class);
+ if (store != null) {
+ return store;
+ }
}
-
Exception exception = null;
for (String sourceName: model.getSourceNames()) {
ConnectorManager cm =
this.connectorManagerRepository.getConnectorManager(model.getSourceJndiName(sourceName));
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-04-12
03:02:54 UTC (rev 2050)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-04-13
16:28:08 UTC (rev 2051)
@@ -140,12 +140,9 @@
unit.addAttachment(IndexMetadataFactory.class, imf);
// add the cached store.
- MetadataStoreGroup stores = null;
- File cacheFileName = this.serializer.getAttachmentPath(unit,
vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
- if (cacheFileName.exists()) {
- stores = this.serializer.loadAttachment(cacheFileName, MetadataStoreGroup.class);
- }
- else {
+ File cacheFile = this.serializer.getAttachmentPath(unit,
vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
+ MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile,
MetadataStoreGroup.class);
+ if (stores == null) {
stores = new MetadataStoreGroup();
stores.addStore(imf.getMetadataStore());
}
Added: trunk/test-integration/db/src/test/java/com/IntTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/com/IntTest.java (rev
0)
+++ trunk/test-integration/db/src/test/java/com/IntTest.java 2010-04-13 16:28:08 UTC (rev
2051)
@@ -0,0 +1,37 @@
+/*
+ * Copyright � 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+package com;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.jdbc.TeiidStatement;
+
+
+/**
+ */
+public class IntTest {
+
+ public static void main(String[] args) throws Exception {
+ Connection c =
TeiidDriver.getInstance().connect("jdbc:teiid:TPCRperf@mm://localhost:31000;user=admin;password=teiid",
null);
+ Statement s = c.createStatement();
+ try {
+ s.execute("set showplan debug");
+ ResultSet rs = s.executeQuery("SELECT ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE,
ORDERS.O_CLERK, CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME FROM
TPCR01_SqlServerVirt.TPCR01.ORDERS, TPCR01_OracleVirt.CUSTOMER WHERE CUSTOMER.C_CUSTKEY =
ORDERS.O_CUSTKEY AND CUSTOMER.C_NATIONKEY = 1 AND CUSTOMER.C_ACCTBAL between 5 AND 2000
AND ORDERS.O_ORDERDATE < {ts'1998-01-01 00:00:00'} OPTION MAKEDEP
TPCR01_SQLServerPhys.TPCR01.ORDERS");
+ int i = 0;
+ while (rs.next()) {
+ i++;
+ }
+ System.out.println(s.unwrap(TeiidStatement.class).getPlanDescription());
+ System.out.println(s.unwrap(TeiidStatement.class).getDebugLog());
+ System.out.println(i);
+ } finally {
+ s.close();
+ c.close();
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/test-integration/db/src/test/java/com/IntTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain