01: package org.compass.needle.coherence;
02:
03: import java.io.IOException;
04:
05: import com.tangosol.net.NamedCache;
06: import com.tangosol.util.filter.AlwaysFilter;
07: import com.tangosol.util.filter.AndFilter;
08: import com.tangosol.util.filter.EqualsFilter;
09: import com.tangosol.util.processor.ConditionalRemove;
10:
11: /**
12: * The invocable directory uses Coherence extended support for invocable cache
13: * services (not available at all editions).
14: *
15: * <p>Allow to better implement locking and batch deletions.
16: *
17: * @author kimchy
18: */
19: public class InvocableCoherenceDirectory extends
20: DataGridCoherenceDirectory {
21:
22: public InvocableCoherenceDirectory(String cacheName) {
23: super (cacheName);
24: }
25:
26: public InvocableCoherenceDirectory(String cacheName,
27: String indexName) {
28: super (cacheName, indexName);
29: }
30:
31: public InvocableCoherenceDirectory(String cacheName,
32: String indexName, int bucketSize) {
33: super (cacheName, indexName, bucketSize);
34: }
35:
36: public InvocableCoherenceDirectory(NamedCache cache,
37: String indexName) {
38: super (cache, indexName);
39: }
40:
41: public InvocableCoherenceDirectory(NamedCache cache,
42: String indexName, int bucketSize) {
43: super (cache, indexName, bucketSize);
44: }
45:
46: protected void doInit() {
47: setLockFactory(new InvocableCoherenceLockFactory(getCache(),
48: getIndexName()));
49: }
50:
51: public void deleteFile(String name) throws IOException {
52: getCache().invokeAll(
53: new AndFilter(getIndexNameEqualsFilter(),
54: new EqualsFilter(getFileNameKeyExtractor(),
55: name)),
56: new ConditionalRemove(AlwaysFilter.INSTANCE, false));
57: }
58:
59: public void deleteContent() {
60: getCache().invokeAll(getIndexNameEqualsFilter(),
61: new ConditionalRemove(AlwaysFilter.INSTANCE, false));
62: }
63: }
|