@PostConstruct public void loadRuleParentIds(){
  LOGGER.trace("Entering loadRuleParentIds()...");
  LOGGER.trace("Trying to get cache lock for " + RuleTagCache.cacheInitializedKey);
  clusterCache.acquireWriteLockOnKey(RuleTagCache.cacheInitializedKey);
  try {
    Boolean isRuleCachePostProcessed=Boolean.FALSE;
    if (clusterCache.hasKey(ruleCachePostProcessedKey)) {
      isRuleCachePostProcessed=(Boolean)clusterCache.getCopy(ruleCachePostProcessedKey);
    }
    if (!isRuleCachePostProcessed.booleanValue()) {
      LOGGER.info("Setting parent ids for rules...");
      ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(threadPoolMin,threadPoolMax,5,TimeUnit.SECONDS,new ArrayBlockingQueue<Runnable>(1000));
      LoaderTask task=new LoaderTask();
      int counter=0;
      for (      Long key : ruleTagCache.getKeys()) {
        task.addKey(key);
        counter++;
        if (counter == 500) {
          threadPoolExecutor.execute(task);
          task=new LoaderTask();
          counter=0;
        }
      }
      threadPoolExecutor.execute(task);
      threadPoolExecutor.shutdown();
      try {
        threadPoolExecutor.awaitTermination(1200,TimeUnit.SECONDS);
      }
 catch (      InterruptedException e) {
        LOGGER.warn("Exception caught while waiting for rule parent id loading threads to complete (waited longer then timeout?): ",e);
      }
      LOGGER.info("... rule parent ids set.");
      clusterCache.put(ruleCachePostProcessedKey,Boolean.TRUE);
    }
 else {
      LOGGER.info("Cache " + RuleTagCache.cacheInitializedKey + " was already initialized. No need for action..");
    }
  }
  finally {
    clusterCache.releaseWriteLockOnKey(RuleTagCache.cacheInitializedKey);
    LOGGER.trace("Released cache lock .. for " + RuleTagCache.cacheInitializedKey);
  }
  LOGGER.trace("Leaving loadRuleParentIds()");
}

@ PostConstruct public void loadRuleParentIds ( ) { LOGGER . trace ( "Entering loadRuleParentIds()..." ) ; LOGGER . trace ( "Trying to get cache lock for " + RuleTagCache . cacheInitializedKey ) ; clusterCache . acquireWriteLockOnKey ( RuleTagCache . cacheInitializedKey ) ; try { Boolean isRuleCachePostProcessed = Boolean . FALSE ; if ( clusterCache . hasKey ( ruleCachePostProcessedKey ) ) { isRuleCachePostProcessed = ( Boolean ) clusterCache . getCopy ( ruleCachePostProcessedKey ) ; } if ( ! isRuleCachePostProcessed . booleanValue ( ) ) { LOGGER . info ( "Setting parent ids for rules..." ) ; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor ( threadPoolMin , threadPoolMax , 5 , TimeUnit . SECONDS , new ArrayBlockingQueue < Runnable > ( 1000 ) ) ; LoaderTask task = new LoaderTask ( ) ; int counter = 0 ; for ( Long key : ruleTagCache . getKeys ( ) ) { task . addKey ( key ) ; counter ++ ; if ( counter == 500 ) { threadPoolExecutor . execute ( task ) ; task = new LoaderTask ( ) ; counter = 0 ; } } threadPoolExecutor . execute ( task ) ; threadPoolExecutor . shutdown ( ) ; try { threadPoolExecutor . awaitTermination ( 1200 , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { LOGGER . warn ( "Exception caught while waiting for rule parent id loading threads to complete (waited longer then timeout?): " , e ) ; } LOGGER . info ( "... rule parent ids set." ) ; clusterCache . put ( ruleCachePostProcessedKey , Boolean . TRUE ) ; } else { LOGGER . info ( "Cache " + RuleTagCache . cacheInitializedKey + " was already initialized. No need for action.." ) ; } } finally { clusterCache . releaseWriteLockOnKey ( RuleTagCache . cacheInitializedKey ) ; LOGGER . trace ( "Released cache lock .. for " + RuleTagCache . cacheInitializedKey ) ; } LOGGER . trace ( "Leaving loadRuleParentIds()" ) ; }
loads parent ids in batches of 500 on bean creation , if the distributed cache is being initialised .
