/** * Create a new LocalLockMergingSegmentReadLocker with special purpose caches * @param locksCache the cache to be used to store distributed locks * @param chunksCache the cache containing the chunks, this is where the bulk of data is stored * @param metadataCache smaller cache for the metadata of stored elements * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) locksCache, chunksCache, metadataCache, indexName, affinitySegmentId); }
/** * @return true if the lock was acquired, false if it's too late: the file * was deleted and this LocalReadLock should be removed too. */ boolean acquire() { if (value == 0) { boolean haveIt = delegate.acquireReadLock(name); if (haveIt) { value = 1; return true; } else { value = -1; return false; } } else if (value == -1) { // it was deleted just a two lines ago return false; } else { value++; return true; } }
void release() { value--; if (value <= 0) { localLocks.remove(name); delegate.deleteOrReleaseReadLock(name); } } }
if (isMultiChunked(filename)) { int newValue = 0; FileReadLockKey readLockKey = new FileReadLockKey(indexName, filename, affinitySegmentId); realFileDelete(indexName, filename, locksCache, chunksCache, metadataCache, forceSynchronousDeletes, affinitySegmentId); realFileDelete(indexName, filename, locksCache, chunksCache, metadataCache, forceSynchronousDeletes, affinitySegmentId);
public DistributedSegmentReadLocker(Cache<Object, Integer> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName) { if (locksCache == null) throw new IllegalArgumentException("locksCache must not be null"); if (chunksCache == null) throw new IllegalArgumentException("chunksCache must not be null"); if (metadataCache == null) throw new IllegalArgumentException("metadataCache must not be null"); if (indexName == null) throw new IllegalArgumentException("index name must not be null"); this.indexName = indexName; this.locksCache = locksCache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE, Flag.SKIP_CACHE_LOAD, Flag.SKIP_INDEXING); this.chunksCache = chunksCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); this.metadataCache = metadataCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); verifyCacheHasNoEviction(this.locksCache); }
realFileDelete(readLockKey, locksCache, chunksCache, metadataCache);
if (isMultiChunked(filename)) { int newValue = 0; FileReadLockKey readLockKey = new FileReadLockKey(indexName, filename, affinitySegmentId); realFileDelete(indexName, filename, locksCache, chunksCache, metadataCache, forceSynchronousDeletes, affinitySegmentId); realFileDelete(indexName, filename, locksCache, chunksCache, metadataCache, forceSynchronousDeletes, affinitySegmentId);
public DistributedSegmentReadLocker(Cache<Object, Integer> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, int affinitySegmentId, boolean forceSynchronousDeletes) { this.affinitySegmentId = affinitySegmentId; this.forceSynchronousDeletes = forceSynchronousDeletes; if (locksCache == null) throw new IllegalArgumentException("locksCache must not be null"); if (chunksCache == null) throw new IllegalArgumentException("chunksCache must not be null"); if (metadataCache == null) throw new IllegalArgumentException("metadataCache must not be null"); if (indexName == null) throw new IllegalArgumentException("index name must not be null"); this.indexName = indexName; this.locksCache = locksCache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE, Flag.SKIP_CACHE_LOAD, Flag.SKIP_INDEXING); this.chunksCache = chunksCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); this.metadataCache = (AdvancedCache<FileCacheKey, FileMetadata>) metadataCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); verifyCacheHasNoEviction(this.locksCache); }
/** * Create a new LocalLockMergingSegmentReadLocker for specified cache and index name. * * @param cache * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> cache, String indexName) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) cache, cache, cache, indexName); }
void release() { value--; if (value <= 0) { localLocks.remove(name); delegate.deleteOrReleaseReadLock(name); } } }
public DistributedSegmentReadLocker(Cache<Object, Integer> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, int affinitySegmentId, boolean forceSynchronousDeletes) { this.affinitySegmentId = affinitySegmentId; this.forceSynchronousDeletes = forceSynchronousDeletes; if (locksCache == null) throw new IllegalArgumentException("locksCache must not be null"); if (chunksCache == null) throw new IllegalArgumentException("chunksCache must not be null"); if (metadataCache == null) throw new IllegalArgumentException("metadataCache must not be null"); if (indexName == null) throw new IllegalArgumentException("index name must not be null"); this.indexName = indexName; this.locksCache = locksCache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE, Flag.SKIP_CACHE_LOAD, Flag.SKIP_INDEXING); this.chunksCache = chunksCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); this.metadataCache = (AdvancedCache<FileCacheKey, FileMetadata>) metadataCache.getAdvancedCache().withFlags(Flag.SKIP_INDEXING); verifyCacheHasNoEviction(this.locksCache); }
/** * @return true if the lock was acquired, false if it's too late: the file * was deleted and this LocalReadLock should be removed too. */ boolean acquire() { if (value == 0) { boolean haveIt = delegate.acquireReadLock(name); if (haveIt) { value = 1; return true; } else { value = -1; return false; } } else if (value == -1) { // it was deleted just a two lines ago return false; } else { value++; return true; } }
/** * Create a new LocalLockMergingSegmentReadLocker with special purpose caches * @param locksCache the cache to be used to store distributed locks * @param chunksCache the cache containing the chunks, this is where the bulk of data is stored * @param metadataCache smaller cache for the metadata of stored elements * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) locksCache, chunksCache, metadataCache, indexName, affinitySegmentId); }
synchronized void release() { value--; if (value <= 0) { localLocks.remove(name); delegate.deleteOrReleaseReadLock(name); } } }
/** * @return true if the lock was acquired, false if it's too late: the file * was deleted and this LocalReadLock should be removed too. */ synchronized boolean acquire() { if (value == 0) { boolean haveIt = delegate.acquireReadLock(name); if (haveIt) { value = 1; return true; } else { value = -1; return false; } } else if (value == -1) { // it was deleted just a two lines ago return false; } else { value++; return true; } }
/** * Create a new LocalLockMergingSegmentReadLocker for specified cache and index name. * * @param cache * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> cache, String indexName, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) cache, cache, cache, indexName, affinitySegmentId); }
/** * Create a new LocalLockMergingSegmentReadLocker for specified cache and index name. * * @param cache * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> cache, String indexName, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) cache, cache, cache, indexName, affinitySegmentId); }
/** * Create a new LocalLockMergingSegmentReadLocker with special purpose caches * @param locksCache the cache to be used to store distributed locks * @param chunksCache the cache containing the chunks, this is where the bulk of data is stored * @param metadataCache smaller cache for the metadata of stored elements * @param indexName */ public LocalLockMergingSegmentReadLocker(Cache<?, ?> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) locksCache, chunksCache, metadataCache, indexName); }
public LocalLockMergingSegmentReadLocker(Cache<?, ?> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, boolean forceSynchronousDeletes, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) locksCache, chunksCache, metadataCache, indexName, affinitySegmentId,forceSynchronousDeletes); }
public LocalLockMergingSegmentReadLocker(Cache<?, ?> locksCache, Cache<?, ?> chunksCache, Cache<?, ?> metadataCache, String indexName, boolean forceSynchronousDeletes, int affinitySegmentId) { this.delegate = new DistributedSegmentReadLocker((Cache<Object, Integer>) locksCache, chunksCache, metadataCache, indexName, affinitySegmentId,forceSynchronousDeletes); }