/** * {@inheritDoc} */ public void remove(CacheEntry entry) throws CacheException { writeBehind.delete(entry); }
@Override public long getQueueSize() { lock.readLock().lock(); try { if (delegate == null) { return 0; } } finally { lock.readLock().unlock(); } return delegate.getQueueSize(); } }
/** * * @param writeBehind */ public void init(WriteBehind writeBehind) { lock.writeLock().lock(); try { delegate = writeBehind; if (isStarted) { delegate.start(writer); } if (filter != null) { delegate.setOperationsFilter(filter); } if (isStopped) { delegate.stop(); } } finally { lock.writeLock().unlock(); } }
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }
/** * {@inheritDoc} */ public void dispose() { /* If WriteBehind is configured but no writer is registered, writeBehind will be null */ if (writeBehind != null) { writeBehind.stop(); } }
/** * {@inheritDoc} */ public void put(Element element) throws CacheException { writeBehind.write(element); }
/** * {@inheritDoc} */ public void start(final CacheWriter writer) throws CacheException { writeLock.lock(); try { for (WriteBehind queue : queues) { queue.start(writer); } } finally { writeLock.unlock(); } }
/** * {@inheritDoc} */ public void setOperationsFilter(final OperationsFilter filter) { readLock.lock(); try { for (WriteBehind queue : queues) { queue.setOperationsFilter(filter); } } finally { readLock.unlock(); } }
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }
/** * {@inheritDoc} */ public void stop() throws CacheException { writeLock.lock(); try { for (WriteBehind queue : queues) { queue.stop(); } } finally { writeLock.unlock(); } }
@Override public void write(Element element) { lock.readLock().lock(); try { if (delegate == null) { throw new IllegalStateException(); } } finally { lock.readLock().unlock(); } delegate.write(element); }
@Override public void start(CacheWriter writerParam) throws CacheException { lock.writeLock().lock(); try { if (delegate == null) { isStarted = true; NonStopWriteBehind.this.writer = writerParam; return; } } finally { lock.writeLock().unlock(); } delegate.start(writerParam); }
@Override public void setOperationsFilter(OperationsFilter filter) { lock.writeLock().lock(); try { if (delegate == null) { NonStopWriteBehind.this.filter = filter; return; } } finally { lock.writeLock().unlock(); } delegate.setOperationsFilter(filter); }
/** * * @param writeBehind */ public void init(WriteBehind writeBehind) { lock.writeLock().lock(); try { delegate = writeBehind; if (isStarted) { delegate.start(writer); } if (filter != null) { delegate.setOperationsFilter(filter); } if (isStopped) { delegate.stop(); } } finally { lock.writeLock().unlock(); } }
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }
@Override public void stop() throws CacheException { lock.writeLock().lock(); try { if (delegate == null) { isStopped = true; return; } } finally { lock.writeLock().unlock(); } delegate.stop(); }
@Override public void delete(CacheEntry entry) { lock.readLock().lock(); try { if (delegate == null) { throw new IllegalStateException(); } } finally { lock.readLock().unlock(); } delegate.delete(entry); }
/** * {@inheritDoc} */ public void write(final Element element) { readLock.lock(); try { getQueue(element.getKey()).write(element); } finally { readLock.unlock(); } }
/** * {@inheritDoc} */ public long getQueueSize() { int size = 0; readLock.lock(); try { for (WriteBehind queue : queues) { size += queue.getQueueSize(); } } finally { readLock.unlock(); } return size; }
/** * {@inheritDoc} */ public void start(final CacheWriter writer) throws CacheException { writeLock.lock(); try { for (WriteBehind queue : queues) { queue.start(writer); } } finally { writeLock.unlock(); } }