Package org.infinispan.tree.impl
Class TreeCacheImpl<K,V>
- java.lang.Object
-
- org.infinispan.batch.AutoBatchSupport
-
- org.infinispan.tree.impl.TreeStructureSupport
-
- org.infinispan.tree.impl.TreeCacheImpl<K,V>
-
- All Implemented Interfaces:
org.infinispan.commons.api.Lifecycle
,TreeCache<K,V>
public class TreeCacheImpl<K,V> extends TreeStructureSupport implements TreeCache<K,V>
- Since:
- 4.0
- Author:
- Manik Surtani (manik AT jboss DOT org)
-
-
Field Summary
-
Fields inherited from class org.infinispan.tree.impl.TreeStructureSupport
cache
-
Fields inherited from class org.infinispan.batch.AutoBatchSupport
batchContainer
-
-
Constructor Summary
Constructors Constructor Description TreeCacheImpl(AdvancedCache<?,?> cache)
TreeCacheImpl(Cache<?,?> cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearData(String fqn)
Convenience method that takes in a String represenation of the Fqn.void
clearData(String fqn, Flag... flags)
void
clearData(AdvancedCache<NodeKey,AtomicMap<?,?>> cache, Fqn fqn)
void
clearData(Fqn fqn)
Removes the keys and properties from a named node.void
clearData(Fqn fqn, Flag... flags)
boolean
exists(String f)
Tests if an Fqn exists.boolean
exists(String fqn, Flag... flags)
boolean
exists(Fqn fqn, Flag... flags)
V
get(String fqn, K key)
Convenience method that takes a string representation of an Fqn.V
get(String fqn, K key, Flag... flags)
V
get(Fqn fqn, K key)
Convenience method that allows for direct access to the data in aNode
.V
get(Fqn fqn, K key, Flag... flags)
Cache<?,?>
getCache()
Map<K,V>
getData(Fqn fqn)
Retrieves a defensively copied data map of the underlying node.Map<K,V>
getData(Fqn fqn, Flag... flags)
Set<K>
getKeys(String fqn)
Convenience method that takes in a String represenation of the Fqn.Set<K>
getKeys(String fqn, Flag... flags)
Set<K>
getKeys(Fqn fqn)
Returns a set of attribute keys for the Fqn.Set<K>
getKeys(Fqn fqn, Flag... flags)
Node<K,V>
getNode(String fqn)
Convenience method that takes a string representation of an Fqn.Node<K,V>
getNode(String fqn, Flag... flags)
Node<K,V>
getNode(Fqn fqn)
A convenience method to retrieve a node directly from the cache.Node<K,V>
getNode(Fqn fqn, Flag... flags)
Node<K,V>
getRoot()
Returns the root node of this cache.Node<K,V>
getRoot(Flag... flags)
void
move(String nodeToMove, String newParent)
Convenience method that takes in string representations of Fqns.void
move(String nodeToMove, String newParent, Flag... flags)
void
move(Fqn nodeToMoveFqn, Fqn newParentFqn)
Moves a part of the cache to a different subtree.void
move(Fqn nodeToMoveFqn, Fqn newParentFqn, Flag... flags)
void
put(String fqn, Map<? extends K,? extends V> data)
Convenience method that takes a string representation of an Fqn.void
put(String fqn, Map<? extends K,? extends V> data, Flag... flags)
V
put(String fqn, K key, V value)
Convenience method that takes a string representation of an Fqn.V
put(String fqn, K key, V value, Flag... flags)
void
put(Fqn fqn, Map<? extends K,? extends V> data)
Copies all of the mappings from the specified map to aNode
.void
put(Fqn fqn, Map<? extends K,? extends V> data, Flag... flags)
V
put(Fqn fqn, K key, V value)
Associates the specified value with the specified key for aNode
in this cache.V
put(Fqn fqn, K key, V value, Flag... flags)
V
remove(String fqn, K key)
Convenience method that takes a string representation of an Fqn.V
remove(String fqn, K key, Flag... flags)
V
remove(Fqn fqn, K key)
Removes the mapping for this key from a Node.V
remove(Fqn fqn, K key, Flag... flags)
boolean
removeNode(String fqn)
Convenience method that takes a string representation of an Fqn.boolean
removeNode(String fqn, Flag... flags)
boolean
removeNode(Fqn fqn)
boolean
removeNode(Fqn fqn, Flag... flags)
void
start()
Invoked on component startvoid
stop()
Invoked on component stopString
toString()
-
Methods inherited from class org.infinispan.tree.impl.TreeStructureSupport
createNodeInCache, exists, exists, getAtomicMap, getAtomicMap, isLocked, printTree
-
Methods inherited from class org.infinispan.batch.AutoBatchSupport
assertBatchingSupported, endAtomic, failAtomic, startAtomic
-
-
-
-
Constructor Detail
-
TreeCacheImpl
public TreeCacheImpl(Cache<?,?> cache)
-
TreeCacheImpl
public TreeCacheImpl(AdvancedCache<?,?> cache)
-
-
Method Detail
-
getRoot
public Node<K,V> getRoot()
Description copied from interface:TreeCache
Returns the root node of this cache.
-
put
public V put(String fqn, K key, V value)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.put(Fqn, Object, Object)
- Specified by:
put
in interfaceTreeCache<K,V>
- Parameters:
fqn
- String representation of the Fqnkey
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. Anull
return can also indicate that the Node previously associatednull
with the specified key, if the implementation supports null values.
-
put
public void put(Fqn fqn, Map<? extends K,? extends V> data)
Description copied from interface:TreeCache
Copies all of the mappings from the specified map to aNode
.
-
put
public void put(String fqn, Map<? extends K,? extends V> data)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.put(Fqn, java.util.Map)
-
remove
public V remove(Fqn fqn, K key)
Description copied from interface:TreeCache
Removes the mapping for this key from a Node. Returns the value to which the Node previously associated the key, ornull
if the Node contained no mapping for this key.
-
remove
public V remove(String fqn, K key)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.remove(Fqn, Object)
-
removeNode
public boolean removeNode(Fqn fqn)
Description copied from interface:TreeCache
- Specified by:
removeNode
in interfaceTreeCache<K,V>
- Parameters:
fqn
-Node
to remove- Returns:
- true if the node was removed, false if the node was not found
-
removeNode
public boolean removeNode(Fqn fqn, Flag... flags)
- Specified by:
removeNode
in interfaceTreeCache<K,V>
-
removeNode
public boolean removeNode(String fqn)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.removeNode(Fqn)
- Specified by:
removeNode
in interfaceTreeCache<K,V>
- Parameters:
fqn
- string representation of the Fqn to retrieve- Returns:
- true if the node was found and removed, false otherwise
-
removeNode
public boolean removeNode(String fqn, Flag... flags)
- Specified by:
removeNode
in interfaceTreeCache<K,V>
-
getNode
public Node<K,V> getNode(Fqn fqn)
Description copied from interface:TreeCache
A convenience method to retrieve a node directly from the cache. Equivalent to calling cache.getRoot().getChild(fqn).
-
getNode
public Node<K,V> getNode(String fqn)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.getNode(Fqn)
-
get
public V get(Fqn fqn, K key)
Description copied from interface:TreeCache
Convenience method that allows for direct access to the data in aNode
.
-
exists
public boolean exists(String f)
Description copied from interface:TreeCache
Tests if an Fqn exists. Convenience method forTreeCache.exists(Fqn)
-
get
public V get(String fqn, K key)
Description copied from interface:TreeCache
Convenience method that takes a string representation of an Fqn. Otherwise identical toTreeCache.get(Fqn, Object)
-
move
public void move(Fqn nodeToMoveFqn, Fqn newParentFqn) throws NodeNotExistsException
Description copied from interface:TreeCache
Moves a part of the cache to a different subtree. E.g.: assume a cache structure such as:/a/b/c /a/b/d /a/b/e Fqn f1 = Fqn.fromString("/a/b/c"); Fqn f2 = Fqn.fromString("/a/b/d"); cache.move(f1, f2);
Will result in:/a/b/d/c /a/b/e
and nowFqn f3 = Fqn.fromString("/a/b/e"); Fqn f4 = Fqn.fromString("/a"); cache.move(f3, f4);
will result in:/a/b/d/c /a/e
No-op if the node to be moved is the root node. Note: As of 3.0.0 and when using MVCC locking, more specific behaviour is defined as follows:- A no-op if the node is moved unto itself. E.g., move(fqn, fqn.getParent()) will not do anything.
- If a target node does not exist it will be created silently, to be more consistent with other APIs such as put() on a nonexistent node.
- If the source node does not exist this is a no-op, to be more consistent with other APIs such as get() on a nonexistent node.
- Specified by:
move
in interfaceTreeCache<K,V>
- Parameters:
nodeToMoveFqn
- the Fqn of the node to move.newParentFqn
- new location under which to attach the node being moved.- Throws:
NodeNotExistsException
- may throw one of these if the target node does not exist or if a different thread has moved this node elsewhere already.
-
move
public void move(Fqn nodeToMoveFqn, Fqn newParentFqn, Flag... flags) throws NodeNotExistsException
- Specified by:
move
in interfaceTreeCache<K,V>
- Throws:
NodeNotExistsException
-
move
public void move(String nodeToMove, String newParent) throws NodeNotExistsException
Description copied from interface:TreeCache
Convenience method that takes in string representations of Fqns. Otherwise identical toTreeCache.move(Fqn, Fqn)
- Specified by:
move
in interfaceTreeCache<K,V>
- Throws:
NodeNotExistsException
-
move
public void move(String nodeToMove, String newParent, Flag... flags) throws NodeNotExistsException
- Specified by:
move
in interfaceTreeCache<K,V>
- Throws:
NodeNotExistsException
-
getData
public Map<K,V> getData(Fqn fqn)
Description copied from interface:TreeCache
Retrieves a defensively copied data map of the underlying node. A convenience method to retrieving a node and getting data from the node directly.
-
getKeys
public Set<K> getKeys(String fqn)
Description copied from interface:TreeCache
Convenience method that takes in a String represenation of the Fqn. Otherwise identical toTreeCache.getKeys(Fqn)
.
-
getKeys
public Set<K> getKeys(Fqn fqn)
Description copied from interface:TreeCache
Returns a set of attribute keys for the Fqn. Returns null if the node is not found, otherwise a Set. The set is a copy of the actual keys for this node. A convenience method to retrieving a node and getting keys from the node directly.
-
clearData
public void clearData(String fqn)
Description copied from interface:TreeCache
Convenience method that takes in a String represenation of the Fqn. Otherwise identical toTreeCache.clearData(Fqn)
.
-
clearData
public void clearData(Fqn fqn)
Description copied from interface:TreeCache
Removes the keys and properties from a named node. A convenience method to retrieving a node and getting keys from the node directly.
-
clearData
public void clearData(AdvancedCache<NodeKey,AtomicMap<?,?>> cache, Fqn fqn)
-
put
public V put(Fqn fqn, K key, V value)
Description copied from interface:TreeCache
Associates the specified value with the specified key for aNode
in this cache. If theNode
previously contained a mapping for this key, the old value is replaced by the specified value.- Specified by:
put
in interfaceTreeCache<K,V>
- Parameters:
fqn
- absoluteFqn
to theNode
to be accessed.key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- previous value associated with specified key, or
null
if there was no mapping for key. Anull
return can also indicate that the Node previously associatednull
with the specified key, if the implementation supports null values.
-
getCache
public Cache<?,?> getCache()
-
start
public void start() throws CacheException
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component start- Specified by:
start
in interfaceorg.infinispan.commons.api.Lifecycle
- Throws:
CacheException
-
stop
public void stop()
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component stop- Specified by:
stop
in interfaceorg.infinispan.commons.api.Lifecycle
-
-