teiid SVN: r1148 - in trunk: cache-jbosscache/src/main/java/com/metamatrix/cache/jboss and 28 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-07-17 13:57:05 -0400 (Fri, 17 Jul 2009)
New Revision: 1148
Modified:
trunk/build/kit-embedded/deploy.properties
trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/CacheProvider.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
trunk/embedded/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/EmbeddedTestUtil.java
trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java
trunk/embedded/src/test/resources/admin/buffertest1.properties
trunk/embedded/src/test/resources/admin/buffertest2.properties
trunk/embedded/src/test/resources/admin/buffertest3.properties
trunk/embedded/src/test/resources/bqt/fakebqt.properties
trunk/embedded/src/test/resources/dqp/dqp.properties
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestDataEntitlements.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestVDBLessExecution.java
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestPartsDatabaseMetadata.java
trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestResultSetMetadata.java
trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataInConnector.java
trunk/test-integration/src/test/resources/3473/3473.properties
trunk/test-integration/src/test/resources/authcheck/bqt.properties
trunk/test-integration/src/test/resources/bqt/bqt.properties
trunk/test-integration/src/test/resources/dqp/dqp.properties
trunk/test-integration/src/test/resources/metadata/dqp.properties
trunk/test-integration/src/test/resources/partssupplier/dqp.properties
trunk/test-integration/src/test/resources/vdbless/dqp.properties
trunk/test-integration/src/test/resources/xml-vp/xmlvp.properties
trunk/test-integration/src/test/resources/xquery/xquery.properties
trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java
trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
Log:
TEIID-722, TEIID-679 : Fixed the instance name of the instance based on the process name rather than an automatic integer identifier. Also, exposed the transaction Manager properties in the deploy properties
Modified: trunk/build/kit-embedded/deploy.properties
===================================================================
--- trunk/build/kit-embedded/deploy.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/build/kit-embedded/deploy.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -144,3 +144,9 @@
#ssl.truststore.filename=teiid.truststore
#ssl.truststore.Password=changeme
#client.encryption.enabled=true
+
+
+# transaction time out in seconds
+#xa.enabled=true
+#xa.max_timeout=120
+#xa.enable_recovery=true
\ No newline at end of file
Modified: trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -34,6 +34,7 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import com.google.inject.name.Named;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
@@ -48,20 +49,18 @@
private static final String NAME = "Cache"; //$NON-NLS-1$
private org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
+ private JMXUtil jmx;
@Inject
- JMXUtil jmx;
-
- @Inject
- public JBossCacheFactory(org.jboss.cache.Cache cacheStore) {
- try {
- jmx.register(JMXUtil.MBeanType.SERVICE, NAME, cacheStore);
- cacheStore.create();
- cacheStore.start();
- this.cacheStore = cacheStore;
- } catch (FailedToRegisterException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- }
+ public JBossCacheFactory(org.jboss.cache.Cache cacheStore, @Named("jmx") JMXUtil jmx) {
+ this.cacheStore = cacheStore;
+// try {
+// this.jmx = jmx;
+// //jmx.register(JMXUtil.MBeanType.SERVICE, NAME, cacheStore);
+// this.cacheStore = cacheStore;
+// } catch (FailedToRegisterException e) {
+// throw new MetaMatrixRuntimeException(e.getCause());
+// }
}
/**
@@ -110,13 +109,13 @@
}
public void destroy() {
- try {
- jmx.unregister(JMXUtil.MBeanType.SERVICE, NAME);
- } catch (FailedToRegisterException e) {
- } finally {
- this.cacheStore.destroy();
- this.destroyed = true;
- }
+// try {
+// jmx.unregister(JMXUtil.MBeanType.SERVICE, NAME);
+// } catch (FailedToRegisterException e) {
+// } finally {
+// this.cacheStore.destroy();
+// this.destroyed = true;
+// }
}
}
Modified: trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -47,7 +47,6 @@
public static final String OUTPUT_BUFFER_SIZE = "server.outputBufferSize"; //$NON-NLS-1$
//derived properties
- public static final String DQP_IDENTITY = "dqp.identity"; //$NON-NLS-1$
public static final String DQP_TMPDIR = "mm.io.tmpdir"; //$NON-NLS-1$
public static final String BOOTURL = "bootURL"; //$NON-NLS-1$
public static final String ENABLE_SOCKETS = "sockets.enabled"; //$NON-NLS-1$
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -942,7 +942,7 @@
try {
this.setUserPreferences(PropertiesUtils.clone(properties));
- DQPEmbeddedPlugin.logInfo("EmbeddedConfigurationService.dqp_loading", new Object[] {getInstanceIdenifier()}); //$NON-NLS-1$
+ DQPEmbeddedPlugin.logInfo("EmbeddedConfigurationService.dqp_loading", new Object[] {getProcessName()}); //$NON-NLS-1$
// initialize encryption
initializeEncryption();
@@ -1008,12 +1008,7 @@
*/
public URL[] getVDBLocations() {
ArrayList vdbs = new ArrayList();
- addVDBs(vdbs, getUserPreferences().getProperty(DQPEmbeddedProperties.VDB_DEFINITION));
- addVDBs(vdbs, getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR));
- return (URL[])vdbs.toArray(new URL[vdbs.size()]);
- }
-
- private void addVDBs(ArrayList vdbs, String vdbProperty) {
+ String vdbProperty = getUserPreferences().getProperty(DQPEmbeddedProperties.VDB_DEFINITION);
if (vdbProperty != null && vdbProperty.length() != 0) {
StringTokenizer st = new StringTokenizer(vdbProperty, VDB_LIST_SEPARATOR);
while( st.hasMoreTokens() ) {
@@ -1027,7 +1022,8 @@
vdbs.add(vdbURL);
}
}
- }
+ return (URL[])vdbs.toArray(new URL[vdbs.size()]);
+ }
/**
* Load the Connector Bindings from the VDBS and ServerConfig.xml
@@ -1389,7 +1385,6 @@
private File getWorkDir() {
String workDirectory = getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_WORKDIR);
File workDir = new File(workDirectory);
- workDir.mkdirs();
return workDir;
}
@@ -1417,10 +1412,10 @@
}
/**
- * @see com.metamatrix.dqp.service.ConfigurationService#getInstanceIdenifier()
+ * @see com.metamatrix.dqp.service.ConfigurationService#getProcessName()
*/
- public String getInstanceIdenifier() {
- return getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_IDENTITY);
+ public String getProcessName() {
+ return getUserPreferences().getProperty(DQPEmbeddedProperties.PROCESSNAME);
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -34,15 +34,12 @@
public class EmbeddedTransactionService extends TransactionServerImpl {
- public static final String TRANSACTIONS_ENABLED = "metamatrix.xatxnmgr.enabled"; //$NON-NLS-1$
-
@Override
public void initialize(Properties props)
throws ApplicationInitializationException {
try {
props = new Properties(props);
- props.setProperty(TransactionService.HOSTNAME, "dqp"); //$NON-NLS-1$
- props.setProperty(TransactionService.VMNAME, props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY));
+ props.setProperty(TransactionService.PROCESSNAME, props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
props.setProperty(TransactionService.TXN_STORE_DIR, props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR));
this.setTransactionProvider(ArjunaTransactionProvider.getInstance(props));
} catch (XATransactionException e) {
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/CacheProvider.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/CacheProvider.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/CacheProvider.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -47,6 +47,8 @@
String workspaceDir = this.props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR);
p.setProperty("location", workspaceDir + "/cache"); //$NON-NLS-1$ //$NON-NLS-2$
configs.get(0).setProperties(p);
+ cache.create();
+ cache.start();
return cache;
}
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -26,11 +26,13 @@
import java.io.File;
import java.io.IOException;
+import java.io.RandomAccessFile;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.URL;
+import java.nio.channels.FileChannel;
import java.util.Date;
import java.util.Properties;
@@ -101,7 +103,7 @@
initialize(connectionProperties);
return new LocalServerConnection(connectionProperties, this.clientServices);
} catch (ApplicationInitializationException e) {
- throw new ConnectionException(e.getCause());
+ throw new ConnectionException(e, e.getMessage());
}
}
@@ -120,21 +122,22 @@
return;
}
- String dqpId = getDQPIdentity(info);
- info.setProperty(DQPEmbeddedProperties.DQP_IDENTITY, dqpId);
-
URL bootstrapURL = null;
Properties props = info;
-
+ String processName = "embedded"; //$NON-NLS-1$
+
try {
bootstrapURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.BOOTURL));
props = PropertiesUtils.loadFromURL(bootstrapURL);
props.putAll(info);
props = PropertiesUtils.resolveNestedProperties(props);
+ processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME, processName);
+ props.setProperty(DQPEmbeddedProperties.PROCESSNAME, processName);
+
// Create a temporary workspace directory
String teiidHome = info.getProperty(DQPEmbeddedProperties.TEIID_HOME);
- this.workspaceDirectory = createWorkspace(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR, "work"), dqpId); //$NON-NLS-1$
+ this.workspaceDirectory = createWorkspace(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR, "work"), processName); //$NON-NLS-1$
props.setProperty(DQPEmbeddedProperties.DQP_WORKDIR, this.workspaceDirectory);
// create the deploy directories
@@ -142,17 +145,28 @@
props.setProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, deployDirectory.getCanonicalPath());
deployDirectory.mkdirs();
+ // if there is no separate vdb-definitions specified then use the deploy directory as the location of the vdb
+ String vdbDefinitions = props.getProperty(DQPEmbeddedProperties.VDB_DEFINITION);
+ if (vdbDefinitions == null) {
+ props.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, deployDirectory.getCanonicalPath());
+ }
+
// create log directory
File logDirectory = new File(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_LOGDIR, "log")); //$NON-NLS-1$
props.setProperty(DQPEmbeddedProperties.DQP_LOGDIR, logDirectory.getCanonicalPath());
deployDirectory.mkdirs();
-
+
} catch (IOException e) {
throw new ApplicationInitializationException(e);
}
-
- this.jmxServer = new JMXUtil(dqpId);
-
+
+ // check for a duplicate process and exit if one found.
+ if(isDuplicateProcess(processName)) {
+ throw new ApplicationInitializationException(DQPEmbeddedPlugin.Util.getString("DQPEmbeddedManager.duplicate_process", processName)); //$NON-NLS-1$
+ }
+
+ this.jmxServer = new JMXUtil(processName);
+
EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, this.jmxServer);
Injector injector = Guice.createInjector(config);
ResourceFinder.setInjector(injector);
@@ -187,6 +201,18 @@
DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
}
+ private boolean isDuplicateProcess(String processName) {
+ try {
+ File f = new File(this.workspaceDirectory, "teiid_"+processName+".pid"); //$NON-NLS-1$ //$NON-NLS-2$
+ FileChannel channel = new RandomAccessFile(f, "rw").getChannel(); //$NON-NLS-1$
+ return (channel.tryLock() == null);
+ } catch (Exception e) {
+ // ignore
+ }
+ return true;
+ }
+
+
private ClientServiceRegistry createClientServices(ConfigurationService configService) {
ClientServiceRegistry services = new ClientServiceRegistry();
@@ -202,36 +228,16 @@
}
/**
- * Define an identifier for the DQP
- * @return a JVM level unique identifier
- */
- private String getDQPIdentity(Properties props) {
-
- String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
- if (processName != null) {
- return processName;
- }
-
- synchronized (System.class) {
- String id = System.getProperty(DQPEmbeddedProperties.DQP_IDENTITY, "1"); //$NON-NLS-1$
- int identity = Integer.parseInt(id);
- System.setProperty(DQPEmbeddedProperties.DQP_IDENTITY, String.valueOf(identity + 1));
- id = String.valueOf(identity);
- return id;
- }
- }
-
- /**
* Create the temporary workspace directory for the dqp
* @param identity - identity of the dqp
* @throws MMSQLException
*/
private String createWorkspace(String teiidHome, String baseDir, String identity) throws IOException {
File baseFile = new File(teiidHome, baseDir);
-
- System.setProperty(DQPEmbeddedProperties.DQP_TMPDIR, baseFile.getCanonicalPath() + "/temp"); //$NON-NLS-1$S
-
+
File f = new File(baseFile, identity);
+
+ System.setProperty(DQPEmbeddedProperties.DQP_TMPDIR, f.getCanonicalPath() + "/temp"); //$NON-NLS-1$S
// If directory already exists then try to delete it; because we may have
// failed to delete at end of last run (JVM holds lock on jar files)
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -58,6 +58,7 @@
import com.metamatrix.dqp.embedded.services.EmbeddedTransactionService;
import com.metamatrix.dqp.embedded.services.EmbeddedVDBService;
import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.platform.security.api.AuthorizationPolicy;
import com.metamatrix.platform.security.authorization.service.AdminAuthorizationPolicyProvider;
import com.metamatrix.platform.security.authorization.service.AuthorizationServiceImpl;
@@ -83,10 +84,8 @@
bind(LogListener.class).toProvider(LogListernerProvider.class).in(Scopes.SINGLETON);
bind(URL.class).annotatedWith(Names.named("BootstrapURL")).toInstance(bootstrapURL); //$NON-NLS-1$
- bindConstant().annotatedWith(Names.named("HostName")).to("embedded"); //$NON-NLS-1$ //$NON-NLS-2$
- bindConstant().annotatedWith(Names.named("ProcessName")).to(props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY, "test")); //$NON-NLS-1$ //$NON-NLS-2$
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props); //$NON-NLS-1$
- bind(JMXUtil.class).toInstance(this.jmx);
+ bind(JMXUtil.class).annotatedWith(Names.named("jmx")).toInstance(this.jmx); //$NON-NLS-1$
InetAddress address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(address);
@@ -136,7 +135,7 @@
}
private Map<String, Class<? extends ApplicationService>> getDefaultServiceClasses() {
- boolean useTxn = PropertiesUtils.getBooleanProperty(props, EmbeddedTransactionService.TRANSACTIONS_ENABLED, true);
+ boolean useTxn = PropertiesUtils.getBooleanProperty(props, TransactionService.TRANSACTIONS_ENABLED, true);
Map<String, Class<? extends ApplicationService>> result = new HashMap<String, Class<? extends ApplicationService>>();
result.put(DQPServiceNames.CONFIGURATION_SERVICE, EmbeddedConfigurationService.class);
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -43,9 +43,9 @@
@Override
public LogListener get() {
String logDirectory = this.props.getProperty(DQPEmbeddedProperties.DQP_LOGDIR);
- String instanceId = this.props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY, "0"); //$NON-NLS-1$
+ String processName = this.props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
- File logFile = new File(logDirectory, "teiid_"+instanceId+".log"); //$NON-NLS-1$ //$NON-NLS-2$
+ File logFile = new File(logDirectory, "teiid_"+processName+".log"); //$NON-NLS-1$ //$NON-NLS-2$
System.setProperty("dqp.log4jFile", logFile.getAbsolutePath()); //$NON-NLS-1$ // hack
return new Log4jListener();
}
Modified: trunk/embedded/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
===================================================================
--- trunk/embedded/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -194,6 +194,7 @@
DQPEmbeddedManager.start_dqp=DQP is started at time = {0}
DQPEmbeddedManager.shutdown_dqp=DQP is shutdown at time = {0}
+DQPEmbeddedManager.duplicate_process= There is another process running with same name {0}; Failed to start.
ServerSecurityAdminImpl.User_name_too_long=The user name may not be null and cannot be longer than {0} charachters
ServerSecurityAdminImpl.neither_User_nor_Group=Parameter memberType is neither a User nor a Group.
Modified: trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/EmbeddedTestUtil.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/EmbeddedTestUtil.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/EmbeddedTestUtil.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -36,8 +36,11 @@
public static Properties getProperties() throws IOException {
Properties p = getProperties(UnitTestUtil.getTestScratchPath()+"/dqp/dqp.properties"); //$NON-NLS-1$
- p.setProperty(DQPEmbeddedProperties.DQP_WORKDIR, System.getProperty("java.io.tmpdir")+"/teiid/1"); //$NON-NLS-1$ //$NON-NLS-2$
- p.setProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, System.getProperty("java.io.tmpdir")+"/teiid/deploy"); //$NON-NLS-1$ //$NON-NLS-2$
+ p.setProperty(DQPEmbeddedProperties.DQP_WORKDIR, p.getProperty(DQPEmbeddedProperties.TEIID_HOME)+"/work"); //$NON-NLS-1$
+ p.setProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, p.getProperty(DQPEmbeddedProperties.TEIID_HOME)+"/deploy"); //$NON-NLS-1$
+
+ new File(p.getProperty(DQPEmbeddedProperties.TEIID_HOME)+"/work").mkdirs(); //$NON-NLS-1$
+ new File(p.getProperty(DQPEmbeddedProperties.TEIID_HOME)+"/deploy").mkdirs(); //$NON-NLS-1$
return p;
}
Modified: trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -91,8 +91,8 @@
}
public void testGetAvailableVDBFiles() throws Exception {
- service.setUserPreferences(EmbeddedTestUtil.getProperties());
- HashMap vdbFiles = VDBConfigurationReader.loadVDBS(service.getVDBLocations(), new File(UnitTestUtil.getTestScratchPath()));
+ service.setUserPreferences(EmbeddedTestUtil.getProperties());
+ HashMap vdbFiles = VDBConfigurationReader.loadVDBS(service.getVDBLocations(), service.getDeployDir());
int count = vdbFiles.keySet().size();
assertEquals(2, count);
// admin.vdb is ignored because it did not have any models
Modified: trunk/embedded/src/test/resources/admin/buffertest1.properties
===================================================================
--- trunk/embedded/src/test/resources/admin/buffertest1.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/resources/admin/buffertest1.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -27,7 +27,7 @@
dqp.logLevel=4
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/embedded/src/test/resources/admin/buffertest2.properties
===================================================================
--- trunk/embedded/src/test/resources/admin/buffertest2.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/resources/admin/buffertest2.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -30,7 +30,7 @@
dqp.logLevel=4
dqp.identity=1
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/embedded/src/test/resources/admin/buffertest3.properties
===================================================================
--- trunk/embedded/src/test/resources/admin/buffertest3.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/resources/admin/buffertest3.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -28,7 +28,7 @@
dqp.logLevel=4
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
Modified: trunk/embedded/src/test/resources/bqt/fakebqt.properties
===================================================================
--- trunk/embedded/src/test/resources/bqt/fakebqt.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/resources/bqt/fakebqt.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -11,7 +11,7 @@
service.dqp.configuration.classname=com.metamatrix.dqp.service.FakeAbstractService
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
metamatrix.xatxnmgr.txnstore_dir=../../../../target/scratch
Modified: trunk/embedded/src/test/resources/dqp/dqp.properties
===================================================================
--- trunk/embedded/src/test/resources/dqp/dqp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/embedded/src/test/resources/dqp/dqp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -31,7 +31,7 @@
dqp.buffer.connectorBatchSize=3868
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -358,11 +358,11 @@
public String getBufferMemorySize();
/**
- * Return some identifier which uniquely identifies the DQP. Usally this
- * is an integer value which is set at the creation of the DQP
+ * Return some identifier which uniquely identifies the DQP. Usually this
+ * is name given to this process
* @return unique number for DQP in a given JVM
*/
- public String getInstanceIdenifier();
+ public String getProcessName();
/**
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -39,18 +39,19 @@
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
/**
*/
public interface TransactionService extends ApplicationService {
- public static final String MAX_TIMEOUT = "metamatrix.xatxnmgr.max_timeout"; //$NON-NLS-1$
- public static final String TXN_STORE_DIR = "metamatrix.xatxnmgr.txnstore_dir"; //$NON-NLS-1$
- public static final String TXN_STATUS_PORT = "metamatrix.xatxnmgr.txnstatus_port"; //$NON-NLS-1$
- public static final String TXN_ENABLE_RECOVERY = "metamatrix.xatxnmgr.enable_recovery"; //$NON-NLS-1$
+ public static final String TRANSACTIONS_ENABLED = "xa.enabled"; //$NON-NLS-1$
+ public static final String MAX_TIMEOUT = "xa.max_timeout"; //$NON-NLS-1$
+ public static final String TXN_STORE_DIR = "xa.txnstore_dir"; //$NON-NLS-1$
+ public static final String TXN_STATUS_PORT = "xa.txnstatus_port"; //$NON-NLS-1$
+ public static final String TXN_ENABLE_RECOVERY = "xa.enable_recovery"; //$NON-NLS-1$
- public static final String VMNAME = "metamatrix.xatxnmgr.vmname"; //$NON-NLS-1$
- public static final String HOSTNAME = "metamatrix.xatxnmgr.hostname"; //$NON-NLS-1$
+ public static final String PROCESSNAME = DQPEmbeddedProperties.PROCESSNAME;
public static final String DEFAULT_TXN_MGR_LOG_DIR = "txnlog"; //$NON-NLS-1$
public static final String DEFAULT_TXN_TIMEOUT = "120"; //$NON-NLS-1$ //2 mins
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -21,6 +21,8 @@
*/
package org.teiid.dqp.internal.cache;
+import java.util.Properties;
+
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
@@ -28,6 +30,7 @@
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.CacheConfiguration.Policy;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@Singleton
public class DQPContextCache {
@@ -37,9 +40,9 @@
private String processIdentifier;
@Inject
- public DQPContextCache(@Named("HostName") String hostName, @Named("ProcessName") String processName, CacheFactory cacheFactory) {
+ public DQPContextCache(@Named("DQPProperties") Properties props, CacheFactory cacheFactory) {
this.cache = cacheFactory.get(Cache.Type.SCOPED_CACHE, new CacheConfiguration(Policy.LRU, 600, 10000));
- this.processIdentifier = hostName + "-" + processName; //$NON-NLS-1$
+ this.processIdentifier = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
}
public Cache getGlobalScopedCache() {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -22,6 +22,8 @@
package com.metamatrix.dqp.service;
+import java.util.Properties;
+
import org.teiid.dqp.internal.cache.DQPContextCache;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -57,6 +59,6 @@
@Override
public DQPContextCache getContextCache() {
- return new DQPContextCache("test", "test", new FakeCacheFactory()); //$NON-NLS-1$ //$NON-NLS-2$
+ return new DQPContextCache(new Properties(), new FakeCacheFactory());
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -21,16 +21,15 @@
*/
package org.teiid.dqp.internal.cache;
+import java.util.Properties;
+
import junit.framework.TestCase;
-import org.teiid.connector.api.CacheScope;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -41,7 +40,9 @@
@Override
protected void setUp() throws Exception {
- cacheContext = new DQPContextCache("host", "process", new FakeCacheFactory()); //$NON-NLS-1$ //$NON-NLS-2$
+ Properties p = new Properties();
+ p.setProperty(DQPEmbeddedProperties.PROCESSNAME, "host-process"); //$NON-NLS-1$
+ cacheContext = new DQPContextCache(p, new FakeCacheFactory());
}
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -65,8 +65,7 @@
}
props.putAll(env);
- props.setProperty(TransactionService.HOSTNAME, host.getFullName());
- props.setProperty(TransactionService.VMNAME, CurrentConfiguration.getInstance().getProcessName());
+ props.setProperty(TransactionService.PROCESSNAME, CurrentConfiguration.getInstance().getProcessName());
props.setProperty(TransactionService.TXN_STORE_DIR, host.getDataDirectory());
this.setTransactionProvider(ArjunaTransactionProvider.getInstance(props));
Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestDataEntitlements.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestDataEntitlements.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestDataEntitlements.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -16,6 +16,7 @@
try {
getConnection(VDB, DQP_PROP_FILE, "user=test"); //$NON-NLS-1$
TestCase.fail("Should have failed authenticate user test"); //$NON-NLS-1$
+ closeConnection();
} catch (Exception e) {
}
}
@@ -23,13 +24,14 @@
@Test public void testAdminAuth() {
try {
getConnection(VDB, DQP_PROP_FILE, "user=admin;password=mm"); //$NON-NLS-1$
- TestCase.fail("Should have failed authenticate user test"); //$NON-NLS-1$
+ TestCase.fail("Should have failed authenticate user test"); //$NON-NLS-1$
} catch (Exception e) {
}
getConnection(VDB, DQP_PROP_FILE, "user=admin;password=teiid"); //$NON-NLS-1$
execute("select * from BQT1.smalla"); //$NON-NLS-1$
walkResults();
+ closeConnection();
}
@Test public void testEntitlements() {
@@ -38,26 +40,29 @@
TestCase.fail("Should have failed authenticate user test"); //$NON-NLS-1$
} catch (Exception e) {
}
-
+
+ getConnection(VDB, DQP_PROP_FILE, "user=john;password=mm"); //$NON-NLS-1$
try {
- getConnection(VDB, DQP_PROP_FILE, "user=john;password=mm"); //$NON-NLS-1$
execute("select intkey, stringkey from BQT1.smalla"); //$NON-NLS-1$
walkResults();
} catch(Exception e) {
TestCase.assertTrue(e.getMessage().endsWith("is not entitled to action <Read> for 1 or more of the groups/elements/procedures.")); //$NON-NLS-1$
}
+ closeConnection();
getConnection(VDB, DQP_PROP_FILE, "user=paul;password=mm"); //$NON-NLS-1$
execute("select intkey, stringkey from BQT1.smalla"); //$NON-NLS-1$
assertRowCount(50);
-
+ closeConnection();
+
+ getConnection(VDB, DQP_PROP_FILE, "user=paul;password=mm"); //$NON-NLS-1$
try {
- getConnection(VDB, DQP_PROP_FILE, "user=paul;password=mm"); //$NON-NLS-1$
execute("select * from BQT1.smalla"); //$NON-NLS-1$
walkResults();
} catch(Exception e) {
TestCase.assertTrue(e.getMessage().endsWith("is not entitled to action <Read> for 1 or more of the groups/elements/procedures.")); //$NON-NLS-1$
- }
+ }
+ closeConnection();
}
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestVDBLessExecution.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestVDBLessExecution.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestVDBLessExecution.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -46,6 +46,7 @@
"y 2" //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testIntegrationExecution() {
@@ -55,6 +56,7 @@
"x 1 1 1 -23 null -23.0 -23 -23.0 -127 2000-01-02 01:00:00 2000-01-01 00:00:01.0 1 0 -32767 -23 -23 -23", //$NON-NLS-1$
"y 2 2 2 -22 -22 null -22 -22.0 -126 2000-01-03 02:00:00 2000-01-01 00:00:02.0 0 1 -32766 -22 -22 -22", //$NON-NLS-1$
});
+ closeConnection();
}
/**
@@ -63,6 +65,7 @@
@Test public void testProcedureExecution() {
getConnection(VDB, DQP_PROP_FILE);
execute("exec Derby.SQLUDTS(null, null, null, null, null)"); //$NON-NLS-1$
+ closeConnection();
}
@Test public void testDatabaseMetaDataTables() throws Exception {
@@ -73,6 +76,7 @@
"TABLE_CAT[string] TABLE_SCHEM[string] TABLE_NAME[string] TABLE_TYPE[string] REMARKS[string] TYPE_CAT[string] TYPE_SCHEM[string] TYPE_NAME[string] SELF_REFERENCING_COL_NAME[string] REF_GENERATION[string] ISPHYSICAL[boolean]", //$NON-NLS-1$
"null VDBLess SummitData.EXAMPLE TABLE null null null null null null true" //$NON-NLS-1$
});
+ closeConnection();
}
/**
@@ -88,6 +92,7 @@
"null VDBLess System.ElementProperties SYSTEM TABLE null null null null null null false" //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataColumns() throws Exception {
@@ -99,6 +104,7 @@
"null VDBLess SummitData.EXAMPLE TRADEID 12 string 4000 null 0 0 0 null null null null 0 1 YES null null null null NO", //$NON-NLS-1$
"null VDBLess SummitData.EXAMPLE NOTIONAL 4 integer 10 null 0 0 0 null null null null 0 2 YES null null null null NO", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataColumns1() throws Exception {
@@ -125,6 +131,7 @@
"null VDBLess Derby.SMALLA BIGDECIMALVALUE 2 bigdecimal 20 null 0 10 1 null null null null 0 16 NO null null null null NO", //$NON-NLS-1$
"null VDBLess Derby.SMALLA OBJECTVALUE 12 string 4000 null 0 0 1 null null null null 4096 17 NO null null null null NO", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataPrimaryKeys() throws Exception {
@@ -141,6 +148,7 @@
"null VDBLess Derby.FLIGHTS SEGMENT_NUMBER 2 SQL090709161814150", //$NON-NLS-1$
"null VDBLess Derby.FLTAVAIL SEGMENT_NUMBER 2 FLTAVAIL_PK", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataExportedKeys() throws Exception {
@@ -152,6 +160,7 @@
"null VDBLess Derby.FLIGHTS FLIGHT_ID null VDBLess Derby.FLTAVAIL FLIGHT_ID 1 3 3 FLTS_FK SQL090709161814150 5", //$NON-NLS-1$
"null VDBLess Derby.FLIGHTS SEGMENT_NUMBER null VDBLess Derby.FLTAVAIL SEGMENT_NUMBER 2 3 3 FLTS_FK SQL090709161814150 5" //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataImportedKeys() throws Exception {
@@ -169,6 +178,7 @@
"null VDBLess Derby.SMALLA INTKEY null VDBLess Derby.SMALLBRIDGE AKEY 1 3 3 SMLA_FK SQL060110103634070 5", //$NON-NLS-1$
"null VDBLess Derby.SMALLB INTKEY null VDBLess Derby.SMALLBRIDGE BKEY 1 3 3 SMLB_FK SQL060110103635170 5", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataIndexInfo() throws Exception {
@@ -195,6 +205,7 @@
"null VDBLess Derby.SYSTRIGGERS false null SYSTRIGGERS_INDEX3 0 1 TABLEID null 0 1 null", //$NON-NLS-1$
"null VDBLess Derby.SYSTRIGGERS false null SYSTRIGGERS_INDEX3 0 2 CREATIONTIMESTAMP null 0 1 null", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataProcedures() throws Exception {
@@ -207,6 +218,7 @@
"null VDBLess Derby.REMOVE_JAR null null null null 1 Derby.REMOVE_JAR", //$NON-NLS-1$
"null VDBLess Derby.REPLACE_JAR null null null null 1 Derby.REPLACE_JAR", //$NON-NLS-1$
});
+ closeConnection();
}
@Test public void testDatabaseMetaDataProcedureColumns() throws Exception {
@@ -221,6 +233,7 @@
"null VDBLess Derby.SQLUDTS UDTTYPES 1 12 string 128 256 0 0 1 null null null null null 4 YES Derby.SQLUDTS.UDTTYPES", //$NON-NLS-1$
"null VDBLess Derby.SQLUDTS OPTIONS 1 12 string 4000 8000 0 0 1 null null null null null 5 YES Derby.SQLUDTS.OPTIONS", //$NON-NLS-1$
});
+ closeConnection();
}
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestPartsDatabaseMetadata.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestPartsDatabaseMetadata.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestPartsDatabaseMetadata.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -29,6 +29,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -56,6 +57,10 @@
getConnection(VDB, DQP_PROP_FILE);
dbMetadata = this.internalConnection.getMetaData();
}
+
+ @After public void tearDown() {
+ closeConnection();
+ }
private void checkResult(String testName, ResultSet actualResults) throws Exception {
ResultSetMetaData resultMetadata = actualResults.getMetaData();
Modified: trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestResultSetMetadata.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestResultSetMetadata.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/java/com/metamatrix/systemmodel/TestResultSetMetadata.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -22,6 +22,7 @@
package com.metamatrix.systemmodel;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +44,10 @@
getConnection(VDB, DQP_PROP_FILE);
}
+ @After public void tearDown() {
+ closeConnection();
+ }
+
private void executeTest(String sql, String[] expected) throws Exception {
execute(sql);
java.sql.ResultSet rs = this.internalResultSet;
Modified: trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataInConnector.java
===================================================================
--- trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataInConnector.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataInConnector.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -16,13 +16,15 @@
execute("Select * from TableA"); //$NON-NLS-1$
String expected[] = {"column1[string] column2[integer]"}; //$NON-NLS-1$
assertResults(expected);
+ closeConnection();
}
@Test public void testMetadataProcedure() throws Exception {
getConnection(VDB, DQP_PROP_FILE, ""); //$NON-NLS-1$
execute("exec AnyModel.ProcedureB(?)", new Object[] {"foo"}); //$NON-NLS-1$ //$NON-NLS-2$
String expected[] = {"column1[string] column2[integer]"}; //$NON-NLS-1$
- assertResults(expected);
+ assertResults(expected);
+ closeConnection();
}
}
Modified: trunk/test-integration/src/test/resources/3473/3473.properties
===================================================================
--- trunk/test-integration/src/test/resources/3473/3473.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/3473/3473.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -28,7 +28,7 @@
dqp.logLevel=2
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
Modified: trunk/test-integration/src/test/resources/authcheck/bqt.properties
===================================================================
--- trunk/test-integration/src/test/resources/authcheck/bqt.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/authcheck/bqt.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -24,7 +24,7 @@
vdb.definition=./bqt.def
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
membership.enabled=true
membership.superUser=admin
Modified: trunk/test-integration/src/test/resources/bqt/bqt.properties
===================================================================
--- trunk/test-integration/src/test/resources/bqt/bqt.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/bqt/bqt.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -24,7 +24,7 @@
vdb.definition=./loopback.DEF
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
Modified: trunk/test-integration/src/test/resources/dqp/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/dqp/dqp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/dqp/dqp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -29,7 +29,7 @@
#dqp.classpath=./lib/;./license/;./lib/metamatrix-dqp.jar;./lib/bcprov-jdk14-122.jar;./extensions/MJjdbc.jar
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
Modified: trunk/test-integration/src/test/resources/metadata/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/metadata/dqp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/metadata/dqp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -26,7 +26,7 @@
vdb.definition=./ConfigurationInfo.def
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/test-integration/src/test/resources/partssupplier/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/partssupplier/dqp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/partssupplier/dqp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -30,7 +30,7 @@
dqp.buffer.usedisk=false
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/test-integration/src/test/resources/vdbless/dqp.properties
===================================================================
--- trunk/test-integration/src/test/resources/vdbless/dqp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/vdbless/dqp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -25,7 +25,7 @@
vdb.definition=./ConfigurationInfo.def
processorDebugAllowed=true
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/test-integration/src/test/resources/xml-vp/xmlvp.properties
===================================================================
--- trunk/test-integration/src/test/resources/xml-vp/xmlvp.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/xml-vp/xmlvp.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -30,7 +30,7 @@
dqp.buffer.usedisk=false
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/test-integration/src/test/resources/xquery/xquery.properties
===================================================================
--- trunk/test-integration/src/test/resources/xquery/xquery.properties 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/test-integration/src/test/resources/xquery/xquery.properties 2009-07-17 17:57:05 UTC (rev 1148)
@@ -4,7 +4,7 @@
dqp.logLevel=2
#only for testing, as this takes more time to start and shutdown
-metamatrix.xatxnmgr.enable_recovery=false
+xa.enable_recovery=false
teiid.home=target/scratch
Modified: trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java
===================================================================
--- trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -77,8 +77,8 @@
*/
public void init(Properties props) throws XATransactionException {
// unique name for this txn manager
- String vmName = props.getProperty(TransactionService.VMNAME);
- String txnMgrUniqueName = "txnmgr_" + props.getProperty(TransactionService.HOSTNAME, "").replace('.', '_') + "_" + vmName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String vmName = props.getProperty(TransactionService.PROCESSNAME);
+ String txnMgrUniqueName = "txnmgr_" + "_" + vmName; //$NON-NLS-1$ //$NON-NLS-2$
// set the directory for storing the in-flight transactions
String baseDir = props.getProperty(TransactionService.TXN_STORE_DIR, System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
Modified: trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
===================================================================
--- trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-07-17 15:39:12 UTC (rev 1147)
+++ trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-07-17 17:57:05 UTC (rev 1148)
@@ -81,8 +81,7 @@
final List done = new ArrayList();
Properties props = new Properties();
- props.setProperty(TransactionService.VMNAME, "test"); //$NON-NLS-1$
- props.setProperty(TransactionService.HOSTNAME, "test"); //$NON-NLS-1$
+ props.setProperty(TransactionService.PROCESSNAME, "test"); //$NON-NLS-1$
RecoveryConfiguration.setRecoveryManagerPropertiesFile("com/metamatrix/xa/arjuna/jbossjta-properties.xml"); //$NON-NLS-1$
com.arjuna.ats.jta.common.Configuration.setPropertiesFile("com/metamatrix/xa/arjuna/jbossjta-properties.xml"); //$NON-NLS-1$
Configuration.setPropertiesFile("com/metamatrix/xa/arjuna/jbossjta-properties.xml"); //$NON-NLS-1$
16 years, 9 months
Warning: could not send message for past 4 hours
by Mail Delivery Subsystem
**********************************************
** THIS IS A WARNING MESSAGE ONLY **
** YOU DO NOT NEED TO RESEND YOUR MESSAGE **
**********************************************
The original message was received at Fri, 17 Jul 2009 07:08:07 -0400
from svn01.web.mwc.hst.phx2.redhat.com [10.5.105.7]
----- Transcript of session follows -----
<teiid-commits(a)lists.jboss.org>... Deferred: Connection refused by mx1.lists.jboss.org.
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old
16 years, 9 months
teiid SVN: r1147 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-07-17 11:39:12 -0400 (Fri, 17 Jul 2009)
New Revision: 1147
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
Log:
TEIID-350 adding a section about determinism to the reference
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-07-17 14:44:22 UTC (rev 1146)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-07-17 15:39:12 UTC (rev 1147)
@@ -2174,4 +2174,49 @@
query engine to know about and use functions</para>
</sect2>
</sect1>
+ <sect1 id="nondeterministic_functions">
+ <title>Nondeterministic Function Handling</title>
+ <para>Teiid categorizes functions by varying degrees of determinism.
+ When a function is evaluated and to what extent the result can be
+ cached are based upon its determinism level.</para>
+ <orderedlist>
+ <listitem>
+ <para>Deterministic - the function will always return the same result
+ for the given inputs. Deterministic functions are evaluated by the
+ engine as soon as all input values are known, which may occur as soon
+ as the rewrite phase. Some functions, such as the lookup function, are
+ not truly deterministic, but is treated as such for performance. All
+ functions not categorized below are considered deterministic.</para>
+ </listitem>
+ <listitem>
+ <para>Session Deterministic - the function will return the same
+ result for the given inputs under the same user session. This category includes the hasRole,
+ env, and user functions. Session deterministic functions are evaluated
+ by the engine as soon as all input values are known, which may occur as soon
+ as the rewrite phase. If a session deterministic function is evaluated
+ during the creation of a prepared processing plan, then the resulting
+ plan will be cached only for the user's session.</para>
+ </listitem>
+ <listitem>
+ <para>Command Deterministic - the result of function evaluation is
+ only deterministic within the scope of the user command. This category
+ include the curdate, curtime, now, and commandpayload functions.
+ Command deterministic functions are delayed in evaluation until
+ processing to ensure that even prepared plans utilizing these
+ functions will be executed with relevant values. Command deterministic function
+ evaulation will occur prior to pushdown - however multiple occurances
+ of the same command deterministic time function are not guarenteed to
+ evaluate to the same value. </para>
+ </listitem>
+ <listitem>
+ <para>Nondeterministic - the result of function evaluation is fully
+ nondeterministic. This category includes the rand function and UDFs
+ marked as nondeterministic. Nondeterministic functions are delayed in
+ evaluation until processing with a preference for pushdown. If the
+ function is not pushed down, then it may be evaluated for every row in
+ it's execution context (for example if the function is used in the
+ select clause).</para>
+ </listitem>
+ </orderedlist>
+ </sect1>
</chapter>
\ No newline at end of file
16 years, 9 months
teiid SVN: r1146 - in trunk/engine/src: test/java/com/metamatrix/query/optimizer and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-07-17 10:44:22 -0400 (Fri, 17 Jul 2009)
New Revision: 1146
Modified:
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
Log:
TEIID-727 adding a conversion to ensure that the lookup search value matches the type of the key value.
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -825,41 +825,42 @@
Expression[] args = lookup.getArgs();
ResolvedLookup result = new ResolvedLookup();
// Special code to handle setting return type of the lookup function to match the type of the return element
- if( args[0] instanceof Constant && args[1] instanceof Constant && args[2] instanceof Constant) {
- // If code table name in lookup function refers to virtual group, throws exception
- GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
- try {
- groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
- if (groupSym.getMetadataID() instanceof TempMetadataID) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
- }
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
+ if( !(args[0] instanceof Constant) || !(args[1] instanceof Constant) || !(args[2] instanceof Constant)) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
+ }
+ // If code table name in lookup function refers to temp group throw exception
+ GroupSymbol groupSym = new GroupSymbol((String) ((Constant)args[0]).getValue());
+ try {
+ groupSym.setMetadataID(metadata.getGroupID((String) ((Constant)args[0]).getValue()));
+ if (groupSym.getMetadataID() instanceof TempMetadataID) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0065, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0065, ((Constant)args[0]).getValue()));
}
- result.setGroup(groupSym);
-
- List<GroupSymbol> groups = Arrays.asList(groupSym);
-
- String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
- ElementSymbol returnElement = new ElementSymbol(returnElementName);
- try {
- ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
- }
- result.setReturnElement(returnElement);
-
- String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
- ElementSymbol keyElement = new ElementSymbol(keyElementName);
- try {
- ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
- } catch(QueryMetadataException e) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
- }
- result.setKeyElement(keyElement);
- return result;
- }
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0063, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0063));
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, ((Constant)args[0]).getValue()));
+ }
+ result.setGroup(groupSym);
+
+ List<GroupSymbol> groups = Arrays.asList(groupSym);
+
+ String returnElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[1]).getValue(); //$NON-NLS-1$
+ ElementSymbol returnElement = new ElementSymbol(returnElementName);
+ try {
+ ResolverVisitor.resolveLanguageObject(returnElement, groups, metadata);
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, returnElementName));
+ }
+ result.setReturnElement(returnElement);
+
+ String keyElementName = (String) ((Constant)args[0]).getValue() + "." + (String) ((Constant)args[2]).getValue(); //$NON-NLS-1$
+ ElementSymbol keyElement = new ElementSymbol(keyElementName);
+ try {
+ ResolverVisitor.resolveLanguageObject(keyElement, groups, metadata);
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0062, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0062, keyElementName));
+ }
+ result.setKeyElement(keyElement);
+ args[3] = convertExpression(args[3], DataTypeManager.getDataTypeName(keyElement.getType()));
+ return result;
}
private static QueryResolverException handleUnresolvedGroup(GroupSymbol symbol, String description) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -3557,21 +3557,21 @@
});
}
- /** defect 11630 - note that the lookup function is pushed down, it will actually be evaluated before being sent to the connector */
+ /** defect 11630 - note that the lookup function is not pushed down, it will actually be evaluated before being sent to the connector */
public void testLookupFunction() {
- ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 'value') IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1', 'e1', 'e2', 'value') IS NULL" }); //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1', 'e1', 'e2', 1) IS NULL" }); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
}
/** case 5213 - note here that the lookup cannot be pushed down since it is dependent upon an element symbol*/
- public void testLookupFunction2() {
+ public void testLookupFunction2() throws Exception {
- ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e1) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g2" }); //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e2) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e2, g_0.e1 FROM pm1.g2 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
1, // Access
@@ -3594,7 +3594,7 @@
/** defect 21965 */
public void testLookupFunctionInSelect() {
- ProcessorPlan plan = helpPlan("SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 'value') FROM pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan("SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT e1 FROM pm1.g2" }); //$NON-NLS-1$
checkNodeTypes(plan, new int[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -7029,7 +7029,7 @@
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Plan query
- String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 'value') = e1";//$NON-NLS-1$
+ String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) = e1";//$NON-NLS-1$
Command command = TestProcessor.helpParse(sql);
ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
@@ -7041,7 +7041,7 @@
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);
Map valueMap = new HashMap();
- valueMap.put("value", "b"); //$NON-NLS-1$ //$NON-NLS-2$
+ valueMap.put(1, "b"); //$NON-NLS-1$ //$NON-NLS-2$
dataManager.defineCodeTable("pm1.g1", "e2", "e1", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dataManager.setThrowBlocked(true);
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -121,10 +121,26 @@
private Function helpResolveFunction(String sql) throws QueryParserException,
QueryResolverException, MetaMatrixComponentException {
- Function func = (Function)QueryParser.getQueryParser().parseExpression(sql);
- ResolverVisitor.resolveLanguageObject(func, FakeMetadataFactory.example1Cached());
+ Function func = getFunction(sql);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
return func;
}
+
+ private Function getFunction(String sql) throws QueryParserException,
+ MetaMatrixComponentException, QueryResolverException {
+ Function func = (Function)QueryParser.getQueryParser().parseExpression(sql);
+ ResolverVisitor.resolveLanguageObject(func, FakeMetadataFactory.example1Cached());
+ return func;
+ }
+ /**
+ * e1 is of type string, so 1 should be converted to string
+ * @throws Exception
+ */
+ @Test public void testLookupTypeConversion() throws Exception {
+ String sql = "lookup('pm1.g1', 'e2', 'e1', 1)"; //$NON-NLS-1$
+ Function f = getFunction(sql);
+ assertEquals(DataTypeManager.DefaultDataClasses.STRING, f.getArg(3).getType());
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -1458,20 +1458,20 @@
//base test. no change is expected
public void testRewriteLookupFunction1() {
- String criteria = "lookup('pm1.g1','e1', 'e2', 'value') = 'ab'"; //$NON-NLS-1$
+ String criteria = "lookup('pm1.g1','e1', 'e2', 1) = 'ab'"; //$NON-NLS-1$
CompareCriteria expected = (CompareCriteria)parseCriteria(criteria, FakeMetadataFactory.example1Cached());
helpTestRewriteCriteria(criteria, expected, FakeMetadataFactory.example1Cached());
}
public void testRewriteLookupFunction1b() {
- helpTestRewriteCriteria("lookup('pm1.g1','e1', 'e2', pm1.g1.e1) = 'ab'", "lookup('pm1.g1','e1', 'e2', pm1.g1.e1) = 'ab'"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("lookup('pm1.g1','e1', 'e2', pm1.g1.e2) = 'ab'", "lookup('pm1.g1','e1', 'e2', pm1.g1.e2) = 'ab'"); //$NON-NLS-1$ //$NON-NLS-2$
}
/** defect 11630 1 should still get rewritten as '1'*/
public void testRewriteLookupFunctionCompoundCriteria() {
- String criteria = "LOOKUP('pm1.g1','e1', 'e2', 'value') IS NULL AND pm1.g1.e1='1'"; //$NON-NLS-1$
+ String criteria = "LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL AND pm1.g1.e1='1'"; //$NON-NLS-1$
CompoundCriteria expected = (CompoundCriteria)parseCriteria(criteria, FakeMetadataFactory.example1Cached());
- helpTestRewriteCriteria("LOOKUP('pm1.g1','e1', 'e2', 'value') IS NULL AND pm1.g1.e1=1", expected, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ helpTestRewriteCriteria("LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL AND pm1.g1.e1=1", expected, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
}
public void testSelectWithNoFrom() {
@@ -1680,9 +1680,9 @@
}
public void testRewriteSearchedCaseExpr4() {
- String criteria = "lookup('pm1.g1', 'e2', 'e1', null) = 0"; //$NON-NLS-1$
+ String criteria = "lookup('pm1.g1', 'e2', 'e1', '2') = 0"; //$NON-NLS-1$
CompareCriteria expected = (CompareCriteria)parseCriteria(criteria, FakeMetadataFactory.example1Cached());
- helpTestRewriteCriteria("lookup('pm1.g1', 'e2', 'e1', case 0 when 1 then pm1.g1.e1 end) = 0", expected, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ helpTestRewriteCriteria("lookup('pm1.g1', 'e2', 'e1', case 0 when 1 then pm1.g1.e1 else 2 end) = 0", expected, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
}
// First WHEN always false, so remove it
Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-07-17 14:43:11 UTC (rev 1145)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-07-17 14:44:22 UTC (rev 1146)
@@ -1703,7 +1703,7 @@
public void testLookupKeyElementComparable() throws Exception {
QueryMetadataInterface metadata = exampleMetadata2();
- String sql = "SELECT lookup('test.group', 'e2', 'e3', e2) AS x FROM test.group"; //$NON-NLS-1$
+ String sql = "SELECT lookup('test.group', 'e2', 'e3', convert(e2, blob)) AS x FROM test.group"; //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
16 years, 9 months
teiid SVN: r1145 - in trunk/engine/src: test/java/com/metamatrix/query/optimizer/relational and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-07-17 10:43:11 -0400 (Fri, 17 Jul 2009)
New Revision: 1145
Modified:
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
Log:
TEIID-514 update to order by alias generation to not change unrelated output names.
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2009-07-17 11:08:06 UTC (rev 1144)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2009-07-17 14:43:11 UTC (rev 1145)
@@ -330,29 +330,27 @@
for (int i = 0; i < obj.getVariableCount(); i++) {
SingleElementSymbol element = obj.getVariable(i);
String name = visitor.namingContext.getElementName(element, false);
- boolean needsAlias = true;
-
- Expression expr = SymbolMap.getExpression(element);
-
- if (!(expr instanceof SingleElementSymbol)) {
- expr = new ExpressionSymbol(element.getShortName(), expr);
- } else if (expr instanceof ElementSymbol) {
- needsAlias = needsAlias(name, (ElementSymbol)expr);
- }
-
- if (needsAlias) {
- element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
- obj.getVariables().set(i, element);
+ if (name != null) {
+ boolean needsAlias = true;
+
+ Expression expr = SymbolMap.getExpression(element);
+
+ if (!(expr instanceof SingleElementSymbol)) {
+ expr = new ExpressionSymbol(element.getShortName(), expr);
+ } else if (expr instanceof ElementSymbol) {
+ needsAlias = needsAlias(name, (ElementSymbol)expr);
+ }
+
+ if (needsAlias) {
+ element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
+ obj.getVariables().set(i, element);
+ }
+ element.setOutputName(name);
}
- element.setOutputName(name);
- }
-
- super.visit(obj);
-
- //we prefer to use the short name
- for (int i = 0; i < obj.getVariableCount(); i++) {
- SingleElementSymbol element = obj.getVariable(i);
- if (element instanceof ElementSymbol) {
+
+ visitNode(element);
+
+ if (name != null && element instanceof ElementSymbol) {
element.setOutputName(SingleElementSymbol.getShortName(element.getOutputName()));
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-07-17 11:08:06 UTC (rev 1144)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-07-17 14:43:11 UTC (rev 1145)
@@ -22,8 +22,10 @@
package com.metamatrix.query.optimizer.relational;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -36,7 +38,7 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-public class TestAliasGenerator extends TestCase {
+public class TestAliasGenerator {
private Command helpTest(String sql,
String expected,
@@ -52,7 +54,7 @@
/**
* Ensures that views are named with v_ even without metadata
*/
- public void testViewAliasing() throws Exception {
+ @Test public void testViewAliasing() throws Exception {
String sql = "select y.e1 from (select pm1.g1.e1 from pm1.g1) y"; //$NON-NLS-1$
Query command = (Query)QueryParser.getQueryParser().parseCommand(sql);
((ElementSymbol)command.getSelect().getSymbol(0)).setGroupSymbol(new GroupSymbol("y")); //$NON-NLS-1$
@@ -60,13 +62,13 @@
assertEquals("SELECT v_0.c_0 FROM (SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); //$NON-NLS-1$
}
- public void testLongOrderByAlias() throws Exception {
+ @Test public void testLongOrderByAlias() throws Exception {
String sql = "select pm1.g1.e1 || pm1.g1.e2 as asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa, pm1.g1.e2 from pm1.g1 order by asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa"; //$NON-NLS-1$
String expected = "SELECT concat(g_0.e1, g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
}
- public void testOrderBySymbolName() throws Exception {
+ @Test public void testOrderBySymbolName() throws Exception {
String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
Query command = (Query)helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
@@ -74,64 +76,70 @@
assertEquals(((SingleElementSymbol)command.getProjectedSymbols().get(0)).getShortName(), "e1"); //$NON-NLS-1$
}
- public void testInlineViewWithSubQuery() throws Exception {
+ @Test public void testInlineViewWithSubQuery() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb where intnum in (select intnum a from bqt1.smalla)) b"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT g_1.intnum FROM bqt1.smalla AS g_1)) AS v_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testInlineViewOrderBy() throws Exception {
+ @Test public void testInlineViewOrderBy() throws Exception {
String sql = "select intnum from (select intnum from bqt1.smallb) b order by b.intnum"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testNestedInlineViewOrderBy() throws Exception {
+ @Test public void testNestedInlineViewOrderBy() throws Exception {
String sql = "select * from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0) AS v_1 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testInlineViewWithOnClause() throws Exception {
+ @Test public void testInlineViewWithOnClause() throws Exception {
String sql = "select abcd.efg from (select intkey as efg from bqt1.smalla) abcd inner join (select intnum from bqt1.smallb) b on (b.intnum = abcd.efg)"; //$NON-NLS-1$
String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0) AS v_0 INNER JOIN (SELECT g_1.intnum AS c_0 FROM bqt1.smallb AS g_1) AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testUnionOrderBy() throws Exception {
+ @Test public void testUnionOrderBy() throws Exception {
String sql = "select e1, e2 as c_0 from pm1.g1 union all select 1, e1 from pm1.g2 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_1.e1 AS c_0, g_1.e2 AS c_1 FROM pm1.g1 AS g_1 UNION ALL SELECT '1' AS c_0, g_0.e1 AS c_1 FROM pm1.g2 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
}
- public void testDuplicateShortElementName() throws Exception {
+ @Test public void testDuplicateShortElementName() throws Exception {
String sql = "select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 order by pm1.g1.e1, pm1.g2.e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0, g_1.e1 AS c_1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 ORDER BY c_0, c_1"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
}
- public void testCorrelatedRefernce() throws Exception {
+ @Test public void testCorrelatedRefernce() throws Exception {
String sql = "select intnum, stringnum from (select intnum, stringnum from bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT concat(v_0.c_1, v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testCorrelatedRefernce1() throws Exception {
+ @Test public void testCorrelatedRefernce1() throws Exception {
String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT concat(g_0.stringnum, v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
- public void testGroupAliasNotSupported() throws Exception {
+ @Test public void testGroupAliasNotSupported() throws Exception {
String sql = "select b.intkey from bqt1.smalla b"; //$NON-NLS-1$
String expected = "SELECT bqt1.smalla.intkey FROM bqt1.smalla"; //$NON-NLS-1$
helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
}
- public void testUnionAliasing() throws Exception {
+ @Test public void testUnionAliasing() throws Exception {
String sql = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA"; //$NON-NLS-1$
String expected = "SELECT BQT1.SmallA.IntKey AS c_0 FROM BQT1.SmallA UNION ALL SELECT BQT1.SmallA.IntNum AS c_0 FROM BQT1.SmallA"; //$NON-NLS-1$
helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
}
+ @Test public void testUnrelatedOrderBy() throws Exception {
+ String sql = "SELECT b.IntKey FROM BQT1.SmallA a, BQT1.SmallA b ORDER BY a.StringKey"; //$NON-NLS-1$
+ String expected = "SELECT g_1.IntKey AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallA AS g_1 ORDER BY g_0.StringKey"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
}
16 years, 9 months