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" <slava.kopti...@gmail.com> 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/

Reply via email to