@Override public void initCache() { delegate.initCache(); }
public void loadSessions() { while (!isFinished()) { if (!isCoordinator()) { try { Thread.sleep(1000); } catch (InterruptedException ie) { log.error("Interrupted", ie); } } else { startLoading(); } } }
@Override public void run(KeycloakSession session) { InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class); Cache<String, Serializable> workCache = connections.getCache(InfinispanConnectionProvider.WORK_CACHE_NAME); InfinispanCacheInitializer ispnInitializer = new InfinispanCacheInitializer(sessionFactory, workCache, new OfflinePersistentUserSessionLoader(sessionsPerSegment), "offlineUserSessions", sessionsPerSegment, maxErrors); // DB-lock to ensure that persistent sessions are loaded from DB just on one DC. The other DCs will load them from remote cache. CacheInitializer initializer = new DBLockBasedCacheInitializer(session, ispnInitializer); initializer.initCache(); initializer.loadSessions(); // Initialize persister for periodically doing bulk DB updates of lastSessionRefresh timestamps of refreshed sessions persisterLastSessionRefreshStore = new PersisterLastSessionRefreshStoreFactory().createAndInit(session, true); }
@Override protected boolean isFinished() { return delegate.isFinished(); }
@Override protected boolean isCoordinator() { return delegate.isCoordinator(); }
/** * Just coordinator will run this. And there is DB-lock, so the delegate.startLoading() will be permitted just by the single DC */ @Override protected void startLoading() { DBLockManager dbLockManager = new DBLockManager(session); dbLockManager.checkForcedUnlock(); DBLockProvider dbLock = dbLockManager.getDBLock(); dbLock.waitForLock(); try { if (isFinished()) { log.infof("Task already finished when DBLock retrieved"); } else { delegate.startLoading(); } } finally { dbLock.releaseLock(); } } }