@Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteNaturalIdRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalNaturalIdRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }
@Override public boolean afterUpdate(Object key, Object value, SoftLock lock) throws CacheException { RLock writeLock = mapCache.getReadWriteLock(key).writeLock(); writeLock.lock(); try { Lockable item = (Lockable) region.get(key); if (item != null && item.isUnlockable(lock)) { Lock lockItem = (Lock) item; if (lockItem.wasLockedConcurrently()) { decrementLock(key, lockItem); return false; } else { region.put(key, new Item(value, null, region.nextTimestamp())); return true; } } else { handleLockExpiry(key, item); return false; } } finally { writeLock.unlock(); } }
@Override public boolean afterUpdate(SessionImplementor session, Object key, Object value, SoftLock lock) throws CacheException { RLock writeLock = mapCache.getReadWriteLock(key).writeLock(); writeLock.lock(); try { Lockable item = (Lockable) region.get(session, key); if (item != null && item.isUnlockable(lock)) { Lock lockItem = (Lock) item; if (lockItem.wasLockedConcurrently()) { decrementLock(session, key, lockItem); return false; } else { region.put(session, key, new Item(value, null, region.nextTimestamp())); return true; } } else { handleLockExpiry(session, key, item); return false; } } finally { writeLock.unlock(); } }
@Override public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock) throws CacheException { RLock writeLock = mapCache.getReadWriteLock(key).writeLock(); writeLock.lock(); try { Lockable item = (Lockable) region.get(session, key); if (item != null && item.isUnlockable(lock)) { Lock lockItem = (Lock) item; if (lockItem.wasLockedConcurrently()) { decrementLock(session, key, lockItem); return false; } else { region.put(session, key, new Item(value, null, region.nextTimestamp())); return true; } } else { handleLockExpiry(session, key, item); return false; } } finally { writeLock.unlock(); } }
@Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteNaturalIdRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalNaturalIdRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }
@Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (accessType == AccessType.READ_ONLY) { return new ReadOnlyNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.READ_WRITE) { return new ReadWriteNaturalIdRegionAccessStrategy(settings, this, mapCache); } if (accessType == AccessType.NONSTRICT_READ_WRITE) { return new NonStrictReadWriteNaturalIdRegionAccessStrategy(settings, this); } if (accessType == AccessType.TRANSACTIONAL) { return new TransactionalNaturalIdRegionAccessStrategy(settings, this); } throw new CacheException("Unsupported access strategy: " + accessType); }