teiid SVN: r4451 - in trunk/runtime/src: test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-17 12:29:05 -0400 (Mon, 17 Sep 2012)
New Revision: 4451
Modified:
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-2172 fix for invalid session with load balancing
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-09-17 15:38:33 UTC (rev 4450)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2012-09-17 16:29:05 UTC (rev 4451)
@@ -83,8 +83,8 @@
}
private LogonResult logon(Properties connProps, byte[] krb5ServiceTicket) throws LogonException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- String oldSessionId = workContext.getSessionId();
+ //DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ //String oldSessionId = workContext.getSessionId();
String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
// user may be null if using trustedToken to log on
String user = connProps.getProperty(TeiidURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
@@ -101,12 +101,10 @@
if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
sessionInfo.setEmbedded(true);
}
- if (oldSessionId != null) {
- try {
- this.service.closeSession(oldSessionId);
- } catch (InvalidSessionException e) {
- }
- }
+ //if (oldSessionId != null) {
+ //TODO: we should be smarter about disassociating the old sessions from the client. we'll just rely on
+ //ping based clean up
+ //}
LogonResult result = new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
if (krb5ServiceTicket != null) {
result.addProperty(ILogon.KRB5TOKEN, krb5ServiceTicket);
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-17 15:38:33 UTC (rev 4450)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-17 16:29:05 UTC (rev 4451)
@@ -23,7 +23,6 @@
package org.teiid.transport;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
import java.io.ByteArrayInputStream;
import java.io.Serializable;
@@ -35,18 +34,10 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.client.security.ILogon;
-import org.teiid.client.security.InvalidSessionException;
-import org.teiid.client.security.LogonException;
-import org.teiid.client.security.LogonResult;
-import org.teiid.client.security.SessionToken;
-import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.impl.MemoryStorageManager;
-import org.teiid.core.ComponentNotFoundException;
-import org.teiid.core.TeiidComponentException;
import org.teiid.core.crypto.NullCryptor;
import org.teiid.core.util.ObjectConverterUtil;
-import org.teiid.dqp.service.SessionService;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.TeiidURL;
@@ -54,6 +45,7 @@
import org.teiid.net.socket.SocketServerConnectionFactory;
import org.teiid.net.socket.SocketUtil;
import org.teiid.net.socket.UrlServerDiscovery;
+import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.TestSocketRemoting.FakeService;
@@ -64,6 +56,7 @@
private SocketServerConnectionFactory sscf;
private InetSocketAddress addr;
private MemoryStorageManager storageManager;
+ private SessionServiceImpl service;
@Before public void setUp() {
addr = new InetSocketAddress(0);
@@ -165,26 +158,8 @@
return getClass().getClassLoader();
}
};
- server.registerClientService(ILogon.class, new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
- @Override
- public LogonResult logon(Properties connProps)
- throws LogonException, ComponentNotFoundException {
- return new LogonResult(new SessionToken("dummy"), "x", 1, "z");
- }
-
- @Override
- public ResultsFuture<?> ping() throws InvalidSessionException,
- TeiidComponentException {
- return ResultsFuture.NULL_FUTURE;
- }
-
- @Override
- public void assertIdentity(SessionToken checkSession)
- throws InvalidSessionException, TeiidComponentException {
- return;
- }
-
- }, null);
+ service = new SessionServiceImpl();
+ server.registerClientService(ILogon.class, new LogonImpl(service, "fakeCluster"), null);
server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
storageManager = new MemoryStorageManager();
listener = new SocketListener(addr, 1024, 1024, 1, config, server, storageManager);
@@ -199,6 +174,7 @@
Properties p = new Properties();
String url = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure).getAppServerURL();
p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
+ p.setProperty(TeiidURL.CONNECTION.APP_NAME, "test");
p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
if (sscf == null) {
sscf = new SocketServerConnectionFactory();
@@ -254,10 +230,13 @@
assertEquals(2, stats.objectsRead); // handshake response, logon,
assertEquals(1, stats.sockets);
conn.cleanUp();
+ helpEstablishConnection(false, config, p);
+ conn.selectServerInstance(false);
+ assertEquals(2, this.service.getActiveSessions().size());
assertTrue(conn.isOpen(1000));
stats = listener.getStats();
- assertEquals(5, stats.objectsRead); // ping (pool test), assert identity, ping (isOpen)
- assertEquals(1, stats.sockets);
+ assertEquals(7, stats.objectsRead); // ping (pool test), assert identity, ping (isOpen)
+ assertEquals(2, stats.sockets);
conn.close();
}
12 years, 3 months
teiid SVN: r4450 - trunk/jboss-integration/src/main/java/org/teiid/jboss.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-17 11:38:33 -0400 (Mon, 17 Sep 2012)
New Revision: 4450
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
Log:
TEIID-2212 - This was result of non service code and service code and their lifecycles; separated them by responsibilities now.
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-17 11:25:25 UTC (rev 4449)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-17 15:38:33 UTC (rev 4450)
@@ -421,7 +421,7 @@
processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
processorTarget.addDeploymentProcessor(Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES, Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
- processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName, statusChecker, shutdownListener));
+ processorTarget.addDeploymentProcessor(Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName, vdbRepository, shutdownListener));
// translator deployers
processorTarget.addDeploymentProcessor(Phase.STRUCTURE, Phase.STRUCTURE_JDBC_DRIVER|0x0001,new TranslatorStructureDeployer());
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-09-17 11:25:25 UTC (rev 4449)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-09-17 15:38:33 UTC (rev 4450)
@@ -1389,9 +1389,7 @@
synchronized (vdb.getVdb()) {
ReplaceResult rr = vdb.assignDatasource(modelName, sourceName, translatorName, dsName);
if (rr.isNew) {
- ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_STATUS_CHECKER);
- VDBStatusChecker vsc = VDBStatusChecker.class.cast(sc.getValue());
- VDBDeployer.addDataSourceListener(context.getServiceTarget(), new VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName, vsc);
+ VDBDeployer.addDataSourceListener(context.getServiceTarget(), new VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName);
}
if (rr.removedDs != null) {
final ServiceRegistry registry = context.getServiceRegistry(true);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-09-17 11:25:25 UTC (rev 4449)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-09-17 15:38:33 UTC (rev 4450)
@@ -81,13 +81,13 @@
private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
- private VDBStatusChecker vdbStatusChecker;
+ private VDBRepository vdbRepository;
JBossLifeCycleListener shutdownListener;
- public VDBDeployer (TranslatorRepository translatorRepo, String poolName, VDBStatusChecker vdbStatusChecker, JBossLifeCycleListener shutdownListener) {
+ public VDBDeployer (TranslatorRepository translatorRepo, String poolName, VDBRepository vdbRepo, JBossLifeCycleListener shutdownListener) {
this.translatorRepository = translatorRepo;
this.asyncThreadPoolName = poolName;
- this.vdbStatusChecker = vdbStatusChecker;
+ this.vdbRepository = vdbRepo;
this.shutdownListener = shutdownListener;
}
@@ -154,8 +154,7 @@
indexRepo = new IndexMetadataRepository(indexFactory);
visibilityMap = indexFactory.getEntriesPlusVisibilities();
}
- VDBRepository repo = vdbStatusChecker.getVDBRepository();
- repo.addPendingDeployment(deployment);
+ this.vdbRepository.addPendingDeployment(deployment);
// build a VDB service
final VDBService vdb = new VDBService(deployment, visibilityMap);
if (indexRepo != null) {
@@ -255,13 +254,14 @@
static void addDataSourceListener(
final ServiceTarget serviceTarget,
final VDBKey vdbKey,
- final String dsName, VDBStatusChecker vdbStatusChecker) {
+ final String dsName) {
final String jndiName = getJndiName(dsName);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final ServiceName svcName = bindInfo.getBinderServiceName();
- DataSourceListener dsl = new DataSourceListener(dsName, svcName, vdbStatusChecker, vdbKey);
+ DataSourceListener dsl = new DataSourceListener(dsName, svcName, vdbKey);
ServiceBuilder<DataSourceListener> sb = serviceTarget.addService(TeiidServiceNames.dsListenerServiceName(vdbKey.getName(), vdbKey.getVersion(), dsName), dsl);
sb.addDependency(svcName);
+ sb.addDependency(TeiidServiceNames.VDB_STATUS_CHECKER, VDBStatusChecker.class, dsl.vdbStatusCheckInjector);
sb.setInitialMode(Mode.PASSIVE).install();
}
@@ -284,21 +284,20 @@
if (!dataSources.add(VDBStatusChecker.stripContext(dsName))) {
continue; //already listening
}
- addDataSourceListener(serviceTarget, vdbKey, dsName, vdbStatusChecker);
+ addDataSourceListener(serviceTarget, vdbKey, dsName);
}
}
}
static class DataSourceListener implements Service<DataSourceListener>{
- private VDBStatusChecker vdbStatusChecker;
private String dsName;
private ServiceName svcName;
private VDBKey vdb;
+ InjectedValue<VDBStatusChecker> vdbStatusCheckInjector = new InjectedValue<VDBStatusChecker>();
- public DataSourceListener(String dsName, ServiceName svcName, VDBStatusChecker checker, VDBKey vdb) {
+ public DataSourceListener(String dsName, ServiceName svcName, VDBKey vdb) {
this.dsName = dsName;
this.svcName = svcName;
- this.vdbStatusChecker = checker;
this.vdb = vdb;
}
@@ -310,7 +309,7 @@
public void start(StartContext context) throws StartException {
ServiceController<?> s = context.getController().getServiceContainer().getService(this.svcName);
if (s != null) {
- this.vdbStatusChecker.dataSourceAdded(this.dsName, vdb);
+ this.vdbStatusCheckInjector.getValue().dataSourceAdded(this.dsName, vdb);
}
}
@@ -318,7 +317,7 @@
public void stop(StopContext context) {
ServiceController<?> s = context.getController().getServiceContainer().getService(this.svcName);
if (s.getMode().equals(Mode.REMOVE) || s.getState().equals(State.STOPPING)) {
- this.vdbStatusChecker.dataSourceRemoved(this.dsName, vdb);
+ this.vdbStatusCheckInjector.getValue().dataSourceRemoved(this.dsName, vdb);
}
}
}
@@ -348,7 +347,7 @@
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+" metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- this.vdbStatusChecker.getVDBRepository().removeVDB(deployment.getName(), deployment.getVersion());
+ this.vdbRepository.removeVDB(deployment.getName(), deployment.getVersion());
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
for (SourceMappingMetadata smm:model.getSources().values()) {
12 years, 3 months
teiid SVN: r4449 - in trunk: build/kits/jboss-as7/docs/teiid and 14 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-17 07:25:25 -0400 (Mon, 17 Sep 2012)
New Revision: 4449
Modified:
trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli
trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
trunk/engine/pom.xml
trunk/engine/src/main/java/org/teiid/cache/Cache.java
trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/test/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheFactoryService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCache.java
trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCacheFactory.java
trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
trunk/runtime/src/main/resources/infinispan-config.xml
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestTransactions.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
trunk/test-integration/common/src/test/resources/infinispan-replicated-config.xml
Log:
TEIID-2086 ensuring that rs cache access is transactionally consistent
Modified: trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli
===================================================================
--- trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/build/kits/jboss-as7/bin/scripts/teiid-domain-mode-install.cli 2012-09-17 11:25:25 UTC (rev 4449)
@@ -10,17 +10,19 @@
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/replicated-cache=resultset-repl:add(mode=SYNC, batching=true)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/replicated-cache=resultset-repl/locking=LOCKING:add(isolation=READ_COMMITTED)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/replicated-cache=resultset-repl/expiration=EXPIRATION:add(lifespan=7200000)
-/profile=ha/subsystem=infinispan/cache-container=teiid-cache/replicated-cache=resultset-repl/eviction=EVICTION:add(max-entries=1024, strategy=LRU)
+/profile=ha/subsystem=infinispan/cache-container=teiid-cache/replicated-cache=resultset-repl/eviction=EVICTION:add(max-entries=1024, strategy=LIRS)
+/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/transaction=TRANSACTION:add(mode=NON_XA)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset:add(mode=SYNC, batching=true)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/locking=LOCKING:add(isolation=READ_COMMITTED)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/expiration=EXPIRATION:add(lifespan=7200000)
-/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/eviction=EVICTION:add(max-entries=1024, strategy=LRU)
+/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/eviction=EVICTION:add(max-entries=1024, strategy=LIRS)
+/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=resultset/transaction=TRANSACTION:add(mode=NON_XA)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=preparedplan:add(mode=SYNC, batching=true)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=preparedplan/locking=LOCKING:add(isolation=READ_COMMITTED)
/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=preparedplan/expiration=EXPIRATION:add(lifespan=28800)
-/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=preparedplan/eviction=EVICTION:add(max-entries=512, strategy=LRU)
+/profile=ha/subsystem=infinispan/cache-container=teiid-cache/local-cache=preparedplan/eviction=EVICTION:add(max-entries=512, strategy=LIRS)
/profile=ha/subsystem=security/security-domain=teiid-security:add(cache-type=default)
/profile=ha/subsystem=security/security-domain=teiid-security/authentication=classic:add(login-modules=[{"code"=>"org.jboss.security.auth.spi.UsersRolesLoginModule", "flag"=>"required", "module-options"=>[("usersProperties"=>"${jboss.domain.config.dir}/teiid-security-users.properties"), ("rolesProperties"=>"${jboss.domain.config.dir}/teiid-security-roles.properties")]}])
Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html 2012-09-17 11:25:25 UTC (rev 4449)
@@ -36,6 +36,7 @@
<li>TEIID-2195 <b>Function Based Indexes</b> - DDL can be used to specify function based indexes. When used on an internal mat view it will create
the corresponding function based index automatically. In any other circumstance, the metadata is not currently used.
<li>TEIID-2181 <b>System query performance</b> - system queries are now indexed on case-insensitive schema/table name columns.
+ <li>TEIID-2086 <b>Transactional results caching</b> - the result set cache is now transactional by default.
</ul>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -163,7 +164,8 @@
<h4>from 8.1</h4>
<ul>
- <li>The file translator now defaults to exceptionIfFileNotFound=true, you can set the translator property to false to preserve the old behavior of returning null.
+ <li>The file translator now defaults to exceptionIfFileNotFound=true, you can set the translator property to false to preserve the old behavior of returning null.
+ <li>TEIID-2086 TEIID-2168 prepared plan and result set caches are now configured as infinispan caches. See the teiid cache container in the configuration. You may also control the transactional aspects of the result set cache on the resultset and resultset-repl caches via the configuration.
</ul>
<h4>from 8.0</h4>
Modified: trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2012-09-17 11:25:25 UTC (rev 4449)
@@ -170,10 +170,12 @@
</cache-container>
<cache-container name="teiid" default-cache="resultset">
<local-cache name="resultset">
+ <transaction mode="NON_XA"/>
<expiration lifespan="7200000" />
<eviction max-entries="1024" strategy="LIRS"/>
</local-cache>
<local-cache name="resultset-repl">
+ <transaction mode="NON_XA"/>
<expiration lifespan="7200000" />
<eviction max-entries="1024" strategy="LIRS"/>
</local-cache>
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/pom.xml 2012-09-17 11:25:25 UTC (rev 4449)
@@ -98,22 +98,6 @@
<artifactId>xom</artifactId>
<version>1.2</version>
</dependency>
- <dependency>
- <groupId>org.infinispan</groupId>
- <artifactId>infinispan-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.marshalling</groupId>
- <artifactId>jboss-marshalling-river</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.marshalling</groupId>
- <artifactId>jboss-marshalling</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
Modified: trunk/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -81,5 +81,12 @@
* Return all the keys
* @return
*/
- Set<K> keys();
+ Set<K> keySet();
+
+ /**
+ * If the cache is transactional
+ * @return
+ */
+ boolean isTransactional();
+
}
Modified: trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -36,9 +36,4 @@
*/
void destroy();
- /**
- * Return true if replicated caches are created by this factory
- * @return
- */
- boolean isReplicated();
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AccessInfo.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -54,18 +54,13 @@
private boolean sensitiveToMetadataChanges = true;
private List<List<String>> externalNames;
- private transient long creationTime = System.currentTimeMillis();
+ private long creationTime = System.currentTimeMillis();
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
externalNames = initExternalList(externalNames, objectsAccessed);
out.defaultWriteObject();
}
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
- in.defaultReadObject();
- this.creationTime = System.currentTimeMillis();
- }
-
public boolean isSensitiveToMetadataChanges() {
return sensitiveToMetadataChanges;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -336,14 +336,24 @@
}
private void createProcessor() throws TeiidComponentException {
+ this.context.setTransactionContext(getTransactionContext(true));
+ this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
+ this.processor.setContinuous(this.requestMsg.getRequestOptions().isContinuous());
+ }
+
+ TransactionContext getTransactionContext(boolean startAutoWrap) throws TeiidComponentException {
+ if (this.transactionContext != null) {
+ return this.transactionContext;
+ }
+ TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId());
- TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId());
-
Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
// If local or global transaction is not started.
- if (tc.getTransactionType() == Scope.NONE) {
-
+ if (tc.getTransactionType() == Scope.NONE && !requestMsg.isNoExec()) {
+ if (!startAutoWrap) {
+ return null;
+ }
boolean startAutoWrapTxn = false;
if(RequestMessage.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
@@ -365,10 +375,8 @@
tc.setIsolationLevel(requestMsg.getTransactionIsolation());
this.transactionContext = tc;
- this.context.setTransactionContext(tc);
- this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
- this.processor.setContinuous(this.requestMsg.getRequestOptions().isContinuous());
- }
+ return this.transactionContext;
+ }
/**
* state side effects:
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -510,6 +510,14 @@
cacheId = new CacheID(this.dqpWorkContext, pi, requestMsg.getCommandString());
cachable = cacheId.setParameters(requestMsg.getParameterValues());
if (cachable) {
+ //allow cache to be transactionally aware
+ if (rsCache.isTransactional()) {
+ TransactionContext tc = request.getTransactionContext(false);
+ if (tc != null && tc.getTransactionType() != Scope.NONE) {
+ initTransactionState(tc);
+ resume();
+ }
+ }
CachedResults cr = rsCache.get(cacheId);
//check that there are enough cached results
//TODO: possibly ignore max rows for caching
@@ -587,13 +595,7 @@
//This is just a dummy result it will get replaced by collector source
resultsBuffer = this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(), this.request.context.getConnectionId(), TupleSourceType.FINAL);
}
- transactionContext = request.transactionContext;
- if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
- if (this.requestMsg.getRequestOptions().isContinuous()) {
- throw new IllegalStateException("Continuous requests are not allowed to be transactional."); //$NON-NLS-1$
- }
- this.transactionState = TransactionState.ACTIVE;
- }
+ initTransactionState(request.transactionContext);
if (requestMsg.isNoExec()) {
doneProducingBatches();
resultsBuffer.close();
@@ -606,6 +608,16 @@
request = null;
}
+ private void initTransactionState(TransactionContext tc) {
+ transactionContext = tc;
+ if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
+ if (this.requestMsg.getRequestOptions().isContinuous()) {
+ throw new IllegalStateException("Continuous requests are not allowed to be transactional."); //$NON-NLS-1$
+ }
+ this.transactionState = TransactionState.ACTIVE;
+ }
+ }
+
private CacheHint getCacheHint() {
if (requestMsg.getCommand() != null) {
return ((Command)requestMsg.getCommand()).getCacheHint();
@@ -942,7 +954,6 @@
return transactionContext;
}
-
Collection<DataTierTupleSource> getConnectorRequests() {
synchronized (this.connectorInfo) {
return new ArrayList<DataTierTupleSource>(this.connectorInfo.values());
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -48,6 +48,7 @@
* This class is used to cache session aware objects
*/
public class SessionAwareCache<T> {
+ public static final String REPL = "-repl"; //$NON-NLS-1$
public static final int DEFAULT_MAX_SIZE_TOTAL = 512;
public enum Type {
RESULTSET,
@@ -75,7 +76,7 @@
this.distributedCache = localCache;
}
else {
- this.distributedCache = cacheFactory.get(cacheName+"-repl"); //$NON-NLS-1$
+ this.distributedCache = cacheFactory.get(cacheName+REPL);
if (this.distributedCache == null && this.localCache != null) {
this.distributedCache = this.localCache;
}
@@ -204,7 +205,7 @@
}
private void clearCache(Cache<CacheID, T> cache, String vdbName, int version) {
- Set<CacheID> keys = cache.keys();
+ Set<CacheID> keys = cache.keySet();
VDBKey vdbKey = new VDBKey(vdbName, version);
for (CacheID key:keys) {
if (key.vdbInfo.equals(vdbKey)) {
@@ -323,4 +324,8 @@
public static boolean isResultsetCache(String cacheType) {
return (Admin.Cache.valueOf(cacheType) == Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE);
}
+
+ public boolean isTransactional() {
+ return this.localCache.isTransactional() || this.distributedCache.isTransactional();
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cache/DefaultCacheFactory.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/test/java/org/teiid/cache/DefaultCacheFactory.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -22,19 +22,15 @@
package org.teiid.cache;
import java.io.Serializable;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import org.infinispan.configuration.cache.Configuration;
-import org.infinispan.configuration.cache.ConfigurationBuilder;
-import org.infinispan.eviction.EvictionStrategy;
-import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.manager.EmbeddedCacheManager;
import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.LRUCache;
import org.teiid.query.QueryPlugin;
-@SuppressWarnings("nls")
+/**
+ * Provides a non-thread safe simple map backed cache suitable for testing
+ */
public class DefaultCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -5541424157695857527L;
private static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100, "default"); // 1 hours with 100 nodes. //$NON-NLS-1$
@@ -42,98 +38,48 @@
public static DefaultCacheFactory INSTANCE = new DefaultCacheFactory(DEFAULT);
private volatile boolean destroyed = false;
- EmbeddedCacheManager manager;
-
+ private CacheConfiguration config;
public DefaultCacheFactory(CacheConfiguration config) {
- Configuration cacheConfig = new ConfigurationBuilder().eviction()
- .strategy(config.getPolicy()==Policy.LRU?EvictionStrategy.LRU:EvictionStrategy.NONE)
- .maxEntries(config.getMaxEntries())
- .expiration().lifespan(config.getMaxAgeInSeconds()*1000)
- .wakeUpInterval(200)
- .build();
- this.manager = new DefaultCacheManager(cacheConfig);
- this.manager.start();
- this.manager.defineConfiguration("resultset", cacheConfig);
- this.manager.defineConfiguration("resultset-repl", cacheConfig);
- this.manager.defineConfiguration("preparedplan", cacheConfig);
- this.manager.getCache("resultset");
- this.manager.getCache("preparedplan");
- this.manager.getCache("resultset-repl");
+ this.config = config;
}
@Override
public void destroy() {
this.destroyed = true;
- if (this.manager != null) {
- this.manager.stop();
- }
}
@Override
public <K, V> Cache<K, V> get(String cacheName) {
if (!destroyed) {
- manager.getCache(cacheName).clear();
- return new IspnCache(manager.getCache(cacheName), cacheName, getClass().getClassLoader());
+ return new MockCache<K, V>(cacheName, config.getMaxEntries());
}
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30562, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30562));
}
- @Override
- public boolean isReplicated() {
- return false;
- }
-
-
- private static class IspnCache<K, V> implements Cache<K, V> {
+ @SuppressWarnings("serial")
+ private static class MockCache<K, V> extends LRUCache<K, V> implements Cache<K, V> {
- protected org.infinispan.AdvancedCache<K, V> cacheStore;
- private final String name;
- private ClassLoader classloader;
+ private String name;
- public IspnCache(org.infinispan.Cache<K, V> cacheStore, String cacheName, ClassLoader classloader) {
- assert(cacheStore != null);
- this.cacheStore = cacheStore.getAdvancedCache();
+ public MockCache(String cacheName, int maxSize) {
+ super(maxSize<0?Integer.MAX_VALUE:maxSize);
this.name = cacheName;
- this.classloader = classloader;
}
@Override
- public V get(K key) {
- return this.cacheStore.with(this.classloader).get(key);
- }
-
- @Override
public V put(K key, V value, Long ttl) {
- if (ttl != null) {
- return this.cacheStore.with(this.classloader).put(key, value, ttl, TimeUnit.MILLISECONDS);
- }
- return this.cacheStore.with(this.classloader).put(key, value);
+ return put(key, value);
}
@Override
- public V remove(K key) {
- return this.cacheStore.with(this.classloader).remove(key);
- }
-
- @Override
- public int size() {
- return this.cacheStore.with(this.classloader).size();
- }
-
- @Override
- public void clear() {
- this.cacheStore.with(this.classloader).clear();
- }
-
- @Override
public String getName() {
return this.name;
}
@Override
- public Set<K> keys() {
- return this.cacheStore.with(this.classloader).keySet();
+ public boolean isTransactional() {
+ return false;
}
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -30,7 +30,6 @@
import org.junit.Test;
import org.teiid.api.exception.query.QueryParserException;
import org.teiid.cache.CacheConfiguration;
-import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.cache.DefaultCacheFactory;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.metadata.FunctionMethod.Determinism;
@@ -101,56 +100,11 @@
assertNull("Unable to get prepared plan from cache for token2", cache.get(new CacheID(token2, pi, EXAMPLE_QUERY + 1))); //$NON-NLS-1$
}
- @Test public void testMaxSize() throws Exception {
- CacheConfiguration config = new CacheConfiguration();
- config.setType(Policy.LRU.name());
- config.setMaxEntries(100);
- config.setMaxAgeInSeconds(60);
- SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0);
-
- helpPutPreparedPlans(cache, token, 0, 101);
- assertTrue(cache.getTotalCacheEntries() <= 100);
-
- // find a entry that has not been evicted.
- int i = 0;
- while (true) {
- PreparedPlan plan = cache.get(new CacheID(token, pi, EXAMPLE_QUERY + i));
- if (plan != null) {
- break;
- }
- i++;
- if (i > 100) break;
- }
- assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + i)));
-
- helpPutPreparedPlans(cache, token, 102, 50);
-
- //"sql12" should still be there based on lru policy
- assertNotNull(cache.get(new CacheID(token, pi, EXAMPLE_QUERY + i)));
-
- helpPutPreparedPlans(cache, token2, 0, 121);
- helpPutPreparedPlans(cache, token, 0, 50);
- assertTrue(cache.getTotalCacheEntries() <= 100);
- }
-
- @Test public void testZeroSizeCache() throws Exception {
- CacheConfiguration config = new CacheConfiguration();
- config.setMaxEntries(0);
- config.setType(Policy.LRU.name());
-
- try {
- // Create with 0 size cache
- SessionAwareCache<PreparedPlan> cache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0);
- fail("should have failed to create zero sized cache store");
- } catch (Exception e) {
- }
- }
-
// set init size to negative number, which should default to max
@Test public void testNegativeSizeCacheUsesDefault() {
CacheConfiguration config = new CacheConfiguration();
config.setMaxEntries(-1);
- SessionAwareCache<PreparedPlan> negativeSizedCache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0);
+ new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(config), SessionAwareCache.Type.PREPAREDPLAN, 0);
// -1 means unlimited in the infinispan
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheFactoryService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheFactoryService.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheFactoryService.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -21,7 +21,7 @@
*/
package org.teiid.jboss;
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
import org.jboss.modules.Module;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
@@ -32,12 +32,12 @@
import org.teiid.cache.infinispan.InfinispanCacheFactory;
class CacheFactoryService implements Service<CacheFactory> {
- protected InjectedValue<CacheContainer> cacheContainerInjector = new InjectedValue<CacheContainer>();
+ protected InjectedValue<EmbeddedCacheManager> cacheContainerInjector = new InjectedValue<EmbeddedCacheManager>();
private CacheFactory cacheFactory;
@Override
public void start(StartContext context) throws StartException {
- CacheContainer cc = cacheContainerInjector.getValue();
+ EmbeddedCacheManager cc = cacheContainerInjector.getValue();
if (cc != null) {
this.cacheFactory = new InfinispanCacheFactory(cc, Module.getCallerModule().getClassLoader());
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheService.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/CacheService.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -29,6 +29,7 @@
import org.teiid.cache.CacheFactory;
import org.teiid.common.buffer.TupleBufferCache;
import org.teiid.dqp.internal.process.SessionAwareCache;
+import org.teiid.dqp.internal.process.SessionAwareCache.Type;
class CacheService<T> implements Service<SessionAwareCache<T>> {
@@ -49,7 +50,9 @@
@Override
public void start(StartContext context) throws StartException {
this.cache = new SessionAwareCache<T>(this.cacheName, cacheFactoryInjector.getValue(), this.type, this.maxStaleness);
- this.cache.setTupleBufferCache(this.tupleBufferCacheInjector.getValue());
+ if (type == Type.RESULTSET) {
+ this.cache.setTupleBufferCache(this.tupleBufferCacheInjector.getValue());
+ }
}
@Override
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -22,10 +22,7 @@
package org.teiid.jboss;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
import java.util.Iterator;
import java.util.List;
@@ -38,15 +35,15 @@
import javax.resource.spi.work.WorkManager;
import javax.transaction.TransactionManager;
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
import org.jboss.as.clustering.jgroups.ChannelFactory;
import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.DescriptionProvider;
-import org.jboss.as.controller.registry.AttributeAccess.Storage;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.as.controller.registry.AttributeAccess.Storage;
import org.jboss.as.controller.services.path.RelativePathService;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ServiceBasedNamingStore;
@@ -61,12 +58,12 @@
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.ServiceBuilder;
-import org.jboss.msc.service.ServiceBuilder.DependencyType;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.service.ValueService;
+import org.jboss.msc.service.ServiceBuilder.DependencyType;
import org.jboss.msc.value.InjectedValue;
import org.teiid.PolicyDecider;
import org.teiid.cache.CacheFactory;
@@ -321,7 +318,7 @@
ServiceBuilder<CacheFactory> cacheFactoryBuilder = target.addService(cfName, cfs);
String ispnName = Element.RSC_CONTAINER_NAME_ELEMENT.asString(operation);
- cacheFactoryBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName), CacheContainer.class, cfs.cacheContainerInjector); //$NON-NLS-1$
+ cacheFactoryBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName), EmbeddedCacheManager.class, cfs.cacheContainerInjector); //$NON-NLS-1$
newControllers.add(cacheFactoryBuilder.install());
int maxStaleness = 60;
@@ -333,6 +330,8 @@
ServiceBuilder<SessionAwareCache<CachedResults>> resultsCacheBuilder = target.addService(TeiidServiceNames.CACHE_RESULTSET, resultSetService);
resultsCacheBuilder.addDependency(TeiidServiceNames.TUPLE_BUFFER, TupleBufferCache.class, resultSetService.tupleBufferCacheInjector);
resultsCacheBuilder.addDependency(cfName, CacheFactory.class, resultSetService.cacheFactoryInjector);
+ resultsCacheBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName, cacheName)); //$NON-NLS-1$
+ resultsCacheBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName, cacheName + SessionAwareCache.REPL)); //$NON-NLS-1$
newControllers.add(resultsCacheBuilder.install());
}
@@ -357,13 +356,13 @@
ServiceBuilder<CacheFactory> cacheFactoryBuilder = target.addService(cfName, cfs);
String ispnName = Element.PPC_CONTAINER_NAME_ELEMENT.asString(operation);
- cacheFactoryBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName), CacheContainer.class, cfs.cacheContainerInjector); //$NON-NLS-1$
- newControllers.add(cacheFactoryBuilder.install());
+ cacheFactoryBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName), EmbeddedCacheManager.class, cfs.cacheContainerInjector); //$NON-NLS-1$
+ newControllers.add(cacheFactoryBuilder.install());
CacheService<PreparedPlan> preparedPlanService = new CacheService<PreparedPlan>(cacheName, SessionAwareCache.Type.PREPAREDPLAN, 0);
ServiceBuilder<SessionAwareCache<PreparedPlan>> preparedPlanCacheBuilder = target.addService(TeiidServiceNames.CACHE_PREPAREDPLAN, preparedPlanService);
- preparedPlanCacheBuilder.addDependency(TeiidServiceNames.TUPLE_BUFFER, TupleBufferCache.class, preparedPlanService.tupleBufferCacheInjector);
preparedPlanCacheBuilder.addDependency(cfName, CacheFactory.class, preparedPlanService.cacheFactoryInjector);
+ preparedPlanCacheBuilder.addDependency(ServiceName.JBOSS.append("infinispan", ispnName, cacheName)); //$NON-NLS-1$
newControllers.add(preparedPlanCacheBuilder.install());
}
Modified: trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCache.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCache.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCache.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -25,7 +25,10 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.infinispan.transaction.TransactionMode;
import org.teiid.cache.Cache;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
/**
@@ -36,15 +39,24 @@
protected org.infinispan.AdvancedCache<K, V> cacheStore;
private final String name;
private ClassLoader classloader;
+ private boolean transactional;
public InfinispanCache(org.infinispan.Cache<K, V> cacheStore, String cacheName, ClassLoader classloader) {
assert(cacheStore != null);
this.cacheStore = cacheStore.getAdvancedCache();
+ TransactionMode transactionMode = this.cacheStore.getCacheConfiguration().transaction().transactionMode();
+ this.transactional = transactionMode == TransactionMode.TRANSACTIONAL;
+ LogManager.logDetail(LogConstants.CTX_RUNTIME, "Added", transactionMode, "infinispan cache", cacheName); //$NON-NLS-1$ //$NON-NLS-2$
this.name = cacheName;
this.classloader = classloader;
}
@Override
+ public boolean isTransactional() {
+ return transactional;
+ }
+
+ @Override
public V get(K key) {
return this.cacheStore.with(this.classloader).get(key);
}
@@ -82,7 +94,7 @@
}
@Override
- public Set<K> keys() {
+ public Set<K> keySet() {
return this.cacheStore.with(this.classloader).keySet();
}
}
Modified: trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCacheFactory.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCacheFactory.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/runtime/src/main/java/org/teiid/cache/infinispan/InfinispanCacheFactory.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -24,30 +24,30 @@
import java.io.Serializable;
-import org.infinispan.manager.CacheContainer;
+import org.infinispan.manager.EmbeddedCacheManager;
import org.teiid.cache.Cache;
import org.teiid.cache.CacheFactory;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.runtime.RuntimePlugin;
-
public class InfinispanCacheFactory implements CacheFactory, Serializable{
private static final long serialVersionUID = -2767452034178675653L;
- private transient org.infinispan.manager.CacheContainer cacheStore;
+ private transient EmbeddedCacheManager cacheStore;
private volatile boolean destroyed = false;
private ClassLoader classLoader;
-
- public InfinispanCacheFactory(CacheContainer cm, ClassLoader classLoader) {
+ public InfinispanCacheFactory(EmbeddedCacheManager cm, ClassLoader classLoader) {
this.cacheStore = cm;
this.classLoader = classLoader;
}
- public Cache get(String cacheName) {
+ @SuppressWarnings("unchecked")
+ @Override
+ public <K, V> Cache<K, V> get(String cacheName) {
if (!destroyed) {
- org.infinispan.Cache cache = this.cacheStore.getCache(cacheName);
+ org.infinispan.Cache cache = this.cacheStore.getCache(cacheName, false);
if (cache != null) {
- return new InfinispanCache(cache, cacheName, this.classLoader);
+ return new InfinispanCache<K, V>(cache, cacheName, this.classLoader);
}
return null;
}
@@ -62,8 +62,4 @@
destroy();
}
- @Override
- public boolean isReplicated() {
- return true;
- }
}
Modified: trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/runtime/src/main/java/org/teiid/runtime/EmbeddedConfiguration.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -49,6 +49,7 @@
private String bufferDirectory;
private CacheFactory cacheFactory;
private int maxResultSetCacheStaleness = 60;
+ private String infinispanConfigFile = "infinispan-config.xml"; //$NON-NLS-1$
public SecurityHelper getSecurityHelper() {
return securityHelper;
@@ -121,10 +122,19 @@
return this.bufferDirectory;
}
+ public String getInfinispanConfigFile() {
+ return infinispanConfigFile;
+ }
+
+ public void setInfinispanConfigFile(String infinispanConfigFile) {
+ this.infinispanConfigFile = infinispanConfigFile;
+ }
+
public CacheFactory getCacheFactory() {
if (this.cacheFactory == null) {
try {
- DefaultCacheManager manager = new DefaultCacheManager("infinispan-config.xml"); //$NON-NLS-1$
+ DefaultCacheManager manager = new DefaultCacheManager(this.infinispanConfigFile, true);
+ manager.startCaches(manager.getCacheNames().toArray(new String[manager.getCacheNames().size()]));
this.cacheFactory = new InfinispanCacheFactory(manager, this.getClass().getClassLoader());
} catch (IOException e) {
throw new TeiidRuntimeException(RuntimePlugin.Event.TEIID40100, e);
Modified: trunk/runtime/src/main/resources/infinispan-config.xml
===================================================================
--- trunk/runtime/src/main/resources/infinispan-config.xml 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/runtime/src/main/resources/infinispan-config.xml 2012-09-17 11:25:25 UTC (rev 4449)
@@ -30,12 +30,14 @@
<global/>
<namedCache name="resultset">
+ <transaction transactionMode="TRANSACTIONAL"/>
<eviction maxEntries="1024" strategy="LIRS" />
<expiration lifespan="7200000" />
<clustering mode="local"/>
</namedCache>
<namedCache name="resultset-repl">
+ <transaction transactionMode="TRANSACTIONAL"/>
<eviction maxEntries="1024" strategy="LIRS" />
<expiration lifespan="7200000" />
<clustering mode="local"/>
Modified: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -360,6 +360,11 @@
assertEquals(1, tm.txnHistory.size());
txn = tm.txnHistory.remove(0);
Mockito.verify(txn).commit();
+
+ s.execute("set autoCommitTxn on");
+ s.execute("set noexec on");
+ s.execute("select 1");
+ assertFalse(s.getResultSet().next());
}
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestTransactions.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestTransactions.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestTransactions.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -74,6 +74,34 @@
execute("rollback");
execute("select * from temp");
assertRowCount(0);
+
+ execute("select rand(1)"); //TODO - I think our rand function doesn't make sense
+ this.internalConnection.setAutoCommit(false);
+
+ execute("/*+ cache */ select rand()");
+ internalResultSet.next();
+ double d = internalResultSet.getDouble(1);
+
+ execute("select rand(2)");
+ execute("/*+ cache */ select rand()");
+ internalResultSet.next();
+ double d1 = internalResultSet.getDouble(1);
+ assertEquals("Expected same in the txn", d, d1, 0);
+
+ this.internalConnection.rollback();
+ this.internalConnection.setAutoCommit(true);
+
+ execute("select rand(3)");
+ execute("/*+ cache */ select rand()");
+ internalResultSet.next();
+ double d2 = internalResultSet.getDouble(1);
+ assertTrue("Expected different after rollback", d != d2);
+
+ execute("select rand(4)");
+ execute("/*+ cache */ select rand()");
+ internalResultSet.next();
+ d = internalResultSet.getDouble(1);
+ assertEquals("Expected same after autoCommit", d, d2, 0);
}
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-09-17 11:25:25 UTC (rev 4449)
@@ -31,14 +31,12 @@
import java.util.Collection;
import java.util.HashMap;
-import org.infinispan.manager.DefaultCacheManager;
import org.jboss.as.clustering.jgroups.ChannelFactory;
import org.jboss.as.server.ServerEnvironment;
import org.jgroups.Channel;
import org.jgroups.JChannel;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.cache.infinispan.InfinispanCacheFactory;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer;
@@ -146,8 +144,7 @@
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setObjectReplicator(jor);
- DefaultCacheManager manager = new DefaultCacheManager(UnitTestUtil.getTestDataPath()+"/infinispan-replicated-config.xml");
- config.setCacheFactory(new InfinispanCacheFactory(manager, this.getClass().getClassLoader()));
+ config.setInfinispanConfigFile(UnitTestUtil.getTestDataPath()+"/infinispan-replicated-config.xml");
server.start(config, true);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
Modified: trunk/test-integration/common/src/test/resources/infinispan-replicated-config.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/infinispan-replicated-config.xml 2012-09-14 17:24:07 UTC (rev 4448)
+++ trunk/test-integration/common/src/test/resources/infinispan-replicated-config.xml 2012-09-17 11:25:25 UTC (rev 4449)
@@ -11,15 +11,17 @@
</global>
<namedCache name="resultset">
+ <transaction transactionMode="TRANSACTIONAL"/>
<eviction maxEntries="1024" strategy="LIRS" />
<expiration lifespan="7200000"/>
<clustering mode="local"/>
</namedCache>
<namedCache name="resultset-repl">
+ <transaction transactionMode="TRANSACTIONAL"/>
<eviction maxEntries="1024" strategy="LIRS" />
<expiration lifespan="7200000"/>
- <clustering mode="replication">
+ <clustering mode="repl">
<sync/>
</clustering>
</namedCache>
12 years, 3 months
teiid SVN: r4448 - trunk/engine/src/test/java/org/teiid/query/processor.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-14 13:24:07 -0400 (Fri, 14 Sep 2012)
New Revision: 4448
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java
Log:
TEIID-2188 expanding to execute the function method
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java 2012-09-14 17:19:05 UTC (rev 4447)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java 2012-09-14 17:24:07 UTC (rev 4448)
@@ -159,8 +159,11 @@
//cannot pushdown
caps.setFunctionSupport(SourceSystemFunctions.CONCAT2, false);
- helpPlan(sql, metadata, null, capFinder,
+ ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder,
new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT g_0.e1 FROM pm1.g1 AS g_0", new List[] {Arrays.asList("a"), Arrays.asList((String)null)});
+ TestProcessor.helpProcess(plan, dataManager, new List[] {Arrays.asList("aa"), Arrays.asList((String)null)});
caps.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
caps.setFunctionSupport(SourceSystemFunctions.IFNULL, true);
12 years, 3 months
teiid SVN: r4447 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-14 13:19:05 -0400 (Fri, 14 Sep 2012)
New Revision: 4447
Modified:
trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java
trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-2188 adding support for CONCAT2 pushdown
Modified: trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -44,6 +44,7 @@
public static final String ASCII = "ascii"; //$NON-NLS-1$
public static final String CHAR = "char"; //$NON-NLS-1$
public static final String CONCAT = "concat"; //$NON-NLS-1$
+ public static final String CONCAT2 = "concat2"; //$NON-NLS-1$
//public static final String DIFFERENCE = "difference";
public static final String INITCAP = "initcap"; //$NON-NLS-1$
public static final String INSERT = "insert"; //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -126,6 +126,7 @@
registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.CONCAT2, new AliasModifier("||")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
@Override
public List<?> translate(Function function) {
@@ -589,6 +590,7 @@
supportedFunctions.add("CHAR"); //$NON-NLS-1$
supportedFunctions.add("CHR"); //$NON-NLS-1$
supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.CONCAT2);
supportedFunctions.add("||"); //$NON-NLS-1$
supportedFunctions.add("INITCAP"); //$NON-NLS-1$
supportedFunctions.add("LCASE"); //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -441,5 +441,12 @@
input,
output, TRANSLATOR);
}
+
+ @Test public void testConcat2() {
+ helpTestVisitor(getTestVDB(),
+ "select part_name from parts where concat2(part_name, 'x') = concat2(part_weight, part_id)", //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE concat(ifnull(PARTS.PART_NAME, ''), 'x') = CASE WHEN PARTS.PART_WEIGHT IS NULL AND PARTS.PART_ID IS NULL THEN NULL ELSE concat(ifnull(PARTS.PART_WEIGHT, ''), ifnull(PARTS.PART_ID, '')) END", //$NON-NLS-1$
+ true);
+ }
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -98,7 +98,7 @@
@Test
public void testConcat2() throws Exception {
String input = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, '')) END FROM SmallA"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN SmallA.StringNum IS NULL AND SmallA.StringNum IS NULL THEN NULL ELSE concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, '')) END FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
input,
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -67,7 +67,7 @@
@Test
public void testConcat2() throws Exception {
String input = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE {fn concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, ''))} END FROM SmallA"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN SmallA.StringNum IS NULL AND SmallA.StringNum IS NULL THEN NULL ELSE {fn concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, ''))} END FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -380,18 +380,22 @@
@Test public void testConcat2_useLiteral() throws Exception {
String input = "select concat2(stringnum,'_xx') from bqt1.Smalla"; //$NON-NLS-1$
- String output = "SELECT concat(nvl(SmallA.StringNum, ''), '_xx') FROM SmallA"; //$NON-NLS-1$
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, UDF,
- input, output,
- TRANSLATOR);
+ String output = "SELECT (g_0.StringNum || '_xx') FROM SmallA g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ commandBuilder.getLanguageBridgeFactory().setSupportsConcat2(true);
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, TRANSLATOR, obj);
}
@Test public void testConcat2() throws Exception {
String input = "select concat2(stringnum, stringkey) from bqt1.Smalla"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN SmallA.StringNum IS NULL AND SmallA.StringKey IS NULL THEN NULL ELSE concat(nvl(SmallA.StringNum, ''), nvl(SmallA.StringKey, '')) END FROM SmallA"; //$NON-NLS-1$
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, UDF,
- input, output,
- TRANSLATOR);
+ String output = "SELECT (g_0.StringNum || g_0.StringKey) FROM SmallA g_0"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
+ commandBuilder.getLanguageBridgeFactory().setSupportsConcat2(true);
+ Command obj = commandBuilder.getCommand(input, true, true);
+ TranslationHelper.helpTestVisitor(output, TRANSLATOR, obj);
}
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -30,6 +30,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.ResizingArrayList;
+import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.internal.process.RequestWorkItem;
@@ -48,15 +49,7 @@
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.resource.spi.WrappedConnection;
-import org.teiid.translator.CacheDirective;
-import org.teiid.translator.DataNotAvailableException;
-import org.teiid.translator.Execution;
-import org.teiid.translator.ExecutionFactory;
-import org.teiid.translator.ProcedureExecution;
-import org.teiid.translator.ResultSetExecution;
-import org.teiid.translator.ReusableExecution;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.UpdateExecution;
+import org.teiid.translator.*;
public class ConnectorWorkItem implements ConnectorWork {
@@ -85,7 +78,7 @@
private DataNotAvailableException dnae;
- ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager) {
+ ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager) throws TeiidComponentException {
this.id = message.getAtomicRequestID();
this.requestMsg = message;
this.manager = manager;
@@ -108,6 +101,7 @@
this.securityContext.setTransactional(requestMsg.isTransactional());
LanguageBridgeFactory factory = new LanguageBridgeFactory(this.queryMetadata);
factory.setConvertIn(!this.connector.supportsInCriteria());
+ factory.setSupportsConcat2(manager.getCapabilities().supportsFunction(SourceSystemFunctions.CONCAT2));
translatedCommand = factory.translate(message.getCommand());
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -46,6 +46,7 @@
import org.teiid.metadata.ProcedureParameter;
import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.sql.lang.*;
import org.teiid.query.sql.lang.Command;
@@ -63,6 +64,7 @@
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.WindowFunction;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TranslatorException;
@@ -135,6 +137,7 @@
private List<List<?>> allValues = new LinkedList<List<?>>();
private Map<String, List<? extends List<?>>> dependentSets;
private boolean convertIn;
+ private boolean supportsConcat2;
public LanguageBridgeFactory(QueryMetadataInterface metadata) {
if (metadata != null) {
@@ -149,6 +152,10 @@
public void setConvertIn(boolean convertIn) {
this.convertIn = convertIn;
}
+
+ public void setSupportsConcat2(boolean supportsConcat2) {
+ this.supportsConcat2 = supportsConcat2;
+ }
public org.teiid.language.Command translate(Command command) {
try {
@@ -619,7 +626,7 @@
return result;
}
- org.teiid.language.Function translate(Function function) {
+ org.teiid.language.Expression translate(Function function) {
Expression [] args = function.getArgs();
List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(args.length);
for (int i = 0; i < args.length; i++) {
@@ -628,6 +635,43 @@
String name = function.getName();
if (function.getFunctionDescriptor() != null) {
name = function.getFunctionDescriptor().getName();
+ if (!supportsConcat2 && function.getFunctionDescriptor().getMethod().getParent() == null && name.equalsIgnoreCase(SourceSystemFunctions.CONCAT2)) {
+ Expression[] newArgs = new Expression[args.length];
+
+ boolean useCase = true;
+ for(int i=0; i<args.length; i++) {
+ if (args[i] instanceof Constant) {
+ newArgs[i] = args[i];
+ useCase = false;
+ } else {
+ Function f = new Function(SourceSystemFunctions.IFNULL, new Expression[] {args[i], new Constant("")}); //$NON-NLS-1$
+ newArgs[i] = f;
+ f.setType(args[i].getType());
+ FunctionDescriptor descriptor =
+ metadataFactory.getMetadata().getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
+ f.setFunctionDescriptor(descriptor);
+ }
+ }
+
+ Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
+ concat.setType(DataTypeManager.DefaultDataClasses.STRING);
+
+ if (!useCase) {
+ return translate(concat);
+ }
+
+ FunctionDescriptor descriptor =
+ metadataFactory.getMetadata().getFunctionLibrary().findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+ concat.setFunctionDescriptor(descriptor);
+
+ List<CompoundCriteria> when = Arrays.asList(new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1])));
+ Constant nullConstant = new Constant(null, DataTypeManager.DefaultDataClasses.STRING);
+ List<Constant> then = Arrays.asList(nullConstant);
+ SearchedCaseExpression caseExpr = new SearchedCaseExpression(when, then);
+ caseExpr.setElseExpression(concat);
+ caseExpr.setType(DataTypeManager.DefaultDataClasses.STRING);
+ return translate(caseExpr);
+ }
//check for translator pushdown functions, and use the name in source if possible
if (function.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN
&& function.getFunctionDescriptor().getSchema().equalsIgnoreCase(CoreConstants.SYSTEM_MODEL)
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -620,14 +620,27 @@
// ================== Function = length =====================
public static Object length(String str) {
- return new Integer(str.length());
+ return str.length();
}
// ================== Function = concat =====================
- public static Object concat(String str1, String str2) {
+ public static String concat(String str1, String str2) {
return str1 + str2;
}
+
+ public static String concat2(String str1, String str2) {
+ if (str1 == null) {
+ if (str2 == null) {
+ return null;
+ }
+ return str2;
+ }
+ if (str2 == null) {
+ return str1;
+ }
+ return str1 + str2;
+ }
// ================== Function = substring =====================
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -540,11 +540,12 @@
new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concatop_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concatop_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionMethod concat2 = new FunctionMethod("concat2", QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) ), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")), false, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+ FunctionMethod concat2 = new FunctionMethod(SourceSystemFunctions.CONCAT2, QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FUNCTION_CLASS, "concat2", //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")) ); //$NON-NLS-1$ //$NON-NLS-2$
+ concat2.setNullOnNull(false);
functions.add(concat2);
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -48,6 +48,7 @@
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.AggregateSymbol.Type;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.ExecutionFactory.NullOrder;
import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
@@ -231,10 +232,16 @@
//technically the other functions are scoped to SYS or their function model, but that's
//not formally part of their metadata yet
Schema schema = function.getFunctionDescriptor().getMethod().getParent();
+ String fullName = function.getFunctionDescriptor().getMethod().getFullName();
if (schema == null || !schema.isPhysical()) {
// Find capabilities
- if (!caps.supportsFunction(function.getFunctionDescriptor().getMethod().getFullName())) {
- return false;
+
+ if (!caps.supportsFunction(fullName)) {
+ //special handling for delayed rewrite of concat2
+ return (schema == null && SourceSystemFunctions.CONCAT2.equalsIgnoreCase(fullName)
+ && caps.supportsFunction(SourceSystemFunctions.CONCAT)
+ && caps.supportsFunction(SourceSystemFunctions.IFNULL)
+ && caps.supportsCapability(Capability.QUERY_SEARCHED_CASE));
}
if (FunctionLibrary.isConvert(function)) {
Class<?> fromType = function.getArg(0).getType();
@@ -245,7 +252,7 @@
return caps.supportsConvert(DataTypeManager.getTypeCode(fromType), DataTypeManager.getTypeCode(targetType));
}
} else if (!isSameConnector(modelID, schema, metadata, capFinder)) {
- return caps.supportsFunction(function.getFunctionDescriptor().getMethod().getFullName());
+ return caps.supportsFunction(fullName);
}
return true;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -2097,6 +2097,7 @@
}
}
+ boolean omitNull = false;
Integer code = FUNCTION_MAP.get(functionName);
if (code != null) {
switch (code) {
@@ -2145,33 +2146,9 @@
}
break;
}
- case 4: { //rewrite concat2 - CONCAT2(a, b) ==> CASE WHEN (a is NULL AND b is NULL) THEN NULL ELSE CONCAT( NVL(a, ''), NVL(b, '') )
- Expression[] args = function.getArgs();
- Function[] newArgs = new Function[args.length];
-
- for(int i=0; i<args.length; i++) {
- newArgs[i] = new Function(SourceSystemFunctions.IFNULL, new Expression[] {args[i], new Constant("")}); //$NON-NLS-1$
- newArgs[i].setType(args[i].getType());
- Assertion.assertTrue(args[i].getType() == DataTypeManager.DefaultDataClasses.STRING);
- FunctionDescriptor descriptor =
- funcLibrary.findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
- newArgs[i].setFunctionDescriptor(descriptor);
- }
-
- Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
- concat.setType(DataTypeManager.DefaultDataClasses.STRING);
- FunctionDescriptor descriptor =
- funcLibrary.findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
- concat.setFunctionDescriptor(descriptor);
-
- List when = Arrays.asList(new Criteria[] {new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1]))});
- Constant nullConstant = new Constant(null, DataTypeManager.DefaultDataClasses.STRING);
- List then = Arrays.asList(new Expression[] {nullConstant});
- SearchedCaseExpression caseExpr = new SearchedCaseExpression(when, then);
- caseExpr.setElseExpression(concat);
- caseExpr.setType(DataTypeManager.DefaultDataClasses.STRING);
- return rewriteExpressionDirect(caseExpr);
- }
+ case 4:
+ omitNull = true;
+ break;
case 5: {
if (function.getType() != DataTypeManager.DefaultDataClasses.TIMESTAMP) {
FunctionDescriptor descriptor =
@@ -2229,14 +2206,32 @@
Expression[] args = function.getArgs();
Expression[] newArgs = new Expression[args.length];
-
+
// Rewrite args
+ int j = 0;
for(int i=0; i<args.length; i++) {
- newArgs[i] = rewriteExpressionDirect(args[i]);
- if (isNull(newArgs[i]) && !function.getFunctionDescriptor().isNullDependent()) {
- return new Constant(null, function.getType());
+ Expression ex = rewriteExpressionDirect(args[i]);
+ if (isNull(ex)) {
+ if (!function.getFunctionDescriptor().isNullDependent()) {
+ return new Constant(null, function.getType());
+ }
+ if (omitNull) {
+ continue;
+ }
}
+ newArgs[j++] = ex;
}
+ if (omitNull) {
+ if (j==0) {
+ return new Constant(null, function.getType());
+ }
+ if (j==1) {
+ return newArgs[0];
+ }
+ if (j!=args.length) {
+ newArgs = Arrays.copyOf(newArgs, j);
+ }
+ }
function.setArgs(newArgs);
if( FunctionLibrary.isConvert(function)) {
Modified: trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -52,14 +52,20 @@
}
private QueryMetadataInterface metadata;
+ private LanguageBridgeFactory languageBridgeFactory;
/**
* @param metadata The metadata describing the datasource which the query is for.
*/
public CommandBuilder(QueryMetadataInterface metadata) {
this.metadata = metadata;
+ this.languageBridgeFactory = new LanguageBridgeFactory(metadata);
}
+ public LanguageBridgeFactory getLanguageBridgeFactory() {
+ return languageBridgeFactory;
+ }
+
public org.teiid.language.Command getCommand(String queryString) {
return getCommand(queryString, false, false);
}
@@ -75,7 +81,7 @@
command = (Command)command.clone();
command.acceptVisitor(new AliasGenerator(supportsGroupAlias));
}
- return new LanguageBridgeFactory(metadata).translate(command);
+ return languageBridgeFactory.translate(command);
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestFunctionImpl.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -50,7 +50,7 @@
}
public static Function example(String name) throws Exception {
- return TstLanguageBridgeFactory.factory.translate(helpExample(name));
+ return (Function) TstLanguageBridgeFactory.factory.translate(helpExample(name));
}
public void testGetName() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestFunctionPushdown.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -37,8 +37,10 @@
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.parser.TestDDLParser;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings({"nls", "unchecked"})
public class TestFunctionPushdown {
@@ -141,6 +143,34 @@
new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
+ @Test public void testConcat2() throws Exception {
+ QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport(SourceSystemFunctions.CONCAT2, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select concat2(x.e1, x.e1) from pm1.g1 as x"; //$NON-NLS-1$
+
+ helpPlan(sql, metadata, null, capFinder,
+ new String[] {"SELECT concat2(g_0.e1, g_0.e1) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ //cannot pushdown
+ caps.setFunctionSupport(SourceSystemFunctions.CONCAT2, false);
+
+ helpPlan(sql, metadata, null, capFinder,
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ caps.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
+ caps.setFunctionSupport(SourceSystemFunctions.IFNULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+
+ //will get replaced in the LanguageBridgeFactory
+ helpPlan(sql, metadata, null, capFinder,
+ new String[] {"SELECT concat2(g_0.e1, g_0.e1) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
public static String sourceFunc(String msg) {
return msg;
}
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-14 16:04:37 UTC (rev 4446)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2012-09-14 17:19:05 UTC (rev 4447)
@@ -1336,15 +1336,11 @@
}
@Test public void testRewriteConcat2_2() throws Exception {
- helpTestRewriteCriteria("concat2(pm1.g1.e1, null) = 'xyz'", "CASE WHEN pm1.g1.e1 IS NULL THEN null ELSE concat(ifnull(pm1.g1.e1, ''), '') END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("concat2(pm1.g1.e1, null) = 'xyz'", "pm1.g1.e1 = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testRewriteConcat2_3() throws Exception {
- helpTestRewriteCriteria("concat2(pm1.g1.e1, convert(pm1.g1.e2, string)) = 'xyz'", "CASE WHEN (pm1.g1.e1 IS NULL) AND (convert(pm1.g1.e2, string) IS NULL) THEN null ELSE concat(ifnull(pm1.g1.e1, ''), ifnull(convert(pm1.g1.e2, string), '')) END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
@Test public void testRewriteConcat2_4() throws Exception {
- helpTestRewriteCriteria("concat2('a', pm1.g1.e1) = 'xyz'", "concat('a', ifnull(pm1.g1.e1, '')) = 'xyz'"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("concat2('a', pm1.g1.e1) = 'xyz'", "concat2('a', pm1.g1.e1) = 'xyz'"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testRewriteFromUnixTime() throws Exception {
12 years, 3 months
teiid SVN: r4446 - trunk/test-integration/common/src/test/java/org/teiid/arquillian.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-14 12:04:37 -0400 (Fri, 14 Sep 2012)
New Revision: 4446
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
Log:
TEIID-2158: further refinement of test
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 15:57:37 UTC (rev 4445)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 16:04:37 UTC (rev 4446)
@@ -34,14 +34,13 @@
import java.net.URLEncoder;
import org.jboss.arquillian.junit.Arquillian;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminFactory;
-import org.teiid.adminapi.AdminFactory.AdminImpl;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
import org.teiid.jdbc.TeiidDriver;
@@ -50,23 +49,23 @@
@SuppressWarnings("nls")
public class IntegrationTestRestWebserviceGeneration extends AbstractMMQueryTestCase {
- private static Admin admin;
+ private Admin admin;
- @BeforeClass
- public static void setup() throws Exception {
+ @Before
+ public void setup() throws Exception {
admin = AdminFactory.getInstance().createAdmin("localhost", 9999, "admin", "admin".toCharArray());
- admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
+
}
- @AfterClass
- public static void teardown() throws AdminException {
+ @After
+ public void teardown() throws AdminException {
AdminUtil.cleanUp(admin);
admin.close();
}
@Test
public void testGetOperation() throws Exception {
-
+ admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
assertTrue(AdminUtil.waitForVDBLoad(admin, "sample", 1, 3));
this.internalConnection = TeiidDriver.getInstance().connect("jdbc:teiid:sample@mm://localhost:31000;user=user;password=user", null);
@@ -83,7 +82,7 @@
@Test
public void testPostOperation() throws Exception {
-
+ admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
assertTrue(AdminUtil.waitForVDBLoad(admin, "sample", 1, 3));
this.internalConnection = TeiidDriver.getInstance().connect("jdbc:teiid:sample@mm://localhost:31000;user=user;password=user", null);
12 years, 3 months
teiid SVN: r4445 - trunk/test-integration/common/src/test/java/org/teiid/arquillian.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-14 11:57:37 -0400 (Fri, 14 Sep 2012)
New Revision: 4445
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
Log:
TEIID-2158: further refinement of test
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java 2012-09-14 15:30:26 UTC (rev 4444)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java 2012-09-14 15:57:37 UTC (rev 4445)
@@ -22,11 +22,13 @@
package org.teiid.arquillian;
+import java.util.List;
import java.util.Properties;
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.AdminFactory.AdminImpl;
import org.teiid.adminapi.VDB.Status;
@SuppressWarnings("nls")
@@ -78,5 +80,30 @@
} while (System.currentTimeMillis() < waitUntil);
return false;
}
+
+ static boolean waitForDeployment(Admin admin, String deploymentName,
+ int timeoutInSecs) {
+ long waitUntil = System.currentTimeMillis() + timeoutInSecs*1000;
+ if (timeoutInSecs < 0) {
+ waitUntil = Long.MAX_VALUE;
+ }
+ boolean first = true;
+ do {
+ if (!first) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ break;
+ }
+ } else {
+ first = false;
+ }
+ List<String> deployments = ((AdminImpl)admin).getDeployments();
+ if (deployments.contains(deploymentName)) {
+ return true;
+ }
+ } while (System.currentTimeMillis() < waitUntil);
+ return false;
+ }
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 15:30:26 UTC (rev 4444)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 15:57:37 UTC (rev 4445)
@@ -74,11 +74,11 @@
execute("SELECT * FROM Txns.G1"); //$NON-NLS-1$
this.internalResultSet.next();
- assertTrue(((AdminImpl)admin).getDeployments().contains("sample_1.war"));
+ assertTrue("sample_1.war not found", AdminUtil.waitForDeployment(admin, "sample_1.war", 5));
// get based call
String response = httpCall("http://localhost:8080/sample_1/view/g1/123", "GET", null);
- assertEquals("<rows p1=\"123\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
+ assertEquals("response did not match expected", "<rows p1=\"123\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
}
@Test
@@ -91,18 +91,18 @@
execute("SELECT * FROM Txns.G1"); //$NON-NLS-1$
this.internalResultSet.next();
- assertTrue(((AdminImpl)admin).getDeployments().contains("sample_1.war"));
+ assertTrue("sample_1.war not found", AdminUtil.waitForDeployment(admin, "sample_1.war", 5));
String params = URLEncoder.encode("p1", "UTF-8") + "=" + URLEncoder.encode("456", "UTF-8");
// post based call
String response = httpCall("http://localhost:8080/sample_1/view/g1post", "POST", params);
- assertEquals("<rows p1=\"456\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
+ assertEquals("response did not match expected", "<rows p1=\"456\"><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
// ad-hoc procedure
params = URLEncoder.encode("sql", "UTF-8") + "=" + URLEncoder.encode("SELECT XMLELEMENT(NAME \"rows\", XMLAGG(XMLELEMENT(NAME \"row\", XMLFOREST(e1, e2)))) AS xml_out FROM Txns.G1", "UTF-8");
response = httpCall("http://localhost:8080/sample_1/view/query", "POST", params);
- assertEquals("<rows><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
+ assertEquals("response did not match expected", "<rows><row><e1>ABCDEFGHIJ</e1><e2>0</e2></row></rows>", response);
}
12 years, 3 months
teiid SVN: r4444 - trunk/jboss-integration/src/main/java/org/teiid/jboss.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-14 11:30:26 -0400 (Fri, 14 Sep 2012)
New Revision: 4444
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
Log:
TEIID-2204: I believe during the reload the naming store was being accessed before the it got started; treated any error out of nameing store as not available. Also, ODBC socket was not being properly closed. Corrected that issue.
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2012-09-14 15:01:26 UTC (rev 4443)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2012-09-14 15:30:26 UTC (rev 4444)
@@ -216,7 +216,7 @@
InitialContext ic = new InitialContext();
ic.lookup(LocalServerConnection.TEIID_RUNTIME_CONTEXT);
return true;
- } catch (NamingException e) {
+ } catch (Throwable e) {
return false;
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-09-14 15:01:26 UTC (rev 4443)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-09-14 15:30:26 UTC (rev 4444)
@@ -163,6 +163,7 @@
getVdbRepository().odbcEnabled();
ODBCSocketListener odbc = new ODBCSocketListener(address, this.socketConfig, this.csr, getBufferManagerInjector().getValue(), getMaxODBCLobSizeAllowed(), this.logon);
odbc.setAuthenticationType(this.sessionService.getAuthenticationType());
+ this.socketListener = odbc;
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50037, address.getHostName(), String.valueOf(address.getPort()), (sslEnabled?"ON":"OFF"), authenticationDomains)); //$NON-NLS-1$ //$NON-NLS-2$
}
else {
12 years, 3 months
teiid SVN: r4443 - in trunk/test-integration: perf and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-14 11:01:26 -0400 (Fri, 14 Sep 2012)
New Revision: 4443
Modified:
trunk/test-integration/perf/pom.xml
trunk/test-integration/pom.xml
Log:
switching perf to always be a child module so that it's updated as part of a release
Modified: trunk/test-integration/perf/pom.xml
===================================================================
--- trunk/test-integration/perf/pom.xml 2012-09-14 14:45:21 UTC (rev 4442)
+++ trunk/test-integration/perf/pom.xml 2012-09-14 15:01:26 UTC (rev 4443)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>8.2.0.Alpha1-SNAPSHOT</version>
+ <version>8.2.0.Alpha2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-perf</artifactId>
@@ -18,4 +18,31 @@
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>perf</id>
+ </profile>
+
+ </profiles>
+
</project>
\ No newline at end of file
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2012-09-14 14:45:21 UTC (rev 4442)
+++ trunk/test-integration/pom.xml 2012-09-14 15:01:26 UTC (rev 4443)
@@ -19,18 +19,6 @@
<apache.ant.version>1.7.0</apache.ant.version>
</properties>
- <profiles>
- <profile>
- <!--
- This profile is activated manually, as in "mvn ... -P release ..."
- -->
- <id>perf</id>
- <modules>
- <module>perf</module>
- </modules>
- </profile>
- </profiles>
-
<dependencies>
<dependency>
<groupId>org.jboss.teiid</groupId>
@@ -132,5 +120,6 @@
<modules>
<module>common</module>
<module>db</module>
+ <module>perf</module>
</modules>
</project>
\ No newline at end of file
12 years, 3 months
teiid SVN: r4442 - trunk/test-integration/common/src/test/java/org/teiid/arquillian.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2012-09-14 10:45:21 -0400 (Fri, 14 Sep 2012)
New Revision: 4442
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
Log:
TEIID-2158: fixing the integration test; as the deploy and undeploy as async operations sometimes operations from two different tests can overlap and lead to errors.
Modified: trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 13:44:21 UTC (rev 4441)
+++ trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestRestWebserviceGeneration.java 2012-09-14 14:45:21 UTC (rev 4442)
@@ -34,8 +34,8 @@
import java.net.URLEncoder;
import org.jboss.arquillian.junit.Arquillian;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.teiid.adminapi.Admin;
@@ -50,22 +50,22 @@
@SuppressWarnings("nls")
public class IntegrationTestRestWebserviceGeneration extends AbstractMMQueryTestCase {
- private Admin admin;
+ private static Admin admin;
- @Before
- public void setup() throws Exception {
+ @BeforeClass
+ public static void setup() throws Exception {
admin = AdminFactory.getInstance().createAdmin("localhost", 9999, "admin", "admin".toCharArray());
+ admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
}
- @After
- public void teardown() throws AdminException {
+ @AfterClass
+ public static void teardown() throws AdminException {
AdminUtil.cleanUp(admin);
admin.close();
}
@Test
public void testGetOperation() throws Exception {
- admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
assertTrue(AdminUtil.waitForVDBLoad(admin, "sample", 1, 3));
@@ -83,7 +83,6 @@
@Test
public void testPostOperation() throws Exception {
- admin.deploy("sample-vdb.xml",new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
assertTrue(AdminUtil.waitForVDBLoad(admin, "sample", 1, 3));
12 years, 3 months