0

When starting an Ignite server I check if a cache exists if not create it and then call loadcache. Now I'm confused over what happens in a cluster where I have 5 server nodes, as all of them will do the same thing potentially the cache will loaded multiple times? If so how does one only load it once?

Any help greatly appreciated. Ron.

ronMilne
  • 57
  • 6

1 Answers1

0

I can see the following options:

  • Add an extra condition to check whether initial loading has been completed yet. Something like IgniteAtomicLong might serve as such an indicator:

      IgniteAtomicLong atomic = ignite.atomicLong("isInitial", 0, true);
      ...
    
      if (atomic.compareAndSet(0, 1) == true) {
        // ok, let's do initialization
      }
      else{
       // skip initialization
      }
    
  • Change your startup logic and yield a separate starter script or a compute task that will be started explicitly under your control. Just make sure to run it on a single node only.

  • Create a dedicated bootstrapper service and run it in a singleton mode

Alexandr Shapkin
  • 2,350
  • 1
  • 6
  • 10
  • Is it usual practice to load the grid from the outside after deployment? or given what you've stated above that's what preferred. I'm not sure what a bootstrapper service is :) – ronMilne Jan 17 '22 at 02:42
  • What's your deployment environment? Is it cloud/Kubernetes or just VMs? I'm not an expert with Ignite services either, just saw that people tend to use them. I think I'd go with a single initialization point, either option #2 or #3 if I have control over my grid. Sometimes, say, in k8s when your PODs are managed from outside, it might be ok to stick with option #1. – Alexandr Shapkin Jan 17 '22 at 15:06