You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by siva <si...@bizruntime.com> on 2017/12/22 15:25:01 UTC
How to Load Data from DataBase to Ignite which have native
persistence enabled
Hi,
I am very new to ignite,I am working around the examples.
I have used cache store factory to load the data from sql server database to
ignite which is configured with native persistence
This is my code:
public String getData(String query, String key) throws Exception
{
String value = "";
Ignite ignite = Ignition.ignite();
String CACHE_NAME = key+"_schemas";
IgniteCache<String, EntitySchemas> cache= ignite.cache(CACHE_NAME);
if(cache==null||cache.size()==0)
{
IgniteCache<String,EntitySchemas> schemasCache =
createCacheForSchema(key,CacheAtomicityMode.ATOMIC);
schemasCache.loadCache(null);
}
IgniteQueryService service = new IgniteQueryService();
String result = service.query(CACHE_NAME,query);
return result;
}
private IgniteCache<String, EntitySchemas> createCacheForSchema(String key,
CacheAtomicityMode atomic) throws Exception {
Ignite ignite = Ignition.ignite();
String CACHE_NAME = key+"_schemas";
CacheConfiguration cacheCfg = new CacheConfiguration(CACHE_NAME);
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
cacheCfg.setIndexedTypes(String.class, EntitySchemas.class);
cacheCfg.setAtomicityMode(atomic);
// get sql connection
String connectionString = getSqlConnection(key, atomic);
// Configure store
cacheCfg.setCacheStoreFactory(new
DataCacheStoreFactory(connectionString));
cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
return ignite.getOrCreateCache(cacheCfg);
}
Here are my questions:
1. Is this right way to do?
Because I am using ignite with native persistence enabled but I am using
third party database to load data from database..?
2. What will be the performance issue because it will write in both file
system by ignite native persistence and into sql database by third party
database.?
and so,,,,
Thanks
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to Load Data from DataBase to Ignite which have native
persistence enabled
Posted by Pavel Tupitsyn <pt...@apache.org>.
> You can configure both native persistence and cache store
I think this is not officially supported, I believe
On Mon, Dec 25, 2017 at 3:05 PM, siva <si...@bizruntime.com> wrote:
> Do you really need both persistent stores enabled?
> Yes
>
> Do you use the SQL server store to integrate with other apps?
> Yes
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: How to Load Data from DataBase to Ignite which have native
persistence enabled
Posted by siva <si...@bizruntime.com>.
Do you really need both persistent stores enabled?
Yes
Do you use the SQL server store to integrate with other apps?
Yes
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to Load Data from DataBase to Ignite which have native
persistence enabled
Posted by Alexey Kukushkin <ku...@gmail.com>.
You can configure both native persistence and cache store with
write-through policy but it will not provide you consistency guarantees: it
would be possible that some data is persisted in one store but not the
other if a failure occurred.
Do you really need both persistent stores enabled? Do you use the SQL
server store to integrate with other apps?