not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

classic Classic list List threaded Threaded
16 messages Options
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

I'm able to use Cassandra Together with Ignite Persistence (see the example
below) usingIgnite 2.8.1.  However I could not change to another keyspace
which has the same tables as the keyspace initially configurfed in the
ignite config file.  The data changes are still stored in the old keyspace
instead of the new keyspace that are in ignite config file.  It's seem to me
that the keyspace are cached in the Ignite native persistence layer.  

How do I change the keyspaces of Cassandra?  

The use case is that we use Ignite as cache initially with the data stored
in Cassandra.  With the data increase, caching all data is impractical.  So
we plan to flush the data into the disk when the memory reaches the limits.
We still want to store the data into Cassandra at the same time.  How do we
load the the existing data from Cassandra Store to Native Persistence store
when switching from Ignite Cache + Cassandra Store to Ignite Cache +Ignite
persistence + Cassandra Store?
Here is what I did -
1) duplicated the existing tables (no data) into the another keyspace in
Cassandra
2) read the data from the original keyspace with Cassndra driver. This
loaded the data into
  2.1) ignite cache and native persistence
  2.2) store the data into the new Cassandra keyspace.  it's undesirable to
the store the original data back to the original keyspace.
3) change the cassandra connection setting to switch to the original
keyspace because Ignite Cache and Native Persistence layer have all data
from the Cassandra.
  3.1) switching to the original cassandra keyspace did not take any effect.
The data changes were still stored into the new keyspace.  

Config files
1. cassandra-connection-settings.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">

    <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>
        <bean id="reconnectionPolicy"
           
class="com.datastax.driver.core.policies.ExponentialReconnectionPolicy">
            <constructor-arg name="baseDelayMs" value="100" />
            <constructor-arg name="maxDelayMs" value="6000000" />
        </bean>

        <bean id="retryPolicy"
            class="com.datastax.driver.core.policies.DefaultRetryPolicy">
        </bean>
       
               
    <bean
class="org.apache.ignite.cache.store.cassandra.datasource.DataSource"
name="cassandra">
        <property name="contactPoints" value="127.0.0.1:9042"/>
        <property name="user" value="cassandra"/>
        <property name="password" value="cassandra"/>
        <property name="readConsistency" value="ONE"/>
        <property name="writeConsistency" value="ONE"/>
        <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/>
        <property name="reconnectionPolicy"  ref="reconnectionPolicy"/>
        <property name="retryPolicy"         ref="retryPolicy"/>
    </bean>

</beans>

2. dim_store_key_persistence.xm
<persistence keyspace="ignitetest" table="dim_store">
    <keyPersistence class="com.procurant.model.IdKey" strategy="POJO">
                <partitionKey>
            <field name="id" column="id" />
        </partitionKey>    
    </keyPersistence>
    <valuePersistence class="com.procurant.model.DimStore" strategy="POJO" >  
    <field name="id" column="id" />
    <field name="name" column="name" />
    <field name="zip" column="zip" />
    <field name="addr" column="addr" />
    </valuePersistence>
</persistence>

3. ignite 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:cassandra-connection-settings.xml" />
        <import resource="classpath:ignite-discoverySpi-settings.xml" />

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

   
    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
               
                <property name="igniteInstanceName" value="MyCluster"/>
            <property name="peerClassLoadingEnabled" value="true"/>


                <property name="workDirectory"
value="/c:/apache/data/home/work-cassandra"/>
                       
        <property name="dataStorageConfiguration">
            <bean
class="org.apache.ignite.configuration.DataStorageConfiguration">
                       
                <property name="defaultDataRegionConfiguration">
                    <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
                        <property name="name" value="Default_Region"/>
                        <property name="initialSize" value="#{10L * 1024 *
1024}"/>
                       
                        <property name="maxSize" value="#{4L * 1024 * 1024 *
1024}"/>
                       
           
                        <property name="persistenceEnabled" value="true"/>
                    </bean>
                </property>
                                           
                <property name="storagePath"
value="c:/apache/data/simple-cassandra/storage"/>
                <property name="walFlushFrequency" value="10000"/>
                <property name="walMode" value="LOG_ONLY"/>
                <property name="walPath"      
value="c:/apache/data/simple-cassandra/wal"/>
                <property name="walArchivePath"
value="c:/apache/data/simple-cassandra/wal/archive"/>                                                          
            </bean>
        </property>
       
        <property name="cacheConfiguration">
            <list>


                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="DimStore"/>
                    <property name="cacheMode" value="REPLICATED"/>
                    <property name="atomicityMode" value="TRANSACTIONAL"/>                  
                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>                    
                    <property name="sqlSchema" value="partition"/>
                    <property name="indexedTypes">
                        <list>
                            <value
type="java.lang.Class">com.procurant.model.IdKey</value>
                            <value
type="java.lang.Class">com.procurant.model.DimStore</value>
                        </list>
                    </property>
                   
                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                            <property name="dataSource" ref="cassandra"/>
                            <property name="persistenceSettingsBean"
value="dim_store_persistence_settings"></property>
                        </bean>
                    </property>
               
                </bean>
               
            </list>
        </property>
       
        <property name="discoverySpi" >
            <ref bean="tcpDiscoverySpi"/>
                </property>
               

           
    </bean>
       
</beans>




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

I'm afraid that you may need to drop and recreate these caches to change their configuration, including Cache Store config.

Regards,
--
Ilya Kasnacheev


пн, 28 сент. 2020 г. в 00:27, xmw45688 <[hidden email]>:
I'm able to use Cassandra Together with Ignite Persistence (see the example
below) usingIgnite 2.8.1.  However I could not change to another keyspace
which has the same tables as the keyspace initially configurfed in the
ignite config file.  The data changes are still stored in the old keyspace
instead of the new keyspace that are in ignite config file.  It's seem to me
that the keyspace are cached in the Ignite native persistence layer. 

How do I change the keyspaces of Cassandra? 

The use case is that we use Ignite as cache initially with the data stored
in Cassandra.  With the data increase, caching all data is impractical.  So
we plan to flush the data into the disk when the memory reaches the limits.
We still want to store the data into Cassandra at the same time.  How do we
load the the existing data from Cassandra Store to Native Persistence store
when switching from Ignite Cache + Cassandra Store to Ignite Cache +Ignite
persistence + Cassandra Store?
Here is what I did -
1) duplicated the existing tables (no data) into the another keyspace in
Cassandra
2) read the data from the original keyspace with Cassndra driver. This
loaded the data into
  2.1) ignite cache and native persistence
  2.2) store the data into the new Cassandra keyspace.  it's undesirable to
the store the original data back to the original keyspace.
3) change the cassandra connection setting to switch to the original
keyspace because Ignite Cache and Native Persistence layer have all data
from the Cassandra.
  3.1) switching to the original cassandra keyspace did not take any effect.
The data changes were still stored into the new keyspace.   

Config files
1. cassandra-connection-settings.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">

    <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>
        <bean id="reconnectionPolicy"

class="com.datastax.driver.core.policies.ExponentialReconnectionPolicy">
            <constructor-arg name="baseDelayMs" value="100" />
            <constructor-arg name="maxDelayMs" value="6000000" />
        </bean>

        <bean id="retryPolicy"
            class="com.datastax.driver.core.policies.DefaultRetryPolicy">
        </bean>


    <bean
class="org.apache.ignite.cache.store.cassandra.datasource.DataSource"
name="cassandra">
        <property name="contactPoints" value="127.0.0.1:9042"/>
        <property name="user" value="cassandra"/>
        <property name="password" value="cassandra"/>
        <property name="readConsistency" value="ONE"/>
        <property name="writeConsistency" value="ONE"/>
        <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/>
        <property name="reconnectionPolicy"  ref="reconnectionPolicy"/>
        <property name="retryPolicy"         ref="retryPolicy"/>
    </bean>

</beans>

2. dim_store_key_persistence.xm
<persistence keyspace="ignitetest" table="dim_store">
    <keyPersistence class="com.procurant.model.IdKey" strategy="POJO">
                <partitionKey>
            <field name="id" column="id" />
        </partitionKey>   
    </keyPersistence>
    <valuePersistence class="com.procurant.model.DimStore" strategy="POJO" > 
        <field name="id" column="id" />
        <field name="name" column="name" />
        <field name="zip" column="zip" />
        <field name="addr" column="addr" />
    </valuePersistence>
</persistence>

3. ignite 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:cassandra-connection-settings.xml" />       
        <import resource="classpath:ignite-discoverySpi-settings.xml" />


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


    <bean class="org.apache.ignite.configuration.IgniteConfiguration">

                <property name="igniteInstanceName" value="MyCluster"/>
            <property name="peerClassLoadingEnabled" value="true"/>


                <property name="workDirectory"
value="/c:/apache/data/home/work-cassandra"/>

        <property name="dataStorageConfiguration">
            <bean
class="org.apache.ignite.configuration.DataStorageConfiguration">

                <property name="defaultDataRegionConfiguration">
                    <bean
class="org.apache.ignite.configuration.DataRegionConfiguration">
                        <property name="name" value="Default_Region"/>
                        <property name="initialSize" value="#{10L * 1024 *
1024}"/>

                        <property name="maxSize" value="#{4L * 1024 * 1024 *
1024}"/>


                        <property name="persistenceEnabled" value="true"/>
                    </bean>
                </property>

                <property name="storagePath"
value="c:/apache/data/simple-cassandra/storage"/>
                <property name="walFlushFrequency" value="10000"/>
                <property name="walMode" value="LOG_ONLY"/>
                <property name="walPath"       
value="c:/apache/data/simple-cassandra/wal"/>
                <property name="walArchivePath"
value="c:/apache/data/simple-cassandra/wal/archive"/>                                                         
            </bean>
        </property>

        <property name="cacheConfiguration">
            <list>


                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="DimStore"/>
                    <property name="cacheMode" value="REPLICATED"/>
                    <property name="atomicityMode" value="TRANSACTIONAL"/>                   
                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>                   
                    <property name="sqlSchema" value="partition"/>
                    <property name="indexedTypes">
                        <list>
                            <value
type="java.lang.Class">com.procurant.model.IdKey</value>
                            <value
type="java.lang.Class">com.procurant.model.DimStore</value>
                        </list>
                    </property>

                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                            <property name="dataSource" ref="cassandra"/>
                            <property name="persistenceSettingsBean"
value="dim_store_persistence_settings"></property>
                        </bean>
                    </property>

                </bean>

            </list>
        </property>

        <property name="discoverySpi" >
            <ref bean="tcpDiscoverySpi"/>
                </property>



    </bean>

</beans>




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Thank you for your answer.  I'm able to load the data from Cassandra to
Ignite Cache stores using Cache.loadfull(....).  This works well for the use
cases where 3rd party persistence store is used first, then Ignite Native
Persistence store is used with 3rd party persistence together later.  

However, the configuration of 3rd party persistence store along with Ignite
Native Persistence store appears to be stored inside the Native Persistence
Store or somewhere, any changes in xml configuration will not propagate to
the 3rd party data store.  For example, adding a new column to an ignite
cache, the data for this newly added column is not saved in the 3rd party
persistence store when the data in is saved into the Ignite Native
Persistence Store.  In order to save the new added data for this new column,
the existing cache need be destroyed and created.  This works for caching
small sets of data.  It's probably not practically to destroy a cache with
huge data set and recreate the cache again.

I don't know what I've missed, or this is by design.  If it's by design, I'd
like to request an enhance so that the configuration can be dynamically read
from xml file when the Ignite Native Persistence store is configured with a
3rd party store together.





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

This is currently by design that cache configuration, of which cache store configuration is a part, cannot be changed after the cache is started.

Regards,
--
Ilya Kasnacheev


ср, 16 дек. 2020 г. в 04:29, xmw45688 <[hidden email]>:
Thank you for your answer.  I'm able to load the data from Cassandra to
Ignite Cache stores using Cache.loadfull(....).  This works well for the use
cases where 3rd party persistence store is used first, then Ignite Native
Persistence store is used with 3rd party persistence together later. 

However, the configuration of 3rd party persistence store along with Ignite
Native Persistence store appears to be stored inside the Native Persistence
Store or somewhere, any changes in xml configuration will not propagate to
the 3rd party data store.  For example, adding a new column to an ignite
cache, the data for this newly added column is not saved in the 3rd party
persistence store when the data in is saved into the Ignite Native
Persistence Store.  In order to save the new added data for this new column,
the existing cache need be destroyed and created.  This works for caching
small sets of data.  It's probably not practically to destroy a cache with
huge data set and recreate the cache again.

I don't know what I've missed, or this is by design.  If it's by design, I'd
like to request an enhance so that the configuration can be dynamically read
from xml file when the Ignite Native Persistence store is configured with a
3rd party store together.





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Thanks for your confirmation, Ilya.  

I do have a follow-up question for you.
When Ignite Persistence is used together with Cassandra.  The caches for
Cassandra table mappings are provided via xml file.  The java class for the
mappings is for BOTH Ignite Persistence and Cassandra cache store.  When a
table is changed, the mapping class gets changed, and the cluster is
started. Why is Ignite Persistence able to use this updated java class
(added/removed variables from the class) to insert/update data into Ignite
Persistence stores.  But for Cassandra Store, it appears to use the old
definition of class.  For this case, what's effort if we want to use the new
class of definition?  Do you think that it's reasonable to read the cache
configuration (i.e. via xml) dynamically for 3rd party Cache store which
does if the 3rd party store is used along.  I'm not an expert in java, I can
definitely help (or find a resource to do it) to improve this request.  

Pleas let me know if I can submit a feature request.

Appreciate your help.  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

I think that maybe you could try coding such a cache store which will update this information. It's just that the default Cassandra store doesn't seem to.

Regards, 
--
Ilya Kasnacheev


сб, 19 дек. 2020 г. в 05:17, xmw45688 <[hidden email]>:
Thanks for your confirmation, Ilya. 

I do have a follow-up question for you.
When Ignite Persistence is used together with Cassandra.  The caches for
Cassandra table mappings are provided via xml file.  The java class for the
mappings is for BOTH Ignite Persistence and Cassandra cache store.  When a
table is changed, the mapping class gets changed, and the cluster is
started. Why is Ignite Persistence able to use this updated java class
(added/removed variables from the class) to insert/update data into Ignite
Persistence stores.  But for Cassandra Store, it appears to use the old
definition of class.  For this case, what's effort if we want to use the new
class of definition?  Do you think that it's reasonable to read the cache
configuration (i.e. via xml) dynamically for 3rd party Cache store which
does if the 3rd party store is used along.  I'm not an expert in java, I can
definitely help (or find a resource to do it) to improve this request. 

Pleas let me know if I can submit a feature request.

Appreciate your help. 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Thanks for your suggestion, Ilya.  Can you give me a reference to override
default Cassandra Store implementation?  I thought that the changes would be
on Ignite Persistence side because caching data from standalone Cassandra
store (with Ignite Persistence) did read configuration including class
definition from the xml file.

Regards,
Xinmin  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

Why do you think that change should be on Ignite Persistence side? You said yourself that Ignite Persistence tracks the changes in class definition, it's the Cassandra store that does not.

Regards,
--
Ilya Kasnacheev


ср, 23 дек. 2020 г. в 00:17, xmw45688 <[hidden email]>:
Thanks for your suggestion, Ilya.  Can you give me a reference to override
default Cassandra Store implementation?  I thought that the changes would be
on Ignite Persistence side because caching data from standalone Cassandra
store (with Ignite Persistence) did read configuration including class
definition from the xml file.

Regards,
Xinmin   



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hi Ilya,

Thanks for your guidance and happy new year!  Sorry for late catchup.

You are right, Ignite Native Persistence does track the changes in class
definition for "Ignite Native Persistence".  But the configuration to load
data from Cache to Cassandra store is stored in xml configuration file.
This configuration xml file is passed at runtime (see the example
configuration below). When ignite server is stopped, the cache configuration
is gone, not stored in the any place as far as I understand.  When the
Ignite is restarted, the new xml is passed, there is no previous
configuration for the old class definition in the xml configuration.  

My question - how/where does the ignite server get/read the old class
definition if this class definition is provided in the most recent xml
config file?

So what I said is that the Cassandra Store implementation may not need to
change.  It's the call that reads the xml configuration and stores the data
in Cassandra Store via Ignite Cache.   If I remove Ignite Native
configuration ("persistenceEnabled" value="false"), then Ignite server uses
the xml configuration file passed at runtime.  The Ignite Cache has all new
class definiton.

I'd like your help to guide me make the changes to read the xml
configuration at runtime instead of reading the previously cached
configuration.


    <bean id="catalog_uom_persistence_settings"
class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
        <constructor-arg type="java.lang.String">
            <value>
            </value>
        </constructor-arg>
    </bean>

        <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
                           
                <property name="defaultDataRegionConfiguration">
                        <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                                <property name="name" value="Default_Region"/>
                                <property name="initialSize" value="#{10L * 1024 * 1024}"/>
                               
                                <property name="maxSize" value="#{2L * 1024 * 1024 * 1024}"/>
                               
                               
                                <property name="persistenceEnabled" value="true"/>
                        </bean>
                </property>                
        </bean>

        <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>
                <property name="indexedTypes">
                        <list>
                                <value type="java.lang.Class">java.lang.String</value>
                                <value type="java.lang.Class">com.procurant.catalog.entity.Uom</value>
                        </list>
                </property>
                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dataSource" ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </property>
        </bean>



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

Ignite will use existing cache configuration if cache is already present. There's nothing you can do here. This includes the cache store.

However, the cache store may determine what to keep in its serialized form, and what to re-read/infer every time it is started. So as I have said, you may improve Cassandra cache store to track environment changes.

Regards,

--
Ilya Kasnacheev


вт, 5 янв. 2021 г. в 04:38, xmw45688 <[hidden email]>:
Hi Ilya,

Thanks for your guidance and happy new year!  Sorry for late catchup.

You are right, Ignite Native Persistence does track the changes in class
definition for "Ignite Native Persistence".  But the configuration to load
data from Cache to Cassandra store is stored in xml configuration file.
This configuration xml file is passed at runtime (see the example
configuration below). When ignite server is stopped, the cache configuration
is gone, not stored in the any place as far as I understand.  When the
Ignite is restarted, the new xml is passed, there is no previous
configuration for the old class definition in the xml configuration. 

My question - how/where does the ignite server get/read the old class
definition if this class definition is provided in the most recent xml
config file?

So what I said is that the Cassandra Store implementation may not need to
change.  It's the call that reads the xml configuration and stores the data
in Cassandra Store via Ignite Cache.   If I remove Ignite Native
configuration ("persistenceEnabled" value="false"), then Ignite server uses
the xml configuration file passed at runtime.  The Ignite Cache has all new
class definiton.

I'd like your help to guide me make the changes to read the xml
configuration at runtime instead of reading the previously cached
configuration.


    <bean id="catalog_uom_persistence_settings"
class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
        <constructor-arg type="java.lang.String">
            <value>
            </value>
        </constructor-arg>
    </bean>

        <bean class="org.apache.ignite.configuration.DataStorageConfiguration">

                <property name="defaultDataRegionConfiguration">
                        <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                                <property name="name" value="Default_Region"/>
                                <property name="initialSize" value="#{10L * 1024 * 1024}"/>

                                <property name="maxSize" value="#{2L * 1024 * 1024 * 1024}"/>


                                <property name="persistenceEnabled" value="true"/>
                        </bean>
                </property>               
        </bean>

        <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>
                <property name="indexedTypes">
                        <list>
                                <value type="java.lang.Class">java.lang.String</value>
                                <value type="java.lang.Class">com.procurant.catalog.entity.Uom</value>
                        </list>
                </property>
                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dataSource" ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </property>
        </bean>



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

This post was updated on .
Thanks for your clarifications, and appreciated your suggestions and
guidance.  

My colleague and I went to ignite-cassandra module,  commented out two lines,
_for testing purpose_,  in
org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory.getPersistenceSettings(),
see the changes below.  Removing these two lines is to force Ignite to read
the configuration settings from the xml at runtime.  It looks the change
works and meets our requirement.  

I'm looking for the suggestions and recommendations from Ignite community
and you, and wondering if we make these changes in Ignite repository.  I
think that it's very useful for our Ignite community.  

Similar changes should be applied to
org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory.getDataSource()


    private KeyValuePersistenceSettings getPersistenceSettings() {
// comment out the two line below for testing purpose.
//        if (persistenceSettings != null)
//            return persistenceSettings;

        if (persistenceSettingsBean == null) {
            throw new IllegalStateException("Either persistence settings
bean or persistence settings itself " +
                "should be specified");
        }

        if (appCtx == null) {
            throw new IllegalStateException("Failed to get Cassandra
persistence settings cause Spring application " +
                "context wasn't injected into CassandraCacheStoreFactory");
        }

        Object obj = loadSpringContextBean(appCtx, persistenceSettingsBean);

        if (!(obj instanceof KeyValuePersistenceSettings)) {
            throw new IllegalStateException("Incorrect persistence settings
bean '" +
                persistenceSettingsBean + "' specified");
        }

        return persistenceSettings = (KeyValuePersistenceSettings)obj;
    }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

This seems like a valid change, however, there are issues with it: if you don't have persistence settings files on some nodes, it will cause failure on these nodes. It may also re-read these files too eagerly in its current form.

I can totally see how this may be an option to have in the Cassandra cache store, e.g. dynamicConfigurationReload={true/false} Please note that you also need to factor in Spring when updating data source life cycle = i.e. the data source may come from local Spring context on each node.

Feel free to file a ticket and contribute.

Regards,
--
Ilya Kasnacheev


чт, 7 янв. 2021 г. в 05:48, xmw45688 <[hidden email]>:
Thanks for your clarifications, and appreciated your suggestions and
guidance. 

My college and I went to ignite-cassandra module,  commented two lines,
*/testing purpose/*,  in
org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory.getPersistenceSettings(),
see the changes below.  Removing these two lines is to force Ignite to read
the configuration settings from the xml at runtime.  It looks the change
works and meets our requirement. 

I'm looking for the suggestions and recommendations from Ignite community
and you, and wondering if we make these changes in Ignite repository.  I
think that it's very useful for our Ignite community. 

Similar changes should be applied to
org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory.getDataSource()


    private KeyValuePersistenceSettings getPersistenceSettings() {
// comment the two line below for testing purpose.
//        if (persistenceSettings != null)
//            return persistenceSettings;

        if (persistenceSettingsBean == null) {
            throw new IllegalStateException("Either persistence settings
bean or persistence settings itself " +
                "should be specified");
        }

        if (appCtx == null) {
            throw new IllegalStateException("Failed to get Cassandra
persistence settings cause Spring application " +
                "context wasn't injected into CassandraCacheStoreFactory");
        }

        Object obj = loadSpringContextBean(appCtx, persistenceSettingsBean);

        if (!(obj instanceof KeyValuePersistenceSettings)) {
            throw new IllegalStateException("Incorrect persistence settings
bean '" +
                persistenceSettingsBean + "' specified");
        }

        return persistenceSettings = (KeyValuePersistenceSettings)obj;
    }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Thanks for your recommendations!
1) The dynamicConfigurationReload is not able to reset once
cacheStoreFactory is cached.  It means that cacheStoreFactory does not read
this value unless cacheStoreFactory is first instantiated.  Do I miss
something?  Which factory should I put dynamicConfigurationReload in the xml
configuration file?

2) can you please elaborate more about your comments "the data source may
come from local Spring context on each node.".  


        <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>
               
                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dynamicConfigurationReload"
value ="true" />
                                <property name="dataSource"
ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </pro


CassandraCacheStoreFactory changes

private boolean dynamicConfigurationReload;

    /**
     * @return Persistence settings.
     */
    private KeyValuePersistenceSettings getPersistenceSettings() {
   
              if (!isDynamicConfigurationReload() && persistenceSettings != null)
              return persistenceSettings;
           
                if (persistenceSettingsBean == null) {
                    throw new IllegalStateException("Either persistence settings
bean or persistence settings itself " +
                        "should be specified");
                }
       
                if (appCtx == null) {
                    throw new IllegalStateException("Failed to get Cassandra
persistence settings cause Spring application " +
                        "context wasn't injected into CassandraCacheStoreFactory");
                }
       
                Object obj = loadSpringContextBean(appCtx,
persistenceSettingsBean);
       
                if (!(obj instanceof KeyValuePersistenceSettings)) {
                    throw new IllegalStateException("Incorrect persistence settings
bean '" +
                        persistenceSettingsBean + "' specified");
                }
               
                return persistenceSettings = (KeyValuePersistenceSettings)obj;
               
       
    }
   
   
    public void setDynamicConfigurationReload(boolean
dynamicConfigurationReload ) {
    this.dynamicConfigurationReload = dynamicConfigurationReload;
    }
   
    public boolean isDynamicConfigurationReload() {
    return dynamicConfigurationReload;
    }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

1) Can you please elaborate? If you set this value in a cache store factory, it will keep this boolean value and deserialize it when node is started. I'm not entirely sure if Ignite will store cache store factory or cache store instance in the persistent cache configuration. My expectation it's the former, since cassandra data source is initialized dynamically.

2)
                                <property name="dataSource" ref="cassandra"/> <-- the value of this reference is a distinct object on each node, it is never replicated over the network nor taken from persistent cache configuration.
I'm not sure if it's relevant to your use case, I'm just reminding you to take care of its life cycle.

Does this change work for you?

Regards,
--
Ilya Kasnacheev


вт, 12 янв. 2021 г. в 06:30, xmw45688 <[hidden email]>:
Thanks for your recommendations!
1) The dynamicConfigurationReload is not able to reset once
cacheStoreFactory is cached.  It means that cacheStoreFactory does not read
this value unless cacheStoreFactory is first instantiated.  Do I miss
something?  Which factory should I put dynamicConfigurationReload in the xml
configuration file?

2) can you please elaborate more about your comments "the data source may
come from local Spring context on each node.". 


        <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>

                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dynamicConfigurationReload"
value ="true" />
                                <property name="dataSource"
ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </pro


CassandraCacheStoreFactory changes

private boolean dynamicConfigurationReload;

    /**
     * @return Persistence settings.
     */
    private KeyValuePersistenceSettings getPersistenceSettings() {

              if (!isDynamicConfigurationReload() && persistenceSettings != null)
              return persistenceSettings;

                if (persistenceSettingsBean == null) {
                    throw new IllegalStateException("Either persistence settings
bean or persistence settings itself " +
                        "should be specified");
                }

                if (appCtx == null) {
                    throw new IllegalStateException("Failed to get Cassandra
persistence settings cause Spring application " +
                        "context wasn't injected into CassandraCacheStoreFactory");
                }

                Object obj = loadSpringContextBean(appCtx,
persistenceSettingsBean);

                if (!(obj instanceof KeyValuePersistenceSettings)) {
                    throw new IllegalStateException("Incorrect persistence settings
bean '" +
                        persistenceSettingsBean + "' specified");
                }

                return persistenceSettings = (KeyValuePersistenceSettings)obj;


    }


    public void setDynamicConfigurationReload(boolean
dynamicConfigurationReload ) {
        this.dynamicConfigurationReload = dynamicConfigurationReload;
    }

    public boolean isDynamicConfigurationReload() {
        return dynamicConfigurationReload;
    }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
xmw45688 xmw45688
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

1) My testing shows that CassandraCacheStoreFactory is read from xml config
once if the cache name does not exist in Ignite Persistence. It appears that
CassandraCacheStoreFactory bean is persisted along with cache name in Ignite
Persistence Store, CassandraCacheStoreFactory will not be re-instantiated.
So I need to pre-decide dynamicConfigurationReload value. Modifying
dynamicConfigurationReload value later won't take effect at dynamically.  

<bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>

                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dynamicConfigurationReload"
value ="true" />
                                <property name="dataSource"
ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </property>
</bean>      

2) Yes, the similar implementation is applied to data source.  Thanks for
remaindering.  

3) given dynamicConfigurationReload is only loaded once at very first time
of creating cache, I'm thinking we don't use dynamicConfigurationReload,
instead implement the following
3.1) read data source from the xml config file each time an Ignite server
starts, if data source is not null, use the latest one, else use the
existing one.
3.2) read persistenceSettingsBean from xml config file each time an Ignite
server starts, if persistence settings are not null, use the latest one,
else using the existing one.
3.3) obviously, this is aggressive.  But how many times do we start/restart
an Ignite instance.  The performance impacts are minimal.  

if you think it's okay, I start implementing and testing.  
Let me know if you have any other suggestions/recommendations.

Appreciated your help.
Xinmin




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: not able to change keyspace name when Using 3rd Party Persistence (Cassandra) Together with Ignite Native Persistence

Hello!

Looks overall correct.

Regards,
--
Ilya Kasnacheev


чт, 14 янв. 2021 г. в 11:43, xmw45688 <[hidden email]>:
1) My testing shows that CassandraCacheStoreFactory is read from xml config
once if the cache name does not exist in Ignite Persistence. It appears that
CassandraCacheStoreFactory bean is persisted along with cache name in Ignite
Persistence Store, CassandraCacheStoreFactory will not be re-instantiated.
So I need to pre-decide dynamicConfigurationReload value. Modifying
dynamicConfigurationReload value later won't take effect at dynamically. 

<bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="Uom"/>
                <property name="atomicityMode" value="TRANSACTIONAL"/>
                <property name="cacheMode" value="REPLICATED"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="false"/>
                <property name="sqlSchema" value="catalog"/>

                <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                                <property name="dynamicConfigurationReload"
value ="true" />
                                <property name="dataSource"
ref="cassandra"/>
                                <property name="persistenceSettingsBean"
value="catalog_uom_persistence_settings"></property>
                        </bean>
                </property>
</bean>     

2) Yes, the similar implementation is applied to data source.  Thanks for
remaindering.   

3) given dynamicConfigurationReload is only loaded once at very first time
of creating cache, I'm thinking we don't use dynamicConfigurationReload,
instead implement the following
3.1) read data source from the xml config file each time an Ignite server
starts, if data source is not null, use the latest one, else use the
existing one.
3.2) read persistenceSettingsBean from xml config file each time an Ignite
server starts, if persistence settings are not null, use the latest one,
else using the existing one.
3.3) obviously, this is aggressive.  But how many times do we start/restart
an Ignite instance.  The performance impacts are minimal. 

if you think it's okay, I start implementing and testing. 
Let me know if you have any other suggestions/recommendations.

Appreciated your help.
Xinmin




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/