Getting Invalid state exception when Persistance is enabled.

classic Classic list List threaded Threaded
10 messages Options
prasadbhalerao1983 prasadbhalerao1983
Reply | Threaded
Open this post in threaded view
|

Getting Invalid state exception when Persistance is enabled.

Hi,

I am starting ignite node in server mode in intellij. I am starting only one instance of it. I am using IgniteSpringBean to set configuration and start the node as shown below. But when I enable persistence, I get following exception.

Caused by: java.lang.IllegalStateException: Ignite is in invalid state to perform this operation. It either not started yet or has already being or have stopped [ignite=null, cfg=null]

As per the doc, IgniteSpringBean is responsible for starting the ignite. So how to set node to active state in case this case?

Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

Code to config ignite and cache:

@Bean
public IgniteSpringBean igniteInstance() {
IgniteSpringBean ignite = new IgniteSpringBean();
ignite.active(true);
ignite.setConfiguration(getIgniteConfiguration());

return ignite;
}

private IgniteConfiguration getIgniteConfiguration() {

String HOST = "127.0.0.1:47500..47509";
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList(HOST));

TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);

IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(discoSpi);
cfg.setIgniteInstanceName("springDataNode");
cfg.setPeerClassLoadingEnabled(false);
cfg.setRebalanceThreadPoolSize(4);

DataStorageConfiguration storageCfg = new DataStorageConfiguration();
storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
cfg.setDataStorageConfiguration(storageCfg);


CacheConfiguration<IPRangeDataKey, IPV4RangeData> ipv4RangeCacheCfg = new CacheConfiguration<>("IPV4RangeCache");
ipv4RangeCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ipv4RangeCacheCfg.setWriteThrough(false);
ipv4RangeCacheCfg.setReadThrough(false);
ipv4RangeCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
ipv4RangeCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ipv4RangeCacheCfg.setBackups(1);
Factory<IPV4RangeCacheDataLoader> storeFactory = FactoryBuilder.factoryOf(IPV4RangeCacheDataLoader.class);
ipv4RangeCacheCfg.setCacheStoreFactory(storeFactory);

cfg.setCacheConfiguration(ipv4RangeCacheCfg);
return cfg;
}

Thanks,
Prasad


slava.koptilin slava.koptilin
Reply | Threaded
Open this post in threaded view
|

Re: Getting Invalid state exception when Persistance is enabled.

Hi Prasad,

The root cause of IllegalStateException you observed is that the Ignite
instance is created within IgniteSpringBean#afterSingletonsInstantiated()
method which is triggered by the Spring Framework.
So, you should not call ignite.active(true) method here:
@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite = new IgniteSpringBean();

    // Please do not call active() method here
    // Ignite instance is not initialized yet.
    //ignite.active(true);

    ignite.setConfiguration(getIgniteConfiguration());

    return ignite;
}

One possible workaround is using Ignite LifecycleBeans [1]

// Lifecycle bean that activates the cluster.
public class MyLifecycleBean implements LifecycleBean {
    @IgniteInstanceResource
    private Ignite ignite;

    @Override public void onLifecycleEvent(LifecycleEventType evt) {
        if (evt == LifecycleEventType.AFTER_NODE_START) {
            ignite.active(true);
        }
    }
}

// Provide lifecycle bean to the configuration.
private IgniteConfiguration getIgniteConfiguration() {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setLifecycleBeans(new MyLifecycleBean());
    ...
    return cfg;
}

[1]
https://apacheignite.readme.io/docs/ignite-life-cycle#section-lifecyclebean

Thanks!



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

Re: Getting Invalid state exception when Persistance is enabled.

Hi Slava,
Thank you for solution.

Can you please help me with following question.

I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?


Regards,
Prasad

On Feb 20, 2018 11:49 PM, "slava.koptilin" <[hidden email]> wrote:
Hi Prasad,

The root cause of IllegalStateException you observed is that the Ignite
instance is created within IgniteSpringBean#afterSingletonsInstantiated()
method which is triggered by the Spring Framework.
So, you should not call ignite.active(true) method here:
@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite = new IgniteSpringBean();

    // Please do not call active() method here
    // Ignite instance is not initialized yet.
    //ignite.active(true);

    ignite.setConfiguration(getIgniteConfiguration());

    return ignite;
}

One possible workaround is using Ignite LifecycleBeans [1]

// Lifecycle bean that activates the cluster.
public class MyLifecycleBean implements LifecycleBean {
    @IgniteInstanceResource
    private Ignite ignite;

    @Override public void onLifecycleEvent(LifecycleEventType evt) {
        if (evt == LifecycleEventType.AFTER_NODE_START) {
            ignite.active(true);
        }
    }
}

// Provide lifecycle bean to the configuration.
private IgniteConfiguration getIgniteConfiguration() {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setLifecycleBeans(new MyLifecycleBean());
    ...
    return cfg;
}

[1]
https://apacheignite.readme.io/docs/ignite-life-cycle#section-lifecyclebean

Thanks!



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

Stanislav Lukyanov Stanislav Lukyanov
Reply | Threaded
Open this post in threaded view
|

Using 3rd party DB together with native persistence (WAS: Getting Invalid state exception when Persistance is enabled.)

In reply to this post by prasadbhalerao1983

Hi Prasad,

 

// Please send different questions separately – this way it’s easier to answer and to search for existing answers

 

> Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

 

Ignite doesn’t support using 3rd party DBs and native persistence with the same cache.

If you need to use both, I’d suggest to create two caches, one backed by Oracle and one with enabled Ignite persistence, and alternate between them in your application code.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 20 февраля 2018 г. 15:24
To: [hidden email]
Subject: Getting Invalid state exception when Persistance is enabled.

 

Hi,

 

I am starting ignite node in server mode in intellij. I am starting only one instance of it. I am using IgniteSpringBean to set configuration and start the node as shown below. But when I enable persistence, I get following exception.

 

Caused by: java.lang.IllegalStateException: Ignite is in invalid state to perform this operation. It either not started yet or has already being or have stopped [ignite=null, cfg=null]

 

As per the doc, IgniteSpringBean is responsible for starting the ignite. So how to set node to active state in case this case?

 

Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

Code to config ignite and cache:

 

@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite =
new IgniteSpringBean();
    ignite.active(
true);
    ignite.setConfiguration(getIgniteConfiguration());

   
return ignite;
}

private IgniteConfiguration getIgniteConfiguration() {

    String HOST =
"127.0.0.1:47500..47509";
    TcpDiscoveryVmIpFinder ipFinder =
new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singletonList(HOST));

    TcpDiscoverySpi discoSpi =
new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);

    IgniteConfiguration cfg =
new IgniteConfiguration();
    cfg.setDiscoverySpi(discoSpi);
    cfg.setIgniteInstanceName(
"springDataNode");
    cfg.setPeerClassLoadingEnabled(
false);
    cfg.setRebalanceThreadPoolSize(
4);

   DataStorageConfiguration storageCfg =
new DataStorageConfiguration();
    storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(
true);
    cfg.setDataStorageConfiguration(storageCfg);


    CacheConfiguration<IPRangeDataKey, IPV4RangeData> ipv4RangeCacheCfg =
new CacheConfiguration<>("IPV4RangeCache");
    ipv4RangeCacheCfg.setAtomicityMode(CacheAtomicityMode.
TRANSACTIONAL);
    ipv4RangeCacheCfg.setWriteThrough(
false);
    ipv4RangeCacheCfg.setReadThrough(
false);
    ipv4RangeCacheCfg.setRebalanceMode(CacheRebalanceMode.
ASYNC);
    ipv4RangeCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.
FULL_SYNC);
    ipv4RangeCacheCfg.setBackups(
1);
    Factory<IPV4RangeCacheDataLoader> storeFactory = FactoryBuilder.factoryOf(IPV4RangeCacheDataLoader.
class);
    ipv4RangeCacheCfg.setCacheStoreFactory(storeFactory);

    cfg.setCacheConfiguration(ipv4RangeCacheCfg);
   
return cfg;
}

 

Thanks,

Prasad

 

 

 

prasadbhalerao1983 prasadbhalerao1983
Reply | Threaded
Open this post in threaded view
|

Re: Using 3rd party DB together with native persistence (WAS: Getting Invalid state exception when Persistance is enabled.)

Hi Stan,

Thank you for the reply. I will send different questions separately now onwards.

I do not understand what are you trying to say ( "Ignite doesn’t support using 3rd party DBs and native persistence with the same cache" ) .

If the persistence is enabled and if you create or load the cache from 3rd party DB or any other source, data is always stored/backed in ignite native persistence store. 

I have enable the persistence using IgniteConfiguration. I believe that this configuration is global and so it is applicable to all the caches I have created. As per my understanding, if persistence is enabled any cache created will be stored/backed in ignite persistence store.
So now if I load the data in cache from oracle or any other DB table, it will be persisted in ignite native persistence file system. The point is I want to load the cache from oracle tables only first time or when the cache is empty. To load the cache from 3rd party DB I am using cache.loadCache method. 

I am checking cache size, if the size is zero I call loadCache method. If the cache is not empty it means that data is already loaded in previous attempt so no need to call loadCache method.
I just wanted to know if there is any better solution to achieve this.


Thanks,
Prasad

On Wed, Feb 21, 2018 at 1:33 PM, Stanislav Lukyanov <[hidden email]> wrote:

Hi Prasad,

 

// Please send different questions separately – this way it’s easier to answer and to search for existing answers

 

> Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

 

Ignite doesn’t support using 3rd party DBs and native persistence with the same cache.

If you need to use both, I’d suggest to create two caches, one backed by Oracle and one with enabled Ignite persistence, and alternate between them in your application code.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 20 февраля 2018 г. 15:24
To: [hidden email]
Subject: Getting Invalid state exception when Persistance is enabled.

 

Hi,

 

I am starting ignite node in server mode in intellij. I am starting only one instance of it. I am using IgniteSpringBean to set configuration and start the node as shown below. But when I enable persistence, I get following exception.

 

Caused by: java.lang.IllegalStateException: Ignite is in invalid state to perform this operation. It either not started yet or has already being or have stopped [ignite=null, cfg=null]

 

As per the doc, IgniteSpringBean is responsible for starting the ignite. So how to set node to active state in case this case?

 

Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

Code to config ignite and cache:

 

@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite =
new IgniteSpringBean();
    ignite.active(
true);
    ignite.setConfiguration(getIgniteConfiguration());

   
return ignite;
}

private IgniteConfiguration getIgniteConfiguration() {

    String HOST =
"127.0.0.1:47500..47509";
    TcpDiscoveryVmIpFinder ipFinder =
new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singletonList(HOST));

    TcpDiscoverySpi discoSpi =
new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);

    IgniteConfiguration cfg =
new IgniteConfiguration();
    cfg.setDiscoverySpi(discoSpi);
    cfg.setIgniteInstanceName(
"springDataNode");
    cfg.setPeerClassLoadingEnabled(
false);
    cfg.setRebalanceThreadPoolSize(
4);

   DataStorageConfiguration storageCfg =
new DataStorageConfiguration();
    storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(
true);
    cfg.setDataStorageConfiguration(storageCfg);


    CacheConfiguration<IPRangeDataKey, IPV4RangeData> ipv4RangeCacheCfg =
new CacheConfiguration<>("IPV4RangeCache");
    ipv4RangeCacheCfg.setAtomicityMode(CacheAtomicityMode.
TRANSACTIONAL);
    ipv4RangeCacheCfg.setWriteThrough(
false);
    ipv4RangeCacheCfg.setReadThrough(
false);
    ipv4RangeCacheCfg.setRebalanceMode(CacheRebalanceMode.
ASYNC);
    ipv4RangeCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.
FULL_SYNC);
    ipv4RangeCacheCfg.setBackups(
1);
    Factory<IPV4RangeCacheDataLoader> storeFactory = FactoryBuilder.factoryOf(IPV4RangeCacheDataLoader.
class);
    ipv4RangeCacheCfg.setCacheStoreFactory(storeFactory);

    cfg.setCacheConfiguration(ipv4RangeCacheCfg);
   
return cfg;
}

 

Thanks,

Prasad

 

 

 


Stanislav Lukyanov Stanislav Lukyanov
Reply | Threaded
Open this post in threaded view
|

RE: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

Sorry, I wasn’t completely correct. Persistence and CacheStore can work together, but if cache configured with write-through or read-through modes enabled then data consistency between Ignite persistence and CacheStore is not guaranteed at all times, so such configurations are usually avoided. However, from what you’re saying it seems that you don’t need write-through or read-through, so it should work fine.

Your solution seems OK. If you only need a one-time setup I guess you could also do it without a CacheStore and just get the data from Oracle and put it into Ignite via putAll or DataStreamer.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 21 февраля 2018 г. 14:33
To: [hidden email]
Subject: Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

 

Hi Stan,

 

Thank you for the reply. I will send different questions separately now onwards.

 

I do not understand what are you trying to say ( "Ignite doesn’t support using 3rd party DBs and native persistence with the same cache" ) .

 

If the persistence is enabled and if you create or load the cache from 3rd party DB or any other source, data is always stored/backed in ignite native persistence store. 

 

I have enable the persistence using IgniteConfiguration. I believe that this configuration is global and so it is applicable to all the caches I have created. As per my understanding, if persistence is enabled any cache created will be stored/backed in ignite persistence store.

So now if I load the data in cache from oracle or any other DB table, it will be persisted in ignite native persistence file system. The point is I want to load the cache from oracle tables only first time or when the cache is empty. To load the cache from 3rd party DB I am using cache.loadCache method. 

 

I am checking cache size, if the size is zero I call loadCache method. If the cache is not empty it means that data is already loaded in previous attempt so no need to call loadCache method.

I just wanted to know if there is any better solution to achieve this.

 

 

Thanks,

Prasad

 

On Wed, Feb 21, 2018 at 1:33 PM, Stanislav Lukyanov <[hidden email]> wrote:

Hi Prasad,

 

// Please send different questions separately – this way it’s easier to answer and to search for existing answers

 

> Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

 

Ignite doesn’t support using 3rd party DBs and native persistence with the same cache.

If you need to use both, I’d suggest to create two caches, one backed by Oracle and one with enabled Ignite persistence, and alternate between them in your application code.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 20 февраля 2018 г. 15:24
To: [hidden email]
Subject: Getting Invalid state exception when Persistance is enabled.

 

Hi,

 

I am starting ignite node in server mode in intellij. I am starting only one instance of it. I am using IgniteSpringBean to set configuration and start the node as shown below. But when I enable persistence, I get following exception.

 

Caused by: java.lang.IllegalStateException: Ignite is in invalid state to perform this operation. It either not started yet or has already being or have stopped [ignite=null, cfg=null]

 

As per the doc, IgniteSpringBean is responsible for starting the ignite. So how to set node to active state in case this case?

 

Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

Code to config ignite and cache:

 

@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite =
new IgniteSpringBean();
    ignite.active(
true);
    ignite.setConfiguration(getIgniteConfiguration());

   
return ignite;
}

private IgniteConfiguration getIgniteConfiguration() {

    String HOST =
"127.0.0.1:47500..47509";
    TcpDiscoveryVmIpFinder ipFinder =
new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singletonList(HOST));

    TcpDiscoverySpi discoSpi =
new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);

    IgniteConfiguration cfg =
new IgniteConfiguration();
    cfg.setDiscoverySpi(discoSpi);
    cfg.setIgniteInstanceName(
"springDataNode");
    cfg.setPeerClassLoadingEnabled(
false);
    cfg.setRebalanceThreadPoolSize(
4);

   DataStorageConfiguration storageCfg =
new DataStorageConfiguration();
    storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(
true);
    cfg.setDataStorageConfiguration(storageCfg);


    CacheConfiguration<IPRangeDataKey, IPV4RangeData> ipv4RangeCacheCfg =
new CacheConfiguration<>("IPV4RangeCache");
    ipv4RangeCacheCfg.setAtomicityMode(CacheAtomicityMode.
TRANSACTIONAL);
    ipv4RangeCacheCfg.setWriteThrough(
false);
    ipv4RangeCacheCfg.setReadThrough(
false);
    ipv4RangeCacheCfg.setRebalanceMode(CacheRebalanceMode.
ASYNC);
    ipv4RangeCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.
FULL_SYNC);
    ipv4RangeCacheCfg.setBackups(
1);
    Factory<IPV4RangeCacheDataLoader> storeFactory = FactoryBuilder.factoryOf(IPV4RangeCacheDataLoader.
class);
    ipv4RangeCacheCfg.setCacheStoreFactory(storeFactory);

    cfg.setCacheConfiguration(ipv4RangeCacheCfg);
   
return cfg;
}

 

Thanks,

Prasad

 

 

 

 

 

prasadbhalerao1983 prasadbhalerao1983
Reply | Threaded
Open this post in threaded view
|

Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

Hi Stan,

Could you please elaborate more on this point "but if cache configured with write-through or read-through modes enabled then data consistency between Ignite persistence and CacheStore is not guaranteed at all times" .

If I have enabled ignite persistence and my cache is also read-through and write-through then why does it not guarantee 100% data consistency?


Thanks,
Prasad

On Wed, Feb 21, 2018 at 7:29 PM, Stanislav Lukyanov <[hidden email]> wrote:

Sorry, I wasn’t completely correct. Persistence and CacheStore can work together, but if cache configured with write-through or read-through modes enabled then data consistency between Ignite persistence and CacheStore is not guaranteed at all times, so such configurations are usually avoided. However, from what you’re saying it seems that you don’t need write-through or read-through, so it should work fine.

Your solution seems OK. If you only need a one-time setup I guess you could also do it without a CacheStore and just get the data from Oracle and put it into Ignite via putAll or DataStreamer.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 21 февраля 2018 г. 14:33
To: [hidden email]
Subject: Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

 

Hi Stan,

 

Thank you for the reply. I will send different questions separately now onwards.

 

I do not understand what are you trying to say ( "Ignite doesn’t support using 3rd party DBs and native persistence with the same cache" ) .

 

If the persistence is enabled and if you create or load the cache from 3rd party DB or any other source, data is always stored/backed in ignite native persistence store. 

 

I have enable the persistence using IgniteConfiguration. I believe that this configuration is global and so it is applicable to all the caches I have created. As per my understanding, if persistence is enabled any cache created will be stored/backed in ignite persistence store.

So now if I load the data in cache from oracle or any other DB table, it will be persisted in ignite native persistence file system. The point is I want to load the cache from oracle tables only first time or when the cache is empty. To load the cache from 3rd party DB I am using cache.loadCache method. 

 

I am checking cache size, if the size is zero I call loadCache method. If the cache is not empty it means that data is already loaded in previous attempt so no need to call loadCache method.

I just wanted to know if there is any better solution to achieve this.

 

 

Thanks,

Prasad

 

On Wed, Feb 21, 2018 at 1:33 PM, Stanislav Lukyanov <[hidden email]> wrote:

Hi Prasad,

 

// Please send different questions separately – this way it’s easier to answer and to search for existing answers

 

> Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

 

Ignite doesn’t support using 3rd party DBs and native persistence with the same cache.

If you need to use both, I’d suggest to create two caches, one backed by Oracle and one with enabled Ignite persistence, and alternate between them in your application code.

 

Thanks,

Stan

 

From: [hidden email]
Sent: 20 февраля 2018 г. 15:24
To: [hidden email]
Subject: Getting Invalid state exception when Persistance is enabled.

 

Hi,

 

I am starting ignite node in server mode in intellij. I am starting only one instance of it. I am using IgniteSpringBean to set configuration and start the node as shown below. But when I enable persistence, I get following exception.

 

Caused by: java.lang.IllegalStateException: Ignite is in invalid state to perform this operation. It either not started yet or has already being or have stopped [ignite=null, cfg=null]

 

As per the doc, IgniteSpringBean is responsible for starting the ignite. So how to set node to active state in case this case?

 

Also, I am loading the cache from oracle table using loadCache method. If the persistence is enabled and if the data is already persisted, I want to make sure that the cache is loaded from persisted data instead of loading it from oracle table using loadCache. Can someone please advise how this can be achieved?

 

Code to config ignite and cache:

 

@Bean
public IgniteSpringBean igniteInstance() {
    IgniteSpringBean ignite =
new IgniteSpringBean();
    ignite.active(
true);
    ignite.setConfiguration(getIgniteConfiguration());

   
return ignite;
}

private IgniteConfiguration getIgniteConfiguration() {

    String HOST =
"127.0.0.1:47500..47509";
    TcpDiscoveryVmIpFinder ipFinder =
new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singletonList(HOST));

    TcpDiscoverySpi discoSpi =
new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);

    IgniteConfiguration cfg =
new IgniteConfiguration();
    cfg.setDiscoverySpi(discoSpi);
    cfg.setIgniteInstanceName(
"springDataNode");
    cfg.setPeerClassLoadingEnabled(
false);
    cfg.setRebalanceThreadPoolSize(
4);

   DataStorageConfiguration storageCfg =
new DataStorageConfiguration();
    storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(
true);
    cfg.setDataStorageConfiguration(storageCfg);


    CacheConfiguration<IPRangeDataKey, IPV4RangeData> ipv4RangeCacheCfg =
new CacheConfiguration<>("IPV4RangeCache");
    ipv4RangeCacheCfg.setAtomicityMode(CacheAtomicityMode.
TRANSACTIONAL);
    ipv4RangeCacheCfg.setWriteThrough(
false);
    ipv4RangeCacheCfg.setReadThrough(
false);
    ipv4RangeCacheCfg.setRebalanceMode(CacheRebalanceMode.
ASYNC);
    ipv4RangeCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.
FULL_SYNC);
    ipv4RangeCacheCfg.setBackups(
1);
    Factory<IPV4RangeCacheDataLoader> storeFactory = FactoryBuilder.factoryOf(IPV4RangeCacheDataLoader.
class);
    ipv4RangeCacheCfg.setCacheStoreFactory(storeFactory);

    cfg.setCacheConfiguration(ipv4RangeCacheCfg);
   
return cfg;
}

 

Thanks,

Prasad

 

 

 

 

 


Humphrey Humphrey
Reply | Threaded
Open this post in threaded view
|

Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

I think he means when *write-through* and *read-through* modes are enabled on
the 3rd party store, data might be written/read to/from one of those
persistence storage (not on both).

So if you save data "A" it might be stored in the 3rd party persistence, and
not in the native. When data "A" is not in the cache it might try to look it
up from the native persistence, where it's not available. Same could happen
with updates, if "A" was updated to "B" it could have changed in the 3rd
party but when requesting for the data again you might in one case get "A"
an other case "B" depending on the stores it reads the data from.

At least that is what I understand from his consistency between both stores.



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

Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

To my knowledge, the 2.4 release should have support for both persistence mechanisms, native and 3rd party, working together. The release is out for a vote already:

D.

On Mon, Feb 26, 2018 at 2:43 AM, Humphrey <[hidden email]> wrote:
I think he means when *write-through* and *read-through* modes are enabled on
the 3rd party store, data might be written/read to/from one of those
persistence storage (not on both).

So if you save data "A" it might be stored in the 3rd party persistence, and
not in the native. When data "A" is not in the cache it might try to look it
up from the native persistence, where it's not available. Same could happen
with updates, if "A" was updated to "B" it could have changed in the 3rd
party but when requesting for the data again you might in one case get "A"
an other case "B" depending on the stores it reads the data from.

At least that is what I understand from his consistency between both stores.



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

Andrey Mashenkov Andrey Mashenkov
Reply | Threaded
Open this post in threaded view
|

Re: Using 3rd party DB together with native persistence (WAS: GettingInvalid state exception when Persistance is enabled.)

Hi

It is very easy for user to shoot himself in a foot... and they do it again and again.... e.g. like this one [1].


On Thu, Mar 8, 2018 at 11:28 PM, Dmitriy Setrakyan <[hidden email]> wrote:
To my knowledge, the 2.4 release should have support for both persistence mechanisms, native and 3rd party, working together. The release is out for a vote already:

D.

On Mon, Feb 26, 2018 at 2:43 AM, Humphrey <[hidden email]> wrote:
I think he means when *write-through* and *read-through* modes are enabled on
the 3rd party store, data might be written/read to/from one of those
persistence storage (not on both).

So if you save data "A" it might be stored in the 3rd party persistence, and
not in the native. When data "A" is not in the cache it might try to look it
up from the native persistence, where it's not available. Same could happen
with updates, if "A" was updated to "B" it could have changed in the 3rd
party but when requesting for the data again you might in one case get "A"
an other case "B" depending on the stores it reads the data from.

At least that is what I understand from his consistency between both stores.



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