diff --git a/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/AbstractInfinispanManagedConnectionFactory.java b/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/AbstractInfinispanManagedConnectionFactory.java index bdcdbf26b0..7ed82fd3e7 100644 --- a/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/AbstractInfinispanManagedConnectionFactory.java +++ b/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/AbstractInfinispanManagedConnectionFactory.java @@ -160,7 +160,8 @@ public RemoteCache getCache(String cacheName) { Assertion.isNotNull(cacheName, "Program Error: Cache Name is null"); } - return cacheContainer.getCache(cacheName); + return cacheContainer.getCache(cacheName); + } /** @@ -666,6 +667,12 @@ private RemoteCacheManager getRemoteCacheFromJNDI( protected void registerWithCacheManager(SerializationContext ctx, RemoteCacheManager cc, ClassLoader cl, boolean useAnnotations) throws ResourceException { } + + public String getVersion() throws TranslatorException { + RemoteCache rc = this.getCache(this.getCacheNameProxy().getPrimaryCacheKey()); + if (rc != null) return rc.getProtocolVersion(); + return ""; + } @Override public int hashCode() { diff --git a/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/InfinispanConnectionImpl.java b/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/InfinispanConnectionImpl.java index 250b3b7d43..91c700a4a1 100644 --- a/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/InfinispanConnectionImpl.java +++ b/connectors/connector-infinispan-hotrod/src/main/java/org/teiid/resource/adapter/infinispan/hotrod/InfinispanConnectionImpl.java @@ -61,6 +61,11 @@ public InfinispanConnectionImpl(AbstractInfinispanManagedConnectionFactory confi LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Infinispan Connection has been newly created "); //$NON-NLS-1$ } + @Override + public String getVersion() throws TranslatorException { + return this.config.getVersion(); + } + /** * Close the connection, if a connection requires closing. * (non-Javadoc) diff --git a/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConfigFileRemoteCache.java b/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConfigFileRemoteCache.java index 2201342dc5..7ac28b8dbd 100644 --- a/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConfigFileRemoteCache.java +++ b/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConfigFileRemoteCache.java @@ -87,6 +87,10 @@ public void testConnection() throws Exception { assertNotNull(conn.getCache()); + + assertEquals("Version doesn't start with 7.2", conn.getVersion().startsWith("7.2")); + + conn.cleanUp(); } finally { diff --git a/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConnectionFactory.java b/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConnectionFactory.java index 39cf81fa42..1548ee7f53 100644 --- a/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConnectionFactory.java +++ b/connectors/connector-infinispan-hotrod/src/test/java/org/teiid/resource/adapter/infinispan/hotrod/TestInfinispanConnectionFactory.java @@ -33,7 +33,6 @@ import org.jboss.teiid.jdg_remote.pojo.AllTypes; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; diff --git a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheRAConnection.java b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheRAConnection.java index 75cbdeb02f..444e1463ad 100644 --- a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheRAConnection.java +++ b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheRAConnection.java @@ -21,8 +21,20 @@ */ package org.teiid.resource.adapter.infinispan; +import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.resource.ResourceException; + +import org.infinispan.Cache; +import org.infinispan.client.hotrod.RemoteCache; +import org.infinispan.configuration.cache.Configuration; +import org.infinispan.manager.DefaultCacheManager; +import org.infinispan.manager.EmbeddedCacheManager; +import org.infinispan.query.Search; import org.infinispan.query.dsl.QueryFactory; import org.teiid.logging.LogConstants; import org.teiid.logging.LogManager; @@ -39,145 +51,185 @@ */ public class InfinispanCacheRAConnection extends BasicConnection implements InfinispanCacheConnection { + + private InfinispanManagedConnectionFactory config; - private InfinispanCacheWrapper cacheWrapper; public InfinispanCacheRAConnection(InfinispanManagedConnectionFactory config) { - this.cacheWrapper = config.getCacheWrapper(); + this.config = config; LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Infinispan-Library Mode Cache Connection has been created."); //$NON-NLS-1$ } - - @Override - public Object getCache() throws TranslatorException { - return cacheWrapper.getCache(); - } - @Override - public Collection getAll() throws TranslatorException { - return cacheWrapper.getAll(); + public InfinispanManagedConnectionFactory getConfig() { + return config; } @Override - public QueryFactory getQueryFactory() throws TranslatorException { - return cacheWrapper.getQueryFactory(); + public String getVersion() throws TranslatorException { + return this.getConfig().getVersion(); } - - @Override - public String getPkField() { - return cacheWrapper.getPkField(); - } - - @SuppressWarnings("unused") - @Override - public Class getCacheKeyClassType() throws TranslatorException { - return cacheWrapper.getCacheKeyClassType(); - } - /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#getCacheName() + * @see org.teiid.translator.object.ObjectConnection#getPkField() */ @Override - public String getCacheName() { - return cacheWrapper.getCacheName(); + public String getPkField() { + return getConfig().getPKey(); } /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#getCacheClassType() + * @see org.teiid.translator.object.ObjectConnection#getCacheKeyClassType() */ @Override - public Class getCacheClassType() throws TranslatorException { - return cacheWrapper.getCacheClassType(); + public Class getCacheKeyClassType() { + return getConfig().getCacheKeyClassType(); } /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#add(java.lang.Object, java.lang.Object) + * @see org.teiid.translator.object.ObjectConnection#getCacheName() */ @Override - public void add(Object key, Object value) throws TranslatorException { - this.cacheWrapper.add(key, value); + public String getCacheName() { + return getTargetCacheName(); } /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#remove(java.lang.Object) + * @see org.teiid.translator.object.ObjectConnection#getCacheClassType() */ @Override - public Object remove(Object key) throws TranslatorException { - return this.cacheWrapper.remove(key); + public Class getCacheClassType() { + return getConfig().getCacheClassType(); } /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#update(java.lang.Object, java.lang.Object) + * @see org.teiid.translator.object.ObjectConnection#getClassRegistry() */ @Override - public void update(Object key, Object value) throws TranslatorException { - this.cacheWrapper.update(key, value); + public ClassRegistry getClassRegistry() { + return getConfig().getClassRegistry(); + } + + @Override + public DDLHandler getDDLHandler() { + return getConfig().getCacheNameProxy().getDDLHandler(); + } + + @Override + public boolean isAlive() { + boolean alive = (config == null ? false : this.config.isAlive()); + LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Infinispan Library Mode Connection is alive:", alive); //$NON-NLS-1$ + return (alive); + + } + + private String getTargetCacheName() { + if (getDDLHandler().isStagingTarget()) { + return config.getCacheNameProxy().getStageCacheAliasName(); + } + return config.getCacheNameProxy().getPrimaryCacheAliasName();// public String getCacheName() { +// // return the cacheName that is mapped as the alias +// return cacheNameProxy.getPrimaryCacheAliasName(); +// } +// +// public String getCacheStagingName() { +// return cacheNameProxy.getStageCacheAliasName(); +// } + } + public Cache getCache() { + return getCache(getTargetCacheName()); + } + /** * {@inheritDoc} * - * @see org.teiid.translator.object.ObjectConnection#getClassRegistry() + * @see org.teiid.translator.object.ObjectConnection#getCache(java.lang.String) */ @Override - public ClassRegistry getClassRegistry() { - return cacheWrapper.getClassRegistry(); + public Cache getCache(String cacheName) { + return config.getCache(cacheName); + } + + @Override + public Collection getAll() { + Collection objs = new ArrayList(); + Cache c = getCache(getTargetCacheName()); + for (Object k : c.keySet()) { + objs.add(c.get(k)); + } + return objs; } - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#get(java.lang.Object) - */ + /* split out for testing purposes */ + protected Object performJNDICacheLookup(String jndiName) throws Exception { + Context context = null; + + context = new InitialContext(); + final Object cache = context.lookup(jndiName); + + if (cache == null) { + throw new ResourceException( + InfinispanManagedConnectionFactory.UTIL + .getString( + "InfinispanManagedConnectionFactory.unableToFindCacheUsingJNDI", jndiName)); //$NON-NLS-1$ + } + + return cache; + } + @Override - public Object get(Object key) throws TranslatorException { - return this.cacheWrapper.get(key); + public void cleanUp() { + config = null; + } - /** - * {@inheritDoc} - * - * @see javax.resource.cci.Connection#close() - */ + @SuppressWarnings("rawtypes") @Override - public void close() { - this.cacheWrapper = null; + public QueryFactory getQueryFactory() { + + return Search.getQueryFactory(getCache(getTargetCacheName())); + } - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getCache(java.lang.String) - */ @Override - public Object getCache(String cacheName) throws TranslatorException { - return cacheWrapper.getCache(cacheName); + public Object get(Object key) { + return getCache(getTargetCacheName()).get(key); } - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#clearCache(java.lang.String) - */ @Override - public void clearCache(String cacheName) throws TranslatorException { - cacheWrapper.clearCache(cacheName); + public void add(Object key, Object value) { + getCache(getTargetCacheName()).put(key, value); } - + @Override - public DDLHandler getDDLHandler() { - return cacheWrapper.getDDLHandler(); + public Object remove(Object key) { + return getCache(getTargetCacheName()).removeAsync(key); + } + + @Override + public void update(Object key, Object value) { + getCache(getTargetCacheName()).replace(key, value); } + @Override + public void clearCache(String cacheName) throws TranslatorException { + getCache(cacheName).clear(); + } + + protected void shutDownCacheManager() { + getCache().stop(); + } + /** * Returns the SearchType that will be used to perform * dynamic searching of the cache. @@ -185,8 +237,16 @@ public DDLHandler getDDLHandler() { */ @Override public SearchType getSearchType() { - return cacheWrapper.getSearchType(); + return new DSLSearch(this); + } + + /** + * {@inheritDoc} + * + * @see javax.resource.cci.Connection#close() + */ + @Override + public void close() throws ResourceException { } - } diff --git a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheWrapper.java b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheWrapper.java deleted file mode 100644 index 6ac29ed631..0000000000 --- a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanCacheWrapper.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * See the COPYRIGHT.txt file distributed with this work for information - * regarding copyright ownership. Some portions may be licensed - * to Red Hat, Inc. under one or more contributor license agreements. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA. - */ -package org.teiid.resource.adapter.infinispan; - -import javax.resource.ResourceException; - -import org.teiid.translator.infinispan.libmode.InfinispanCacheConnection; -import org.teiid.translator.object.ClassRegistry; -import org.teiid.translator.object.DDLHandler; - -/** - * @author vanhalbert - * @param - * @param - * - */ -public abstract class InfinispanCacheWrapper implements InfinispanCacheConnection { - - public abstract InfinispanManagedConnectionFactory getConfig(); - - /** - * Called so the wrapper, with the configuration, can create the cache manager it will use - * @param config - * @throws ResourceException - */ - public abstract void init(InfinispanManagedConnectionFactory config) throws ResourceException; - - /** - * Called to pass in the cacheManager it will use. This will be called when - * the CacheManager was registered via JNDI. The factory makes the determination - * if its a local or remote cache and initializes the wrapper accordingly. - * @param config - * @param cacheManager object - */ - public abstract void init(InfinispanManagedConnectionFactory config, Object cacheManager); - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getPkField() - */ - @Override - public String getPkField() { - return getConfig().getPKey(); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getCacheKeyClassType() - */ - @Override - public Class getCacheKeyClassType() { - return getConfig().getCacheKeyClassType(); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getCacheName() - */ - @Override - public String getCacheName() { - return getConfig().getCacheName(); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getCacheClassType() - */ - @Override - public Class getCacheClassType() { - return getConfig().getCacheClassType(); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getClassRegistry() - */ - @Override - public ClassRegistry getClassRegistry() { - return getConfig().getClassRegistry(); - } - - @Override - public DDLHandler getDDLHandler() { - return getConfig().getCacheNameProxy().getDDLHandler(); - } - - /** - * Provided for testing purposes - */ - protected abstract void shutDownCacheManager(); - -} \ No newline at end of file diff --git a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java index 70f5b421fb..3af627a4d3 100644 --- a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java +++ b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java @@ -21,6 +21,7 @@ */ package org.teiid.resource.adapter.infinispan; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -29,11 +30,20 @@ import javax.resource.ResourceException; import javax.resource.spi.InvalidPropertyException; +import org.infinispan.Cache; +import org.infinispan.client.hotrod.RemoteCache; +import org.infinispan.configuration.cache.Configuration; +import org.infinispan.lifecycle.ComponentStatus; +import org.infinispan.manager.DefaultCacheManager; +import org.infinispan.manager.EmbeddedCacheManager; import org.jboss.modules.Module; import org.jboss.modules.ModuleIdentifier; import org.jboss.modules.ModuleLoadException; import org.teiid.core.BundleUtil; +import org.teiid.core.util.Assertion; import org.teiid.core.util.StringUtil; +import org.teiid.logging.LogConstants; +import org.teiid.logging.LogManager; import org.teiid.resource.spi.BasicConnectionFactory; import org.teiid.resource.spi.BasicManagedConnectionFactory; import org.teiid.translator.TranslatorException; @@ -44,18 +54,13 @@ public class InfinispanManagedConnectionFactory extends BasicManagedConnectionFactory { public static final BundleUtil UTIL = BundleUtil.getBundleUtil(InfinispanManagedConnectionFactory.class); - - private static final String LOCAL_CACHE_CONNECTION = "org.teiid.resource.adapter.infinispan.local.LocalCacheConnection"; - private static final String REMOTE_CACHE_CONNECTION = "org.teiid.resource.adapter.infinispan.remote.RemoteCacheConnection"; private static final long serialVersionUID = -9153717006234080627L; - private String remoteServerList = null; private String configurationFileNameForLocalCache = null; - private String hotrodClientPropertiesFile = null; private String cacheJndiName = null; private String cacheTypeMapping = null; private ClassRegistry methodUtil = new ClassRegistry(); - private InfinispanCacheWrapper cacheWrapper = null; + private EmbeddedCacheManager cacheManager = null; private String module; private String stagingCacheName; @@ -64,7 +69,6 @@ public class InfinispanManagedConnectionFactory extends private Class pkCacheKeyJavaType = null; private Class cacheTypeClass = null; // cacheName ==> ClassType private ClassLoader cl; - private String connectionType = null; private CacheNameProxy cacheNameProxy; @Override @@ -75,13 +79,6 @@ public BasicConnectionFactory createConnectionFacto UTIL.getString("InfinispanManagedConnectionFactory.cacheTypeMapNotSet")); //$NON-NLS-1$ } - if (remoteServerList == null - && configurationFileNameForLocalCache == null - && hotrodClientPropertiesFile == null && cacheJndiName == null) { - throw new InvalidPropertyException( - UTIL.getString("InfinispanManagedConnectionFactory.invalidServerConfiguration")); //$NON-NLS-1$ - } - boolean isConfigured = determineConnectionType(); if (!isConfigured) { throw new InvalidPropertyException( @@ -109,14 +106,14 @@ public InfinispanCacheRAConnection getConnection() } - public String getCacheName() { - // return the cacheName that is mapped as the alias - return cacheNameProxy.getPrimaryCacheAliasName(); - } - - public String getCacheStagingName() { - return cacheNameProxy.getStageCacheAliasName(); - } +// public String getCacheName() { +// // return the cacheName that is mapped as the alias +// return cacheNameProxy.getPrimaryCacheAliasName(); +// } +// +// public String getCacheStagingName() { +// return cacheNameProxy.getStageCacheAliasName(); +// } /** * Call to set the name of the cache to access when calling getCache @@ -241,31 +238,6 @@ public ClassRegistry getClassRegistry() { return methodUtil; } - /** - * Returns the host:port[;host:port...] list that identifies - * the remote servers to include in this cluster; - * - * @return host:port[;host:port...] list - */ - public String getRemoteServerList() { - return remoteServerList; - } - - /** - * Set the list of remote servers that make up the Infinispan cluster. The - * servers must be Infinispan HotRod servers. The list must be in the - * appropriate format of host:port[;host:port...] that would be - * used when defining an Infinispan RemoteCacheManager instance. If - * the value is missing, localhost:11311 is assumed. - * - * @param remoteServerList - * the server list in appropriate - * server:port;server2:port2 format. - */ - public void setRemoteServerList(String remoteServerList) { - this.remoteServerList = remoteServerList; - } - /** * Get the name of the configuration resource or file that should be used to * configure a local cache manager @@ -293,32 +265,6 @@ public void setConfigurationFileNameForLocalCache( this.configurationFileNameForLocalCache = configurationFileName; } - /** - * Get the name of the HotRod client properties file that should be used to - * configure a RemoteCacheManager remoteCacheManager. - * - * @return the name of the HotRod client properties file to be used to - * configure RemoteCacheManager - * @see #setHotRodClientPropertiesFile(String) - */ - public String getHotRodClientPropertiesFile() { - return hotrodClientPropertiesFile; - } - - /** - * Set the name of the HotRod client properties file that should be used to - * configure a remoteCacheManager. - * - * @param propertieFileName - * the name of the HotRod client properties file that should be - * used to configure the RemoteCacheManager - * container. - * @see #getHotRodClientPropertiesFile() - */ - public void setHotRodClientPropertiesFile(String propertieFileName) { - this.hotrodClientPropertiesFile = propertieFileName; - } - /** * Get the JNDI Name of the cache. * @@ -341,9 +287,15 @@ public void setCacheJndiName(String jndiName) { this.cacheJndiName = jndiName; } - protected InfinispanCacheWrapper getCacheWrapper() { - return cacheWrapper; - } + @SuppressWarnings("rawtypes") + public Cache getCache(String cacheName) { + if (cacheName == null) { + Assertion.isNotNull(cacheName, "Program Error: Cache Name is null"); + } + + return cacheManager.getCache(cacheName); + } + public ClassLoader getClassLoader() { return this.cl; @@ -426,36 +378,20 @@ protected synchronized ClassLoader loadClasses() throws ResourceException { } protected synchronized InfinispanCacheRAConnection createCacheConnection() throws ResourceException { - if (this.cacheWrapper == null) { + if (this.cacheManager == null) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader()); loadClasses(); - Class clz = null; - if (getCacheJndiName() != null) { - Object cacheMgr = performJNDICacheLookup(getCacheJndiName()); - boolean isHotRod = isHotRod(cacheMgr); - if (isHotRod) { - clz = loadClass(REMOTE_CACHE_CONNECTION); - } else { - clz = loadClass(LOCAL_CACHE_CONNECTION); - } - InfinispanCacheWrapper cachewrapper = (InfinispanCacheWrapper) clz.newInstance(); - cachewrapper.init(this, cacheMgr); - this.cacheWrapper =cachewrapper; - - } else { - clz = loadClass(connectionType); - InfinispanCacheWrapper cachewrapper = (InfinispanCacheWrapper) clz.newInstance(); - cachewrapper.init(this); - this.cacheWrapper =cachewrapper; - } + InfinispanCacheRAConnection conn = new InfinispanCacheRAConnection(this); + createCache(); + // if configured for materialization, initialize the if (cacheNameProxy.getAliasCacheName() != null) { - Map aliasCache = (Map) this.cacheWrapper.getCache(cacheNameProxy.getAliasCacheName()); + Map aliasCache = (Map) this.cacheManager.getCache(cacheNameProxy.getAliasCacheName()); if (aliasCache == null) { throw new ResourceException( InfinispanManagedConnectionFactory.UTIL @@ -476,36 +412,60 @@ protected synchronized InfinispanCacheRAConnection createCacheConnection() throw private boolean determineConnectionType() { if (this.getConfigurationFileNameForLocalCache() != null) { - this.connectionType =LOCAL_CACHE_CONNECTION; return true; } String jndiName = getCacheJndiName(); if (jndiName != null && jndiName.trim().length() != 0) { return true; // to be determined later - } else if (this.getHotRodClientPropertiesFile() != null) { - this.connectionType = REMOTE_CACHE_CONNECTION; - return true; - } else if (this.getRemoteServerList() != null - && !this.getRemoteServerList().isEmpty()) { - this.connectionType = REMOTE_CACHE_CONNECTION; - return true; - } + } return false; } - /** - * If the CacheManager is the HotRod manager, then use the remote cache connection, - * otherwise, use the local cache connection - * @param cacheMgr - * @return boolean true if its the RemoteCacheManager used in HotRod - * @throws Exception - */ - protected boolean isHotRod(Object cacheMgr) throws Exception { - if (cacheMgr.getClass().getName().contains("hotrod")) { - return true; + private void createCache() throws TranslatorException { + if (cacheManager != null) return; + + if (getConfigurationFileNameForLocalCache() != null) { + try { + DefaultCacheManager cc = new DefaultCacheManager(getConfigurationFileNameForLocalCache()); + + LogManager + .logInfo(LogConstants.CTX_CONNECTOR, + "=== Using DefaultCacheManager (loaded by configuration) ==="); //$NON-NLS-1$ + + cacheManager = cc; + + Configuration conf = cc.getCacheConfiguration(getCacheNameProxy().getPrimaryCacheAliasName()); + if (conf == null) { + throw new TranslatorException("Program Error: cache " + getCacheNameProxy().getPrimaryCacheAliasName() + " was not configured"); + } + conf.module(getCacheClassType()); + + if (getCacheNameProxy().getStageCacheAliasName() != null) { + conf = cc.getCacheConfiguration(getCacheNameProxy().getStageCacheAliasName()); + if (conf == null) { + throw new TranslatorException("Program Error: cache " + getCacheNameProxy().getStageCacheAliasName() + " was not configured"); + } + + conf.module(getCacheClassType()); + } + } catch (IOException e) { + throw new TranslatorException(e); + } + } else { + if (getCacheJndiName() != null) { + try { + cacheManager = (EmbeddedCacheManager) performJNDICacheLookup(getCacheJndiName()); + } catch (TranslatorException e) { + throw e; + } catch (Exception e) { + throw new TranslatorException(e); + } + } else if (cacheManager == null) { + throw new TranslatorException("Program Error: DefaultCacheManager was not configured"); + } } - return false; + } @@ -517,7 +477,7 @@ protected Object performJNDICacheLookup(String jndiName) throws Exception { final Object cache = context.lookup(jndiName); if (cache == null) { - throw new ResourceException( + throw new TranslatorException( InfinispanManagedConnectionFactory.UTIL .getString( "InfinispanManagedConnectionFactory.unableToFindCacheUsingJNDI", jndiName)); //$NON-NLS-1$ @@ -526,21 +486,16 @@ protected Object performJNDICacheLookup(String jndiName) throws Exception { return cache; } + + @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime - * result - + ((remoteServerList == null) ? 0 : remoteServerList.hashCode()); result = prime * result + ((configurationFileNameForLocalCache == null) ? 0 : configurationFileNameForLocalCache.hashCode()); - result = prime - * result - + ((hotrodClientPropertiesFile == null) ? 0 - : hotrodClientPropertiesFile.hashCode()); result = prime * result + ((cacheJndiName == null) ? 0 : cacheJndiName.hashCode()); return result; @@ -556,17 +511,10 @@ public boolean equals(Object obj) { return false; InfinispanManagedConnectionFactory other = (InfinispanManagedConnectionFactory) obj; - if (!checkEquals(this.remoteServerList, other.remoteServerList)) { - return false; - } if (!checkEquals(this.configurationFileNameForLocalCache, other.configurationFileNameForLocalCache)) { return false; } - if (!checkEquals(this.hotrodClientPropertiesFile, - other.hotrodClientPropertiesFile)) { - return false; - } if (!checkEquals(this.cacheJndiName, other.cacheJndiName)) { return false; } @@ -606,12 +554,26 @@ private Class getPrimitiveClass(String className) throws ResourceException { public void cleanUp() { methodUtil = null; cl = null; + this.cacheManager= null; + + } + + public boolean isAlive() { + if (cacheManager == null) return false; + if (cacheManager.getStatus() == ComponentStatus.RUNNING) return true; + + return false; + } + + protected String getVersion() { + if (cacheManager == null) return ""; + return cacheManager.getCache(this.getCacheNameProxy().getPrimaryCacheKey()).getVersion(); } /** used in testing */ - public void shutDown() { - this.cacheWrapper.cleanUp(); + public void shutDownCache() { + cleanUp(); } } \ No newline at end of file diff --git a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/local/LocalCacheConnection.java b/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/local/LocalCacheConnection.java deleted file mode 100644 index 23a177bc73..0000000000 --- a/connectors/connector-infinispan-libmode/src/main/java/org/teiid/resource/adapter/infinispan/local/LocalCacheConnection.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * See the COPYRIGHT.txt file distributed with this work for information - * regarding copyright ownership. Some portions may be licensed - * to Red Hat, Inc. under one or more contributor license agreements. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA. - */ -package org.teiid.resource.adapter.infinispan.local; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.resource.ResourceException; - -import org.infinispan.Cache; -import org.infinispan.configuration.cache.Configuration; -//import org.infinispan.; -import org.infinispan.manager.DefaultCacheManager; -import org.infinispan.manager.EmbeddedCacheManager; -import org.infinispan.query.Search; -import org.infinispan.query.dsl.QueryFactory; -import org.teiid.logging.LogConstants; -import org.teiid.logging.LogManager; -import org.teiid.resource.adapter.infinispan.DSLSearch; -import org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper; -import org.teiid.resource.adapter.infinispan.InfinispanManagedConnectionFactory; -import org.teiid.translator.TranslatorException; -import org.teiid.translator.object.SearchType; - -/** - * This wrapper will contain a local Infinispan cache, and will the necessary logic - * for looking up the cache by {@link #performJNDICacheLookup(String) jndiName} - * - * @author vanhalbert - * @param - * @param - */ -public class LocalCacheConnection extends InfinispanCacheWrapper { - - private EmbeddedCacheManager ecm = null; - private InfinispanManagedConnectionFactory config; - - @Override - public InfinispanManagedConnectionFactory getConfig() { - return config; - } - - @Override - public void init(InfinispanManagedConnectionFactory config, Object cacheManager) { - - this.config = config; - ecm = (EmbeddedCacheManager) cacheManager; - } - - /** - */ - @Override - public void init(InfinispanManagedConnectionFactory config) throws ResourceException { - this.config = config; - - if (config.getConfigurationFileNameForLocalCache() != null) { - try { - DefaultCacheManager cc = new DefaultCacheManager(config.getConfigurationFileNameForLocalCache()); - - LogManager - .logInfo(LogConstants.CTX_CONNECTOR, - "=== Using DefaultCacheManager (loaded by configuration) ==="); //$NON-NLS-1$ - - ecm = cc; - - Configuration conf = cc.getCacheConfiguration(config.getCacheNameProxy().getPrimaryCacheAliasName()); - if (conf == null) { - throw new ResourceException("Program Error: cache " + config.getCacheNameProxy().getPrimaryCacheAliasName() + " was not configured"); - } - conf.module(config.getCacheClassType()); - - if (config.getCacheNameProxy().getStageCacheAliasName() != null) { - conf = cc.getCacheConfiguration(config.getCacheNameProxy().getStageCacheAliasName()); - if (conf == null) { - throw new ResourceException("Program Error: cache " + config.getCacheNameProxy().getStageCacheAliasName() + " was not configured"); - } - - conf.module(config.getCacheClassType()); - } - } catch (IOException e) { - throw new ResourceException(e); - } - } else { - if (ecm == null) { - throw new ResourceException("Program Error: DefaultCacheManager was not configured"); - } - } - - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#isAlive() - */ - @Override - public boolean isAlive() { - if (ecm == null) return false; - return ecm.isRunning(getTargetCache()); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#getCache() - */ - @Override - public Cache getCache() { - if (getTargetCache() == null) { - return ecm.getCache(); - } - - return getCache(getTargetCache()); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#getCache(java.lang.String) - */ - @Override - public Cache getCache(String cacheName) { - return ecm.getCache(cacheName); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#getAll() - */ - @Override - public Collection getAll() { - Collection objs = new ArrayList(); - Cache c = getCache(); - for (Object k : c.keySet()) { - objs.add(c.get(k)); - } - return objs; - } - - /* split out for testing purposes */ - protected Object performJNDICacheLookup(String jndiName) throws Exception { - Context context = null; - - context = new InitialContext(); - final Object cache = context.lookup(jndiName); - - if (cache == null) { - throw new ResourceException( - InfinispanManagedConnectionFactory.UTIL - .getString( - "InfinispanManagedConnectionFactory.unableToFindCacheUsingJNDI", jndiName)); //$NON-NLS-1$ - } - - return cache; - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#cleanUp() - */ - @Override - public void cleanUp() { - ecm = null; - config = null; - - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#getQueryFactory() - */ - @SuppressWarnings("rawtypes") - @Override - public QueryFactory getQueryFactory() { - - return Search.getQueryFactory(getCache()); - - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#get(java.lang.Object) - */ - @Override - public Object get(Object key) { - return getCache().get(key); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#add(java.lang.Object, java.lang.Object) - */ - @Override - public void add(Object key, Object value) { - getCache(getTargetCache()).put(key, value); - } - - private String getTargetCache() { - return config.getCacheName(); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#remove(java.lang.Object) - */ - @Override - public Object remove(Object key) { - return getCache(getTargetCache()).removeAsync(key); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#update(java.lang.Object, java.lang.Object) - */ - @Override - public void update(Object key, Object value) { - getCache(getTargetCache()).replace(key, value); - } - - /** - * {@inheritDoc} - * - * @see org.teiid.translator.object.ObjectConnection#clearCache(java.lang.String) - */ - @Override - public void clearCache(String cacheName) throws TranslatorException { - getCache(cacheName).clear(); - } - - /** - * Note: This is used in testing only to enable shutting down the cache so that the next test can recreate it - * {@inheritDoc} - * - * @see org.teiid.resource.adapter.infinispan.InfinispanCacheWrapper#shutDownCacheManager() - */ - @Override - protected void shutDownCacheManager() { - ecm.stop(); - } - - /** - * Returns the SearchType that will be used to perform - * dynamic searching of the cache. - * @return SearchType - */ - @Override - public SearchType getSearchType() { - return new DSLSearch(this); - } - -} \ No newline at end of file diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanConfigFileLocalCache.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanConfigFileLocalCache.java index 2b3f627665..8d72b10a64 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanConfigFileLocalCache.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanConfigFileLocalCache.java @@ -68,7 +68,7 @@ public static void beforeEachClass() throws Exception { @AfterClass public static void closeConnection() throws Exception { - factory.getCacheWrapper().shutDownCacheManager(); + factory.shutDownCache(); } @Override diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiDSLSearch.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiDSLSearch.java index e3004af1ba..a1364a2e82 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiDSLSearch.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiDSLSearch.java @@ -90,7 +90,7 @@ protected Object performJNDICacheLookup(String jnidName) throws Exception { public static void closeConnection() throws Exception { CONNECTION.cleanUp(); - factory.shutDown(); + factory.shutDownCache(); } @Override diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiNameKeyOnlySearch.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiNameKeyOnlySearch.java index 69c29ff8ee..0e165dcc5d 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiNameKeyOnlySearch.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanJndiNameKeyOnlySearch.java @@ -89,7 +89,7 @@ protected Object performJNDICacheLookup(String jnidName) throws Exception { public static void closeConnection() throws Exception { CONNECTION.cleanUp(); - factory.shutDown(); + factory.shutDownCache(); } @Override diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanManagedConnectionFactory.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanManagedConnectionFactory.java index 3eda92646f..e43b0ea22d 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanManagedConnectionFactory.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanManagedConnectionFactory.java @@ -45,7 +45,7 @@ public void before() { @After public void after() { - factory.getCacheWrapper().shutDownCacheManager(); + factory.shutDownCache(); } @Test @@ -63,6 +63,10 @@ public void testCacheTypeMap1() throws Exception { assertEquals(InfinispanTestHelper.TRADE_CACHE_NAME, conn.getCacheName()); assertNotNull(conn.getClassRegistry()); + + assertNotNull(conn.getVersion()); + + System.out.println("Version " + conn.getVersion()); factory.cleanUp(); } diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanUpdateExecution.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanUpdateExecution.java index 344b4431f8..4f99e7b8b3 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanUpdateExecution.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TestInfinispanUpdateExecution.java @@ -54,7 +54,7 @@ public static void beforeEachClass() throws Exception { @AfterClass public static void afterClass() { CONNECTION.cleanUp(); - factory.shutDown(); + factory.shutDownCache(); } diff --git a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TradeAnnotatedObjectConnection.java b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TradeAnnotatedObjectConnection.java index 5ed3134820..27129ba067 100644 --- a/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TradeAnnotatedObjectConnection.java +++ b/connectors/connector-infinispan-libmode/src/test/java/org/teiid/resource/adapter/infinispan/TradeAnnotatedObjectConnection.java @@ -26,7 +26,6 @@ public TradeAnnotatedObjectConnection(Map map, ClassRegistry regi /** * {@inheritDoc} * - * @see org.teiid.translator.infinispan.cache.InfinispanCacheConnection#getQueryFactory() */ @SuppressWarnings("rawtypes") @Override diff --git a/connectors/translator-infinispan-hotrod/src/main/java/org/teiid/translator/infinispan/hotrod/InfinispanHotRodExecutionFactory.java b/connectors/translator-infinispan-hotrod/src/main/java/org/teiid/translator/infinispan/hotrod/InfinispanHotRodExecutionFactory.java index 53d3ffcd1c..6f40093682 100644 --- a/connectors/translator-infinispan-hotrod/src/main/java/org/teiid/translator/infinispan/hotrod/InfinispanHotRodExecutionFactory.java +++ b/connectors/translator-infinispan-hotrod/src/main/java/org/teiid/translator/infinispan/hotrod/InfinispanHotRodExecutionFactory.java @@ -51,6 +51,11 @@ */ @Translator(name = "ispn-hotrod", description = "The Infinispan Translator Using Hotrod Client to query cache") public class InfinispanHotRodExecutionFactory extends ObjectExecutionFactory { + + // with JDG 6.6 supportCompareCriteria no longer needs to be disabled + // @see @link https://issues.jboss.org/browse/TEIID-4333 + private static final String JDG6_6 = "6.6"; + // max available without having to try to override // BooleanQuery.setMaxClauseCount(), and @@ -163,4 +168,28 @@ public MetadataProcessor getMetadataProcessor(){ return new ProtobufMetadataProcessor(); } + /** + * {@inheritDoc} + * + * @see org.teiid.translator.ExecutionFactory#initCapabilities(java.lang.Object) + */ + @Override + public void initCapabilities(ObjectConnection connection) throws TranslatorException { + super.initCapabilities(connection); + if (connection == null) return; + + String version = connection.getVersion(); + + if (version != null) { + if (version.compareTo(JDG6_6) < 0) { + // any version prior to JDG 6.6 the supportCompareCritiaOrdered needs to be set to false; + } else { + this.supportsCompareCriteriaOrdered = true; + } + } + + } + + + } diff --git a/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanExecutionFactory.java b/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanExecutionFactory.java index 856a11853b..37a5d6fb2c 100644 --- a/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanExecutionFactory.java +++ b/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanExecutionFactory.java @@ -22,23 +22,24 @@ package org.teiid.translator.infinispan.hotrod; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.jboss.as.quickstarts.datagrid.hotrod.query.domain.PersonCacheSource; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.teiid.language.Select; import org.teiid.translator.ExecutionContext; -import org.teiid.translator.TranslatorException; -import org.teiid.translator.object.testdata.person.PersonSchemaVDBUtility; import org.teiid.translator.object.ObjectExecution; +import org.teiid.translator.object.testdata.person.PersonSchemaVDBUtility; @SuppressWarnings("nls") public class TestInfinispanExecutionFactory { + @SuppressWarnings("deprecation") protected static InfinispanExecutionFactory TRANSLATOR; + protected static InfinispanHotRodConnection CONNECTION; @Mock @@ -46,27 +47,64 @@ public class TestInfinispanExecutionFactory { @Mock private Select command; - - - private InfinispanHotRodConnection connection = PersonCacheSource.createConnection(true); - - @BeforeClass - public static void setUp() throws TranslatorException { - TRANSLATOR = new InfinispanExecutionFactory(); - TRANSLATOR.start(); - } @Before public void beforeEach() throws Exception{ - + MockitoAnnotations.initMocks(this); } @Test public void testFactory() throws Exception { + CONNECTION = PersonCacheSource.createConnection(true); + TestInfinispanHotRodConnection conn = (TestInfinispanHotRodConnection) CONNECTION; + conn.setVersion("6.6"); + + TRANSLATOR = new InfinispanExecutionFactory(); + TRANSLATOR.initCapabilities(CONNECTION); + TRANSLATOR.start(); - ObjectExecution exec = (ObjectExecution) TRANSLATOR.createExecution(command, context, PersonSchemaVDBUtility.RUNTIME_METADATA, connection); + assertTrue(TRANSLATOR.supportsCompareCriteriaOrdered()); + + ObjectExecution exec = (ObjectExecution) TRANSLATOR.createExecution(command, context, PersonSchemaVDBUtility.RUNTIME_METADATA, CONNECTION); assertNotNull(exec); assertNotNull(TRANSLATOR.getMetadataProcessor()); } + @Test public void testFactoryVersion7() throws Exception { + CONNECTION = PersonCacheSource.createConnection(true); + TestInfinispanHotRodConnection conn = (TestInfinispanHotRodConnection) CONNECTION; + conn.setVersion("7.2.3"); + + TRANSLATOR = new InfinispanExecutionFactory(); + TRANSLATOR.initCapabilities(CONNECTION); + TRANSLATOR.start(); + + assertTrue(TRANSLATOR.supportsCompareCriteriaOrdered()); + + + ObjectExecution exec = (ObjectExecution) TRANSLATOR.createExecution(command, context, PersonSchemaVDBUtility.RUNTIME_METADATA, CONNECTION); + + assertNotNull(exec); + assertNotNull(TRANSLATOR.getMetadataProcessor()); + } + + @Test public void testFactoryVersion65() throws Exception { + CONNECTION = PersonCacheSource.createConnection(true); + TestInfinispanHotRodConnection conn = (TestInfinispanHotRodConnection) CONNECTION; + conn.setVersion("6.5"); + + TRANSLATOR = new InfinispanExecutionFactory(); + TRANSLATOR.initCapabilities(CONNECTION); + TRANSLATOR.start(); + + assertTrue(!TRANSLATOR.supportsCompareCriteriaOrdered()); + + + ObjectExecution exec = (ObjectExecution) TRANSLATOR.createExecution(command, context, PersonSchemaVDBUtility.RUNTIME_METADATA, CONNECTION); + + assertNotNull(exec); + assertNotNull(TRANSLATOR.getMetadataProcessor()); + } + + } diff --git a/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanHotRodConnection.java b/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanHotRodConnection.java index 0b9bab7f02..1db9696d0c 100644 --- a/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanHotRodConnection.java +++ b/connectors/translator-infinispan-hotrod/src/test/java/org/teiid/translator/infinispan/hotrod/TestInfinispanHotRodConnection.java @@ -42,6 +42,7 @@ * */ public class TestInfinispanHotRodConnection extends SimpleMapCacheConnection implements InfinispanHotRodConnection { + protected String version; public static ObjectConnection createConnection(Map map) { CacheNameProxy proxy = new CacheNameProxy(TradesAnnotatedCacheSource.TRADES_CACHE_NAME); @@ -78,13 +79,6 @@ public Collection getAll() throws TranslatorException { return results; } -// -// -// @Override -// public DDLHandler getMaterializeLifeCycle() { -// return new DDLHandler(this, proxy); -// } - /** * {@inheritDoc} * @@ -94,4 +88,18 @@ public Collection getAll() throws TranslatorException { public Descriptor getDescriptor() throws TranslatorException { return null; } + + /** + * {@inheritDoc} + * + * @see org.teiid.translator.object.simpleMap.SimpleMapCacheConnection#getVersion() + */ + @Override + public String getVersion() { + return version; + } + + public void setVersion(String v) { + this.version = v; + } } diff --git a/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectConnection.java b/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectConnection.java index c8021f2503..6199bec7b3 100644 --- a/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectConnection.java +++ b/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectConnection.java @@ -34,6 +34,13 @@ */ public interface ObjectConnection { + /** + * Call to get the version of the data source that being used. + * @return String verison + * @throws TranslatorException + */ + public String getVersion() throws TranslatorException; + /** * Call to check the status of the connection * @return boolean true if the connection is alive. diff --git a/connectors/translator-object/src/main/java/org/teiid/translator/object/simpleMap/SimpleMapCacheConnection.java b/connectors/translator-object/src/main/java/org/teiid/translator/object/simpleMap/SimpleMapCacheConnection.java index abf34dd3c4..f8325f2f3a 100644 --- a/connectors/translator-object/src/main/java/org/teiid/translator/object/simpleMap/SimpleMapCacheConnection.java +++ b/connectors/translator-object/src/main/java/org/teiid/translator/object/simpleMap/SimpleMapCacheConnection.java @@ -39,6 +39,11 @@ public SimpleMapCacheConnection(Map cache, Map s this.registry = registry; this.proxy = proxy; } + + @Override + public String getVersion() { + return ""; + } @Override public Map getCache() throws TranslatorException { diff --git a/pom.xml b/pom.xml index 8258a8f9c5..bd735a166b 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ 2.5.0 - jdg-6.6 + jdg-7.0 7.2.3.Final 7.2.3.Final 3.1.5