Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add a subtype for chaining stores, and have cluster executions of tra…
…nsforms unroll them for chaining stores
- Loading branch information
Showing
15 changed files
with
591 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 21 additions & 8 deletions
29
fcrepo-kernel/src/main/java/org/fcrepo/services/functions/CacheLocalTransform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,56 @@ | ||
package org.fcrepo.services.functions; | ||
|
||
import java.io.Serializable; | ||
import java.util.Set; | ||
|
||
import org.fcrepo.utils.LowLevelCacheEntry; | ||
import org.fcrepo.utils.impl.CacheStoreEntry; | ||
import org.fcrepo.utils.impl.ChainingCacheStoreEntry; | ||
import org.infinispan.Cache; | ||
import org.infinispan.CacheImpl; | ||
import org.infinispan.distexec.DistributedCallable; | ||
import org.infinispan.loaders.CacheStore; | ||
import org.infinispan.loaders.decorators.ChainingCacheStore; | ||
import org.modeshape.jcr.value.BinaryKey; | ||
import org.modeshape.jcr.value.binary.BinaryStore; | ||
|
||
import com.google.common.base.Function; | ||
|
||
|
||
public class CacheLocalTransform<K, V, T> | ||
implements DistributedCallable<K, V, T> { | ||
implements DistributedCallable<K, V, T>, Serializable { | ||
|
||
/** | ||
* Because this class will be communicated between cache nodes, | ||
* it must be serializable | ||
*/ | ||
private static final long serialVersionUID = -7014104738830230123L; | ||
|
||
private static GetCacheStore TRANSFORM = new GetCacheStore(); | ||
|
||
private BinaryStore binStore; | ||
private BinaryKey key; | ||
private Function<LowLevelCacheEntry, T> entryTransform; | ||
private CacheStore store; | ||
private String cacheName = ""; | ||
|
||
public CacheLocalTransform(final BinaryStore store, | ||
final BinaryKey key, final Function<LowLevelCacheEntry, T> entryTransform) { | ||
public CacheLocalTransform(final BinaryKey key, | ||
final Function<LowLevelCacheEntry, T> entryTransform) { | ||
|
||
this.key = key; | ||
this.entryTransform = entryTransform; | ||
this.binStore = store; | ||
} | ||
|
||
@Override | ||
public T call() throws Exception { | ||
LowLevelCacheEntry entry = new LowLevelCacheEntry(binStore, store, key); | ||
LowLevelCacheEntry entry = | ||
(store instanceof ChainingCacheStore) ? | ||
new ChainingCacheStoreEntry((ChainingCacheStore)store, cacheName, key) : | ||
new CacheStoreEntry(store, cacheName, key); | ||
return this.entryTransform.apply(entry); | ||
} | ||
|
||
@Override | ||
public void setEnvironment(Cache<K, V> cache, Set<K> keys) { | ||
this.store = TRANSFORM.apply(cache); | ||
|
||
this.cacheName = ((CacheImpl)cache).getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.