Kenan,

You can try to set IndexedType pair to cache configuration [1] to force
Ignite process annotations on Key\Value classes.

[1]
https://apacheignite.readme.io/docs/indexes#section-registering-indexed-types

On Tue, Oct 24, 2017 at 11:00 PM, Kenan Dalley <[email protected]> wrote:

> These were included in the project file link in the initial post. Here
> they are in text for reference. The only thing not posted is the pom.xml
> and it's just standard SpringBoot Ignite w/ Cassandra.
> cassandra-ignite.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!--
>   Licensed to the Apache Software Foundation (ASF) under one or more
>   contributor license agreements.  See the NOTICE file distributed with
>   this work for additional information regarding copyright ownership.
>   The ASF licenses this file to You under the Apache License, Version 2.0
>   (the "License"); you may not use this file except in compliance with
>   the License.  You may obtain a copy of the License at
>
>        http://www.apache.org/licenses/LICENSE-2.0
>
>   Unless required by applicable law or agreed to in writing, software
>   distributed under the License is distributed on an "AS IS" BASIS,
>   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>   See the License for the specific language governing permissions and
>   limitations under the License.
> -->
>
> <!--
>     Ignite configuration with all defaults and enabled p2p deployment and 
> enabled events.
> -->
> <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";>
>
>     <!-- Cassandra connection settings -->
>     <import resource="classpath:cassandra-connection-settings.xml" />
>
>     <bean id="test1Cache_persistence_settings" 
> class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
>         <constructor-arg type="org.springframework.core.io.Resource" 
> value="classpath:test1-cassandra-persistence-settings.xml" />
>     </bean>
>
>     <bean id="ignite.cfg" 
> class="org.apache.ignite.configuration.IgniteConfiguration">
>         <!-- Set to true to enable distributed class loading for examples, 
> default is false. -->
>         <property name="peerClassLoadingEnabled" value="true"/>
>
>         <!-- Explicitly configure TCP discovery SPI to provide list of 
> initial nodes. -->
>         <property name="discoverySpi">
>             <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
>                 <property name="ipFinder">
>                     <!--
>                         Ignite provides several options for automatic 
> discovery that can be used
>                         instead os static IP based discovery. For information 
> on all options refer
>                         to our documentation: 
> http://apacheignite.readme.io/docs/cluster-config
>                     -->
>                     <!-- Uncomment static IP finder to enable static-based 
> discovery of initial nodes. -->
>                     <!--<bean 
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
>                     <bean 
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
>                         <property name="addresses">
>                             <list>
>                                 <!-- In distributed environment, replace with 
> actual host IP address. -->
>                                 <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="Test1" />
>                     <property name="readThrough" value="true" />
>                     <property name="writeThrough" value="true" />
>                     <!-- <property name="writeBehindEnabled" value="true" /> 
> -->
>                     <property name="cacheStoreFactory">
>                         <bean 
> class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
>                             <!-- Datasource configuration bean which is 
> responsible for Cassandra connection details -->
>                             <property name="dataSourceBean" 
> value="cassandraDataSource" />
>                             <!-- Persistent settings bean which is 
> responsible for the details of how objects will be persisted to Cassandra -->
>                             <property name="persistenceSettingsBean" 
> value="test1Cache_persistence_settings" />
>                         </bean>
>                     </property>
>                 </bean>
>             </list>
>         </property>
>     </bean>
> </beans>
>
> test1-cassandra-persistence-settings.xml
>
> <persistence keyspace="keyspace" table="test1" ttl="2592000">
>     <keyPersistence class="com.gm.test_cassandra.model.Test1Key" 
> strategy="POJO" />
>     <valuePersistence class="com.gm.test_cassandra.model.Test1" 
> strategy="POJO" />
> </persistence>
>
> 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>server-name</value>
>     </util:list>
>
>     <bean id="cassandraDataSource" 
> class="org.apache.ignite.cache.store.cassandra.datasource.DataSource">
>         <property name="contactPoints" ref="contactPoints"/>
>         <property name="user" value="keyspace"/>
>         <property name="password" value="keyspace_pw"/>
>         <property name="readConsistency" value="ONE"/>
>         <property name="writeConsistency" value="ONE"/>
>         <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/>
>     </bean>
> </beans>
>
> Test1Key.java
>
> package com.gm.test_cassandra.model;
>
> import org.apache.ignite.cache.query.annotations.QuerySqlField;
>
> public class Test1Key {
>
>     //Partition Key
>     @QuerySqlField(index = true, groups = {"test1_PK"}, name = "my_id")
>     private transient String my_id;
>
>     public Test1Key() {
>     }
>
>     public Test1Key(final String my_id) {
>         this.my_id = my_id;
>     }
>
>     public String getMy_id() {
>         return my_id;
>     }
>
>     public void setMy_id(final String my_id) {
>         this.my_id = my_id;
>     }
>
>     @Override
>     public boolean equals(final Object o) {
>         if (this == o) {
>             return true;
>         }
>
>         if (!(o instanceof Test1Key)) {
>             return false;
>         }
>
>         final Test1Key other = (Test1Key) o;
>
>         if (this.my_id != null ? !this.my_id.equals(other.my_id) : 
> other.my_id != null) {
>             return false;
>         }
>         return true;
>     }
>
>     @Override
>     public int hashCode() {
>         return this.my_id != null ? this.my_id.hashCode() : 0;
>     }
>
>     @Override
>     public String toString() {
>         final StringBuilder sb = new StringBuilder();
>         sb.append("{");
>         sb.append(Test1Key.class.getSimpleName() + ": {");
>         sb.append("my_id: ");
>         sb.append(this.my_id);
>         sb.append("}}");
>         return sb.toString();
>     }
> }
>
> Test1.java
>
> package com.gm.test_cassandra.model;
>
> import java.util.Date;
> import org.apache.ignite.cache.query.annotations.QuerySqlField;
>
> public class Test1 {
>
>     /*
>         column_1 text,
>         column_2 timestamp,
>         column_3 text,
>         column_4 timestamp,
>         column_5 text,
>         column_6 text,
>         column_7 int,
>         column_8 text,
>         column_9 text
>     */
>     @QuerySqlField(name = "column_1")
>     private transient String column1;
>
>     @QuerySqlField(name = "column_2")
>     private transient Date column2;
>
>     @QuerySqlField(name = "column_3")
>     private transient String column3;
>
>     @QuerySqlField(name = "column_4")
>     private transient Date column4;
>
>     @QuerySqlField(name = "column_5")
>     private transient String column5;
>
>     @QuerySqlField(name = "column_6")
>     private transient String column6;
>
>     @QuerySqlField(name = "column_7")
>     private transient int column7;
>
>     @QuerySqlField(name = "column_8")
>     private transient String column8;
>
>     @QuerySqlField(name = "column_9")
>     private transient String column9;
>
>     public Test1() {
>     }
>
>     public String getColumn1() {
>         return column1;
>     }
>
>     public void setColumn1(String column1) {
>         this.column1 = column1;
>     }
>
>     public Date getColumn2() {
>         return column2;
>     }
>
>     public void setColumn2(Date column2) {
>         this.column2 = column2;
>     }
>
>     public String getColumn3() {
>         return column3;
>     }
>
>     public void setColumn3(String column3) {
>         this.column3 = column3;
>     }
>
>     public Date getColumn4() {
>         return column4;
>     }
>
>     public void setColumn4(Date column4) {
>         this.column4 = column4;
>     }
>
>     public String getColumn5() {
>         return column5;
>     }
>
>     public void setColumn5(String column5) {
>         this.column5 = column5;
>     }
>
>     public String getColumn6() {
>         return column6;
>     }
>
>     public void setColumn6(String column6) {
>         this.column6 = column6;
>     }
>
>     public int getColumn7() {
>         return column7;
>     }
>
>     public void setColumn7(int column7) {
>         this.column7 = column7;
>     }
>
>     public String getColumn8() {
>         return column8;
>     }
>
>     public void setColumn8(String column8) {
>         this.column8 = column8;
>     }
>
>     public String getColumn9() {
>         return column9;
>     }
>
>     public void setColumn9(String column9) {
>         this.column9 = column9;
>     }
>
>     @Override
>     public boolean equals(final Object o) {
>         if (this == o) {
>             return true;
>         }
>
>         if (!(o instanceof Test1)) {
>             return false;
>         }
>
>         final Test1 other = (Test1) o;
>
>         if (this.column1 != null ? !this.column1.equals(other.column1) : 
> other.column1 != null) {
>             return false;
>         }
>
>         if (this.column2 != null ? !this.column2.equals(other.column2) : 
> other.column2 != null) {
>             return false;
>         }
>
>         if (this.column3 != null ? !this.column3.equals(other.column3) : 
> other.column3 != null) {
>             return false;
>         }
>
>         if (this.column4 != null ? !this.column4.equals(other.column4) : 
> other.column4 != null) {
>             return false;
>         }
>
>         if (this.column5 != null ? !this.column5.equals(other.column5) : 
> other.column5 != null) {
>             return false;
>         }
>
>         if (this.column6 != null ? !this.column6.equals(other.column6) : 
> other.column6 != null) {
>             return false;
>         }
>
>         if (!(this.column7 == other.column7)) {
>             return false;
>         }
>
>         if (this.column8 != null ? !this.column8.equals(other.column8) : 
> other.column8 != null) {
>             return false;
>         }
>
>         if (this.column9 != null ? !this.column9.equals(other.column9) : 
> other.column9 != null) {
>             return false;
>         }
>
>         return true;
>     }
>
>     @Override
>     public int hashCode() {
>         int res = this.column1 != null ? this.column1.hashCode() : 0;
>         res = (31 * res) + (this.column2 != null ? this.column2.hashCode() : 
> 0);
>         res = (31 * res) + (this.column3 != null ? this.column3.hashCode() : 
> 0);
>         res = (31 * res) + (this.column4 != null ? this.column4.hashCode() : 
> 0);
>         res = (31 * res) + (this.column5 != null ? this.column5.hashCode() : 
> 0);
>         res = (31 * res) + (this.column6 != null ? this.column6.hashCode() : 
> 0);
>         res = (31 * res) + (this.column7);
>         res = (31 * res) + (this.column8 != null ? this.column8.hashCode() : 
> 0);
>         res = (31 * res) + (this.column9 != null ? this.column9.hashCode() : 
> 0);
>         return res;
>     }
>
>     @Override
>     public String toString() {
>         final StringBuilder sb = new StringBuilder();
>         sb.append("{");
>         sb.append(Test1.class.getSimpleName() + ": {");
>         sb.append("column1: ");
>         sb.append(this.column1);
>         sb.append(", column2: ");
>         sb.append(this.column2);
>         sb.append(", column3: ");
>         sb.append(this.column3);
>         sb.append(", column4: ");
>         sb.append(this.column4);
>         sb.append(", column5: ");
>         sb.append(this.column5);
>         sb.append(", column6: ");
>         sb.append(this.column6);
>         sb.append(", column7: ");
>         sb.append(this.column7);
>         sb.append(", column8: ");
>         sb.append(this.column8);
>         sb.append(", column9: ");
>         sb.append(this.column9);
>         sb.append("}}");
>         return sb.toString();
>     }
> }
>
> Application.java
>
> package com.gm.test_cassandra;
>
> import org.apache.commons.lang3.StringUtils;
> import org.apache.ignite.Ignite;
> import org.apache.ignite.IgniteCache;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.boot.Banner;
> import org.springframework.boot.CommandLineRunner;
> import org.springframework.boot.SpringApplication;
> import org.springframework.boot.autoconfigure.SpringBootApplication;
>
> import com.gm.test_cassandra.model.Test1;
> import com.gm.test_cassandra.model.Test1Key;
>
> @SpringBootApplication
> public class Application implements CommandLineRunner {
>     /**
>      * Cache name.
>      */
>     private static final String TEST1_CACHE_NAME = 
> Test1.class.getSimpleName();
>
>     private static Test1Key test1Key = new Test1Key("test123");
>
>     @Autowired
>     Ignite ignite;
>
>     public static void main(String... args) {
>         SpringApplication app = new SpringApplication(Application.class);
>         app.setBannerMode(Banner.Mode.OFF);
>         app.run(args);
>         System.exit(0);
>     }
>
>     @Override
>     public void run(String... strings) throws Exception {
>         test1();
>     }
>
>     private void test1() {
>         System.out.println(">>> Cassandra cache store Test1 example 
> started.");
>         try (IgniteCache<Test1Key, Test1> cache = this.ignite
>                 .cache(Application.TEST1_CACHE_NAME)) {
>
> //            System.out.println(StringUtils.EMPTY);
> //            System.out.println("Loading cache...");
> //
> //            cache.loadCache(null,
> //                            "select * from dev_qlty.test1 ");// +
> //                            //" where my_id = 'test123';");
> //            System.out.println(StringUtils.EMPTY);
> //            System.out.println("Cache size: " + cache.size());
> //
> //            Iterable<Cache.Entry<Test1Key, Test1>> entries = 
> cache.localEntries();
> //            Iterator<Cache.Entry<Test1Key, Test1>> it = entries.iterator();
> //            System.out.println(StringUtils.EMPTY);
> //            System.out.println("Entries...");
> //            while (it.hasNext()) {
> //                Cache.Entry<Test1Key, Test1> entry = it.next();
> //                System.out.println("Key: " + entry.getKey()+ ", Value: " + 
> entry.getValue());
> //            }
>
>             // Read from C*
>             System.out.println(StringUtils.EMPTY);
>             System.out.println(">>> Cache retrieve Vehicle example started.");
>
>             // Get with skipStore, Get with Store, Get with skipStore
> //            final Vehicle value1 = 
> cache.withSkipStore().get(Application.test2Key);
> //            System.out.println(
> //                    String.format(">>> Read from C* (get - skipStore => 
> expect \"null\" result).  Key: [%s], Value: [%s]", Application.test1Key,
> //                                  value1));
> //            final Vehicle value3 = cache.get(Application.test1Key);
>             final Test1 value3 = cache.get(new Test1Key("test123"));
>             System.out.println(
>                     String.format(">>> Read from C* (get).  Key: [%s], Value: 
> [%s]", Application.test1Key,
>                                   value3));
>
>             final Test1 value5 = 
> cache.withSkipStore().get(Application.test1Key);
>             System.out.println(
>                     String.format(">>> Read from C* (get - skipStore => 
> expect actual result).  Key: [%s], Value: [%s]",
>                                   Application.test1Key,
>                                   value5));
>         }
>         System.out.println(StringUtils.EMPTY);
>     }
> }
>
> ApplicationConfig.java
>
> package com.gm.test_cassandra.config;
>
> import org.apache.ignite.Ignite;
> import org.apache.ignite.Ignition;
> import org.springframework.context.annotation.Bean;
> import org.springframework.context.annotation.Configuration;
>
> @Configuration
> public class ApplicationConfig {
>     @Bean
>     public Ignite ignite() {
>         return Ignition.start("cassandra-ignite.xml");
>     }
> }
>
>
> ------------------------------
> Sent from the Apache Ignite Users mailing list archive
> <http://apache-ignite-users.70518.x6.nabble.com/> at Nabble.com.
>



-- 
Best regards,
Andrey V. Mashenkov

Reply via email to