Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to [email protected] and follow simple instructions in
the reply.


Jenny B. wrote
> Hi
> 
> I am writing this test for a POC with Cassandra. My question is at the end
> of the test I do not see any new tables been created in test1 keyspace,
> neither is any data written. How do I persist data to the tables? Here is
> the test:
> 
> @Test
>   @SuppressWarnings("unchecked")
>   public void igniteCacheTest() {
>     Ignition.stopAll(true);
> 
>     LOGGER.info("Running Alert write tests");
> 
>     try (Ignite ignite =
> Ignition.start("C:/Ignite/ignite/modules/cassandra/store/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config-test.xml"))
> {
> 
>       // create alertCache
>       CacheConfiguration<AlertId, Alert> cacheConfiguration = new
> CacheConfiguration<>("alertCache");
>       cacheConfiguration.setIndexedTypes(AlertId.class, Alert.class);
> 
>       IgniteCache&lt;AlertId, Alert&gt; alertCache =
> ignite.getOrCreateCache(cacheConfiguration);
> 
>       Map&lt;AlertId, Alert&gt; alertMap =
> TestsHelper.getAlertIdAlertMap(500);
> 
>       LOGGER.info("writing to alert cache");
>       alertCache.putAll(alertMap);
> 
>       for (int i=0; i <= 500; i++){
>         alertMap = TestsHelper.getAlertIdAlertMap(500);
>         alertCache.putAll(alertMap);
>       }
> 
>       // create device cache
>       CacheConfiguration&lt;DeviceId, Device&gt; cacheConfig = new
> CacheConfiguration<>("deviceCache");
>       cacheConfig.setIndexedTypes(DeviceId.class, Device.class);
> 
>       IgniteCache&lt;DeviceId, Device&gt; deviceCache =
> ignite.getOrCreateCache(cacheConfig);
> 
>       Map&lt;DeviceId, Device&gt; deviceMap =
> TestsHelper.getDeviceMap(500);
> 
>       LOGGER.info("writing to device cache");
>       deviceCache.putAll(deviceMap);
> 
>       // join on devices
> 
>       String deviceInClauseSql = "select d.deviceName, d.status,
> d.customerId, a.alertType, a.year, a.dayOfYear, a.alertTimestamp "
>           + " from \"alertCache\".alert a, \"deviceCache\".device d "
>           + " where d.ts2cSerialNumber = a.ts2cSerialNumber "
>           + " and d.ts2cSerialNumber in ( 'TCMR-1000210', 'TCMR-1000312')
> "
>           + " order by a.alertTimestamp desc";
>       query = new SqlFieldsQuery(deviceInClauseSql);
>       start = System.currentTimeMillis();
>       result = alertCache.query(query).getAll();
>       gotResults = System.currentTimeMillis();
>       System.out.println(" In device condition " + result.size() + " time
> it took : " + (gotResults - start));
> 
>     }
>     Ignition.stopAll(true);
> 
>   }
>   
>   
>   Here is the config:
>   
>   <?xml version="1.0" encoding="UTF-8"?>
>   
>   
> <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:org/apache/ignite/tests/cassandra/connection-settings.xml"
> />
>   
>       

>       
> <bean id="alertCache_persistence_settings"
> class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
>           
> <constructor-arg type="org.springframework.core.io.Resource"
>                           
> value="classpath:org/apache/ignite/tests/persistence/pojo/alert-settings.xml"
> />
>       
> </bean>
>   
>       

>       
> <bean id="deviceCache_persistence_settings"
> class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
>           
> <constructor-arg type="org.springframework.core.io.Resource"
>                           
> value="classpath:org/apache/ignite/tests/persistence/pojo/device-settings.xml"
> />
>       
> </bean>
>   
>       
> <bean id="ignite.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>                   
> <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>
> 192.168.99.101:47500..47509
> </value>
>                                       
> </list>
>                                   
> </property>
>                               
> </bean>
>                           
> </property>
>                       
> </bean>
>                   
> </property>
>       
> </bean>
> </beans>
> I had this portion in the ignite-config, but commented it out after
> reading one of the comments on this forum.

>                 
> <bean class="org.apache.ignite.configuration.CacheConfiguration">
>                     
> <property name="name" value="alert"/>
>                     
> <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="alertCache_persistence_settings"/>
>                         
> </bean>
>                     
> </property>
>                 
> </bean>
>                 

> 
>                 
> <bean class="org.apache.ignite.configuration.CacheConfiguration">
>                     
> <property name="name" value="device"/>
>                     
> <property name="readThrough" value="true"/>
>                     
> <property name="writeThrough" value="true"/>
>                     
> <property name="atomicityMode" value="TRANSACTIONAL"/>
>                     
> <property name="cacheStoreFactory">
>                         
> <bean
> class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
>                             
> <property name="dataSourceBean" value="cassandraAdminDataSource"/>
>                             
> <property name="persistenceSettingsBean"
> value="deviceCache_persistence_settings"/>
>                         
> </bean>
>                     
> </property>
>                 
> </bean>
>             
> </list>
>         
> </property>
> 
> -->

Your configuration is incorrect.

First of all, it is partially provided in XML, and partially in the code,
that's not going to work. If you go with XML, put all the properties there
(including indexedTypes) and use ignite.cache(name) method to get
IgniteCache instance.

Second of all, name of the cache in XML config is "alert", while in the code
you used "alertCache". Basically, doing this you created another brand new
cache which is completely unaware of Cassandra configuration.

-Val



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Persisting-data-to-cassandra-tables-tp11825p11982.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to