Hi. I have 2 questions regarding Ignite & Cassandra. I'm using Ignite v1.8
I'm trying to get a very simple example working with read/write through to c*, but I'm having some difficulty. First, I'm trying to use the POJO strategy of configuration for both the key & value persistence with the class fieldnames slightly different than the column names, but defined in the @QuerySqlField(name="blah") annotation of the POJO. However, when it runs, I'm getting a "IgniteException: Failed to prepare Cassandra CQL statement: insert into <keyspace>. " and all of the column names are the lowercase names of the class field and not what is defined in the annotation. What's my problem? (configuration/class info to follow at the bottom) Second, none of my "java.sql.Timestamp" fields are showing up in the insert statement generated in the exception. My c* columns are defined as "timestamp" fields and what I've seen seems to indicate that those should be "java.sql.Timestamp" datatypes, but it's not working. How do I get my Timestamp fields to be recognized? =================== Ignite Exception: [Mule] 2016-12-16 09:13:21,901 WARN -com.datastax.driver.core.ReplicationStrategy$NetworkTopologyStrategy.computeTokenToReplicaMap(ReplicationStategy.java:198) - Error while computing token map for keyspace dev_cirad with datacenter dc1: could not achieve replication factor 3 (found 0 replicas only), check your keyspace replication settings. [09:13:22,324][SEVERE][main][CassandraCacheStore] Failed to execute Cassandra CQL statement: insert into "mykeyspace"."HistoryResult" ("histname", "sessionid", "vin", "createdby", "modifiedby", "results") values (?,?,?,?,?,?) using ttl 2592000; class org.apache.ignite.IgniteException: Failed to execute Cassandra CQL statement: insert into "mykeyspace"."HistoryResult" ("histname", "sessionid", "vin", "createdby", "modifiedby", "results") values (?,?,?,?,?,?) using ttl 2592000; at org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:163) Caused by: class org.apache.ignite.IgniteException: Failed to prepare Cassandra CQL statement: insert into "mykeyspace"."HistoryResult" ("histname", "sessionid", "vin", "createdby", "modifiedby", "results") values (?,?,?,?,?,?) using ttl 2592000; at org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.prepareStatement(CassandraSessionImpl.java:615) at org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.execute(CassandraSessionImpl.java:133) ... 20 more Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Unknown identifier histname at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50) at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37) at com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:98) at org.apache.ignite.cache.store.cassandra.session.CassandraSessionImpl.prepareStatement(CassandraSessionImpl.java:597) ... 21 more =================== cassandra-ignite.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <import resource="classpath:cassandra-connection-settings.xml" /> <bean id="HistoryResultCache_persistence_settings" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings"> <constructor-arg type="org.springframework.core.io.Resource" value="classpath:cassandra-persistence-settings.xml" /> </bean> <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> <property name="peerClassLoadingEnabled" value="true"/> <property name="discoverySpi"> <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <property name="ipFinder"> <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> <property name="addresses"> <list> <value>127.0.0.1:47500..47509</value> </list> </property> </bean> </property> </bean> </property> <property name="cacheConfiguration"> <list> <bean class="org.apache.ignite.configuration.CacheConfiguration"> <property name="name" value="HistoryResult" /> <property name="readThrough" value="true" /> <property name="writeThrough" value="true" /> <property name="cacheStoreFactory"> <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory"> <property name="dataSourceBean" value="cassandraAdminDataSource" /> <property name="persistenceSettingsBean" value="HistoryResultCache_persistence_settings" /> </bean> </property> </bean> </list> </property> </bean> </beans> =================== cassandra-connection-settings.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy"> <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy"> <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/> </constructor-arg> </bean> <util:list id="contactPoints" value-type="java.lang.String"> <value>127.0.0.1</value> </util:list> <bean id="cassandraAdminDataSource" class="org.apache.ignite.cache.store.cassandra.datasource.DataSource"> <property name="contactPoints" ref="contactPoints"/> <property name="user" value="user"/> <property name="password" value="p@ssw0rd"/> <property name="readConsistency" value="ONE"/> <property name="writeConsistency" value="ONE"/> <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/> </bean> </beans> =================== cassandra-persistence-settings.xml <persistence keyspace="mykeyspace" table="HistoryResult" ttl="2592000"> <tableOptions> comment = 'Test table for Ignite/Cassandra connection' AND read_repair_chance = 0.2 </tableOptions> <keyPersistence class="com.gm.model.HistoryResultKey" strategy="POJO" /> <valuePersistence class="com.gm.model.HistoryResult" strategy="POJO" /> </persistence> =================== HistoryResultKey.java public class HistoryResultKey { @AffinityKeyMapped @QuerySqlField(index=true, groups={"historyResultPK"}) private String vin; @QuerySqlField(index=true, groups={"historyResultPK"}, name="session_id") private String sessionId; @QuerySqlField(index=true, groups={"historyResultPK"}, name="hist_name") private String histName; public HistoryResultKey() { // No op. } =================== HistoryResult.java public class HistoryResult { @QuerySqlField private String vin; @QuerySqlField(name="session_id") private String sessionId; @QuerySqlField(name="session_time") private Timestamp sessionTime; @QuerySqlField(name="hist_name") private String histName; @QueryTextField private String results; @QuerySqlField(name="analysis_time") private Timestamp analysisTime; @QuerySqlField(name="created_dt") private Timestamp createdDate; @QuerySqlField(name="created_by") private String createdBy; @QuerySqlField(name="modified_dt") private Timestamp modifiedDate; @QuerySqlField(name="modified_by") private String modifiedBy; public HistoryResult() { // no op } =================== TestCassandraPersistence.java public class TestCassandraPersistence { /** Cache name. */ private static final String CACHE_NAME = HistoryResult.class.getSimpleName(); /** Global HistoryResultKey to use across entire example. */ private static HistoryResultKey key = new HistoryResultKey("vin1", "sessionId1", "histName2"); public static void main(String[] args) { try (Ignite ignite = Ignition.start("resources/cassandra-ignite.xml")) { System.out.println(StringUtils.EMPTY); System.out.println(">>> Cache store example started."); try (IgniteCache<HistoryResultKey, HistoryResult> cache = ignite .getOrCreateCache(new CacheConfiguration<HistoryResultKey, HistoryResult>(CACHE_NAME))) { // Write to C* HistoryResult result = generateHistoryResultFromKey(key); System.out.println(String.format(">>> Putting to C*. Key: [%s], Result: [%s]", key, result)); cache.put(key, result); // Clear cache System.out.println(StringUtils.EMPTY); System.out.println(">>> Clearing cache..."); cache.clear(key); // Read from C* System.out.println(StringUtils.EMPTY); System.out.println(">>> Cache retrieve example started."); HistoryResult result2 = cache.get(key); System.out.println(String.format(">>> Read from C*. Key: [%s], Result: [%s]", key, result2)); } System.out.println(StringUtils.EMPTY); } } private static HistoryResult generateHistoryResultFromKey(HistoryResultKey key) { HistoryResult result = null; if (key != null) { result = new HistoryResult(key.getVin(), key.getSessionId(), Timestamp.valueOf(LocalDateTime.now()), key.getHistName(), "results-" + LocalDateTime.now(), Timestamp.valueOf(LocalDateTime.now()), Timestamp.valueOf(LocalDateTime.now()), "creator", Timestamp.valueOf(LocalDateTime.now()), "updater"); } return result; } } -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-with-Cassandra-questions-errors-tp9607.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.