Skip to content

Commit

Permalink
Merge branch 'teiid-4333' of https://github.com/vhalbert/teiid
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Aug 23, 2016
2 parents 7a79be1 + ab50531 commit e351b14
Show file tree
Hide file tree
Showing 33 changed files with 279 additions and 183 deletions.
6 changes: 3 additions & 3 deletions connectors/connector-infinispan-hotrod/pom.xml
Expand Up @@ -17,19 +17,19 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-bom</artifactId>
<version>${version.org.infinispan.6}</version>
<version>${version.org.infinispan.ds}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-remote-query-client</artifactId>
<version>${version.org.infinispan.6}</version>
<version>${version.org.infinispan.ds}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-hotrod</artifactId>
<version>${version.org.infinispan.6}</version>
<version>${version.org.infinispan.ds}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
Expand Down
Expand Up @@ -48,6 +48,7 @@
import org.teiid.translator.infinispan.hotrod.InfinispanPlugin;
import org.teiid.translator.object.CacheNameProxy;
import org.teiid.translator.object.ClassRegistry;
import org.teiid.translator.object.Version;


public abstract class AbstractInfinispanManagedConnectionFactory extends
Expand Down Expand Up @@ -85,6 +86,7 @@ private enum CACHE_TYPE {
private String module;
private ClassLoader cl;
private CacheNameProxy cacheNameProxy;
private Version version = null;



Expand Down Expand Up @@ -668,10 +670,10 @@ protected void registerWithCacheManager(SerializationContext ctx, RemoteCacheMan

}

public String getVersion() throws TranslatorException {
public Version getVersion() throws TranslatorException {
RemoteCache rc = this.getCache(this.getCacheNameProxy().getPrimaryCacheKey());
if (rc != null) return rc.getProtocolVersion();
return "";
return Version.getVersion(rc.getProtocolVersion());

}

@Override
Expand Down
Expand Up @@ -42,6 +42,7 @@
import org.teiid.translator.infinispan.hotrod.InfinispanPlugin;
import org.teiid.translator.object.DDLHandler;
import org.teiid.translator.object.SearchType;
import org.teiid.translator.object.Version;


/**
Expand All @@ -62,7 +63,7 @@ public InfinispanConnectionImpl(AbstractInfinispanManagedConnectionFactory confi
}

@Override
public String getVersion() throws TranslatorException {
public Version getVersion() throws TranslatorException {
return this.config.getVersion();
}

Expand Down
Expand Up @@ -34,10 +34,10 @@
import org.junit.Test;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.Version;


@SuppressWarnings("nls")
@Ignore
public class TestInfinispanConfigFileRemoteCache {

private static InfinispanManagedConnectionFactory factory = null;
Expand All @@ -55,7 +55,7 @@ public static void beforeEachClass() throws Exception {
Properties props = PropertiesUtils.load(f.getAbsolutePath());
props.setProperty("infinispan.client.hotrod.server_list", RemoteInfinispanTestHelper.hostAddress() + ":" + RemoteInfinispanTestHelper.hostPort());

PropertiesUtils.print("./target/jdg.properties", props);
PropertiesUtils.print("./target/hotrod-client.properties", props);

factory = new InfinispanManagedConnectionFactory();

Expand Down Expand Up @@ -87,8 +87,8 @@ public void testConnection() throws Exception {

assertNotNull(conn.getCache());

assertEquals("Version doesn't start with 7.2", conn.getVersion().startsWith("7.2"));
assertEquals("Support For Compare is false", conn.getVersion().compareTo(Version.getVersion("6.6")) >= 0, false );
// assertEquals("Version doesn't start with 7.2", conn.getVersion().startsWith("7.2"));


conn.cleanUp();
Expand Down
2 changes: 1 addition & 1 deletion connectors/connector-infinispan-libmode/pom.xml
Expand Up @@ -17,7 +17,7 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-bom</artifactId>
<version>${version.org.infinispan.6}</version>
<version>${version.org.infinispan.ds}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Expand Up @@ -21,7 +21,6 @@
*/
package org.teiid.resource.adapter.infinispan;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

Expand All @@ -30,10 +29,6 @@
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;
Expand All @@ -44,6 +39,7 @@
import org.teiid.translator.object.ClassRegistry;
import org.teiid.translator.object.DDLHandler;
import org.teiid.translator.object.SearchType;
import org.teiid.translator.object.Version;

/**
* @author vanhalbert
Expand All @@ -65,7 +61,7 @@ public InfinispanManagedConnectionFactory getConfig() {
}

@Override
public String getVersion() throws TranslatorException {
public Version getVersion() throws TranslatorException {
return this.getConfig().getVersion();
}
/**
Expand Down
Expand Up @@ -31,7 +31,6 @@
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;
Expand All @@ -49,6 +48,7 @@
import org.teiid.translator.TranslatorException;
import org.teiid.translator.object.CacheNameProxy;
import org.teiid.translator.object.ClassRegistry;
import org.teiid.translator.object.Version;

public class InfinispanManagedConnectionFactory extends
BasicManagedConnectionFactory {
Expand All @@ -70,6 +70,7 @@ public class InfinispanManagedConnectionFactory extends
private Class<?> cacheTypeClass = null; // cacheName ==> ClassType
private ClassLoader cl;
private CacheNameProxy cacheNameProxy;
private Version version = Version.getVersion("0.0.0");

@Override
public BasicConnectionFactory<InfinispanCacheRAConnection> createConnectionFactory()
Expand Down Expand Up @@ -385,13 +386,12 @@ protected synchronized InfinispanCacheRAConnection createCacheConnection() throw
this.getClass().getClassLoader());
loadClasses();

InfinispanCacheRAConnection conn = new InfinispanCacheRAConnection(this);
createCache();


// if configured for materialization, initialize the
if (cacheNameProxy.getAliasCacheName() != null) {
Map<Object,Object> aliasCache = (Map<Object, Object>) this.cacheManager.getCache(cacheNameProxy.getAliasCacheName());
Map<Object,Object> aliasCache = this.cacheManager.getCache(cacheNameProxy.getAliasCacheName());
if (aliasCache == null) {
throw new ResourceException(
InfinispanManagedConnectionFactory.UTIL
Expand All @@ -400,6 +400,9 @@ protected synchronized InfinispanCacheRAConnection createCacheConnection() throw
}
cacheNameProxy.initializeAliasCache(aliasCache);
}

Cache<Object, Object> cache = this.getCache(this.getCacheNameProxy().getPrimaryCacheKey());
version = Version.getVersion(cache.getVersion());

} catch (Exception e) {
throw new ResourceException(e);
Expand Down Expand Up @@ -465,7 +468,7 @@ private void createCache() throws TranslatorException {
throw new TranslatorException("Program Error: DefaultCacheManager was not configured");
}
}

}


Expand Down Expand Up @@ -565,10 +568,8 @@ public boolean isAlive() {
return false;
}

protected String getVersion() {
if (cacheManager == null) return "";

return cacheManager.getCache(this.getCacheNameProxy().getPrimaryCacheKey()).getVersion();
protected Version getVersion() {
return version;
}


Expand Down
2 changes: 1 addition & 1 deletion connectors/translator-infinispan-hotrod/pom.xml
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-bom</artifactId>
<version>${version.org.infinispan.6}</version>
<version>${version.org.infinispan.ds}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Expand Up @@ -37,11 +37,12 @@
import org.teiid.translator.infinispan.hotrod.metadata.ProtobufMetadataProcessor;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecutionFactory;
import org.teiid.translator.object.Version;



/**
* InfinispanExecutionFactory is the translator that will be use to translate a remote Infinispan cache and issue queries
* InfinispanExecutionFactory is the translator that will be use to translate a remote Infinispan cache and issue queries
* using hotrod client to query the cache.
*
* @author vhalbert
Expand All @@ -51,11 +52,7 @@
*/
@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";

public static final Version SIX_6 = Version.getVersion("6.6"); //$NON-NLS-1$

// max available without having to try to override
// BooleanQuery.setMaxClauseCount(), and
Expand Down Expand Up @@ -93,8 +90,7 @@ public int getMaxFromGroups() {
@Override
public ProcedureExecution createDirectExecution(List<Argument> arguments,
Command command, ExecutionContext executionContext,
RuntimeMetadata metadata, ObjectConnection connection)
throws TranslatorException {
RuntimeMetadata metadata, ObjectConnection connection) {
return super.createDirectExecution(arguments, command, executionContext,
metadata, connection);
}
Expand Down Expand Up @@ -174,20 +170,19 @@ public MetadataProcessor<ObjectConnection> getMetadataProcessor(){
* @see org.teiid.translator.ExecutionFactory#initCapabilities(java.lang.Object)
*/
@Override
public void initCapabilities(ObjectConnection connection) throws TranslatorException {
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;
}
if (connection == null) {
return;
}

Version version = connection.getVersion();
// with JDG 6.6 supportCompareCriteria no longer needs to be disabled
// @see @link https://issues.jboss.org/browse/TEIID-4333
if (version != null && version.compareTo(SIX_6) >= 0) {
this.supportsCompareCriteriaOrdered = true;
}

}


Expand Down
Expand Up @@ -21,10 +21,6 @@
*/
package org.jboss.as.quickstarts.datagrid.hotrod.query.domain;

import java.lang.annotation.Annotation;

import javax.resource.ResourceException;

import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.protostream.annotations.ProtoField;
import org.infinispan.protostream.descriptors.Descriptor;
Expand All @@ -34,6 +30,7 @@
import org.teiid.translator.infinispan.hotrod.TestInfinispanHotRodConnection;
import org.teiid.translator.object.CacheNameProxy;
import org.teiid.translator.object.ClassRegistry;
import org.teiid.translator.object.Version;

/**
* @author vanhalbert
Expand All @@ -44,10 +41,12 @@ public class PersonCacheConnection extends TestInfinispanHotRodConnection {
protected Descriptor descriptor;


public static InfinispanHotRodConnection createConnection(RemoteCache map, boolean useKeyClassType, Descriptor descriptor) {
public static InfinispanHotRodConnection createConnection(RemoteCache map, boolean useKeyClassType, Descriptor descriptor, Version version) {
CacheNameProxy proxy = new CacheNameProxy(PersonCacheSource.PERSON_CACHE_NAME);

return new PersonCacheConnection(map, PersonCacheSource.CLASS_REGISTRY, proxy, useKeyClassType, descriptor);
PersonCacheConnection conn = new PersonCacheConnection(map, PersonCacheSource.CLASS_REGISTRY, proxy, useKeyClassType, descriptor);
conn.setVersion(version);
return conn;
}

/**
Expand Down
Expand Up @@ -49,6 +49,7 @@
import org.infinispan.query.dsl.Query;
import org.teiid.translator.infinispan.hotrod.InfinispanHotRodConnection;
import org.teiid.translator.object.ClassRegistry;
import org.teiid.translator.object.Version;

/**
* Sample cache of objects
Expand Down Expand Up @@ -88,11 +89,14 @@ public class PersonCacheSource<K, V> implements RemoteCache<K, V>{
}
}


public static InfinispanHotRodConnection createConnection(final boolean useKeyClass) {
return createConnection(useKeyClass, Version.getVersion("10.2.1"));
}

public static InfinispanHotRodConnection createConnection(final boolean useKeyClass, Version version) {
final RemoteCache objects = PersonCacheSource.loadCache();

return PersonCacheConnection.createConnection(objects, useKeyClass, DESCRIPTOR);
return PersonCacheConnection.createConnection(objects, useKeyClass, DESCRIPTOR, version);

}

Expand All @@ -111,6 +115,7 @@ public static void loadCache(Map<Object, Object> cache) {
}

Person p = new Person();

p.setId(i);
p.setName("Person " + i);
p.setPhones(pns);
Expand Down

0 comments on commit e351b14

Please sign in to comment.