You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by michal23849 <mi...@gmail.com> on 2018/09/26 14:06:18 UTC

Reading from the SQLServer persistence store with write-behind setting

Hi,

I have the persistence store setup to use the write-behind setting and it
works pretty smoothly. 
					<property name="writeThrough" value="true"/>
					<property name="writeBehindEnabled" value="true"/>

I wanted to ask how we can use this persistence store as the source of data
- actually read from the database when starting the Ignite cluster. 

Could you please provide some usecases to test the Ignite failure scenario
so that the data are restored from the SQLServer database. 

I have some doubts how it works as some Ignite data are converted to strings
(datetime) and no idea how Ignite would process it.

Thank you
Michal



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

Re: Reading from the SQLServer persistence store with write-behind setting

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

In the snippet that you have provided I could see no such mappings, that's
what I noticed. If you have such mappings they should be used, please
provide them as example if that is not the case.

The documentation which I have pointed to in previous answer contains large
chunks of code to implement loadCache().

Regards,
-- 
Ilya Kasnacheev


пн, 1 окт. 2018 г. в 10:44, michal23849 <mi...@gmail.com>:

> Hi Ilya,
>
> I do have all the mappings configured for all my caches and they are
> written
> successfully to SQLServer database using the writeBehind setting.
>
> My question is - will these mapping automatically be used when I want to
> use
> the readThrough functionality or do I have to specify some additional
> mappings or implementation of any other classes?
>
> Can you give some examples of using the loadCache, loadAll, getAll?
>
> Regards
> Michal
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Reading from the SQLServer persistence store with write-behind setting

Posted by michal23849 <mi...@gmail.com>.
Hi Ilya,

I do have all the mappings configured for all my caches and they are written
successfully to SQLServer database using the writeBehind setting.

My question is - will these mapping automatically be used when I want to use
the readThrough functionality or do I have to specify some additional
mappings or implementation of any other classes? 

Can you give some examples of using the loadCache, loadAll, getAll?

Regards
Michal



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

Re: Reading from the SQLServer persistence store with write-behind setting

Posted by "ilya.kasnacheev" <il...@gmail.com>.
Hello!

In order to use loadCaches you will have to define types in jdbc cache
store, since it obviously needs to know structure of your data.

You can find example of that in Ignite documentation:
https://apacheignite.readme.io/docs/3rd-party-store#section-manual

Regards,



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

Re: Reading from the SQLServer persistence store with write-behind setting

Posted by michal23849 <mi...@gmail.com>.
Hi,
do I have to write any method lor cache.loadCache or it should be used as
is?

Is using loadCache an alternative to using the readThrough?
I tried to use both options and can't see any attempt during starting my
cache to even try loading the data from my SQL Server database. ReadThrough
doesn't seem to work at all. Though the write-behind works absolutely fine.

Unless I am missing any extra configuration. I expected that it will use my
XML cache mappings.

My setup is below:

		<property name="cacheConfiguration">
			<list>
				<bean class="org.apache.ignite.configuration.CacheConfiguration">
					<property name="name" value="myCache"/>
					<property name="atomicityMode" value="TRANSACTIONAL"/>

					<property name="writeThrough" value="true"/>
					<property name="readThrough" value="true"/>
					<property name="writeBehindEnabled" value="true"/>
					<property name="cacheStoreFactory">
					<bean
class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
						<property name="dataSourceBean" value="IgniteDataSource" />
						<property name="dialect">
							<bean
class="org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect">
							</bean>
						</property>
(...)
					</bean>
					</property>
				</bean>

My Java code for starting cache:

	private static IgniteCache<myKey, myValue> myCache = null;

	public void start() throws StorageException {
		Ignite ignite = myCacheFactory.start();
		if (myCache == null) {
			synchronized(lock) {
				if (myCache == null) {
					myCache = ignite.getOrCreateCache("myCache");
					myCache.loadCache(null);
				}
			}
		}

How to trigger Ignite to actually try loading the data from the store
(CacheJdbcPojoStoreFactory using SQL Server JDBC driver).

Thanks
Michal




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

Re: Reading from the SQLServer persistence store with write-behind setting

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

You can run cache.loadCache(), it would try to use cache store to restore
cache.

You could also enable readThrough, test on per key basis.

Regards,
-- 
Ilya Kasnacheev


ср, 26 сент. 2018 г. в 17:06, michal23849 <mi...@gmail.com>:

> Hi,
>
> I have the persistence store setup to use the write-behind setting and it
> works pretty smoothly.
>                                         <property name="writeThrough"
> value="true"/>
>                                         <property
> name="writeBehindEnabled" value="true"/>
>
> I wanted to ask how we can use this persistence store as the source of data
> - actually read from the database when starting the Ignite cluster.
>
> Could you please provide some usecases to test the Ignite failure scenario
> so that the data are restored from the SQLServer database.
>
> I have some doubts how it works as some Ignite data are converted to
> strings
> (datetime) and no idea how Ignite would process it.
>
> Thank you
> Michal
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>