@SuppressWarnings("WeakerAccess") protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, Lockable lock) { SecondLevelCacheLogger.INSTANCE.softLockedCacheExpired( getRegion().getName(), key ); log.info( "Cached entry expired : " + key ); // create new lock that times out immediately long ts = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); SoftLockImpl newLock = new SoftLockImpl( ts, uuid, nextLockId.getAndIncrement(), null ); //newLock.unlock( ts ); newLock.unlock( ts - getRegion().getRegionFactory().getTimeout() ); getStorageAccess().putIntoCache( key, newLock, session ); }
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) { try { writeLock.lock(); long timeout = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); log.debugf( "Locking cache item [region=`%s` (%s)] : `%s` (timeout=%s, version=%s)", getRegion().getName(), getAccessType(), key, timeout, version ); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); final SoftLockImpl lock = ( item == null ) ? new SoftLockImpl( timeout, uuid, nextLockId(), version ) : item.lock( timeout, uuid, nextLockId() ); getStorageAccess().putIntoCache( key, lock, session ); return lock; } finally { writeLock.unlock(); } }
@Override public void preInvalidate( String[] spaces, SharedSessionContractImplementor session) { final SessionFactoryImplementor factory = session.getFactory(); final RegionFactory regionFactory = factory.getCache().getRegionFactory(); final boolean stats = factory.getStatistics().isStatisticsEnabled(); final Long ts = regionFactory.nextTimestamp() + regionFactory.getTimeout(); for ( Serializable space : spaces ) { if ( DEBUG_ENABLED ) { log.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); } if ( stats ) { factory.getStatistics().updateTimestampsCachePut(); } } }
@SuppressWarnings("WeakerAccess") protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, Lockable lock) { SecondLevelCacheLogger.INSTANCE.softLockedCacheExpired( getRegion().getName(), key ); log.info( "Cached entry expired : " + key ); // create new lock that times out immediately long ts = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); SoftLockImpl newLock = new SoftLockImpl( ts, uuid, nextLockId.getAndIncrement(), null ); //newLock.unlock( ts ); newLock.unlock( ts - getRegion().getRegionFactory().getTimeout() ); getStorageAccess().putIntoCache( key, newLock, session ); }
@Override public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) { try { writeLock.lock(); long timeout = getRegion().getRegionFactory().nextTimestamp() + getRegion().getRegionFactory().getTimeout(); log.debugf( "Locking cache item [region=`%s` (%s)] : `%s` (timeout=%s, version=%s)", getRegion().getName(), getAccessType(), key, timeout, version ); Lockable item = (Lockable) getStorageAccess().getFromCache( key, session ); final SoftLockImpl lock = ( item == null ) ? new SoftLockImpl( timeout, uuid, nextLockId(), version ) : item.lock( timeout, uuid, nextLockId() ); getStorageAccess().putIntoCache( key, lock, session ); return lock; } finally { writeLock.unlock(); } }
@Override public void preInvalidate( String[] spaces, SharedSessionContractImplementor session) { final SessionFactoryImplementor factory = session.getFactory(); final RegionFactory regionFactory = factory.getCache().getRegionFactory(); final boolean stats = factory.getStatistics().isStatisticsEnabled(); final Long ts = regionFactory.nextTimestamp() + regionFactory.getTimeout(); for ( Serializable space : spaces ) { if ( DEBUG_ENABLED ) { log.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); } if ( stats ) { factory.getStatistics().updateTimestampsCachePut(); } } }