Class TreeCacheImpl<K,​V>

    • 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.
        Specified by:
        getRoot in interface TreeCache<K,​V>
        Returns:
        the root node
      • 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 to TreeCache.put(Fqn, Object, Object)
        Specified by:
        put in interface TreeCache<K,​V>
        Parameters:
        fqn - String representation of the Fqn
        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. A null return can also indicate that the Node previously associated null 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 a Node.
        Specified by:
        put in interface TreeCache<K,​V>
        Parameters:
        fqn - absolute Fqn to the Node to copy the data to
        data - mappings to copy
      • put

        public void put​(Fqn fqn,
                        Map<? extends K,​? extends V> data,
                        Flag... flags)
        Specified by:
        put in interface TreeCache<K,​V>
      • 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 to TreeCache.put(Fqn, java.util.Map)
        Specified by:
        put in interface TreeCache<K,​V>
        Parameters:
        fqn - String representation of the Fqn
        data - data map to insert
      • put

        public void put​(String fqn,
                        Map<? extends K,​? extends V> data,
                        Flag... flags)
        Specified by:
        put in interface TreeCache<K,​V>
      • 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, or null if the Node contained no mapping for this key.
        Specified by:
        remove in interface TreeCache<K,​V>
        Parameters:
        fqn - absolute Fqn to the Node to be accessed.
        key - key whose mapping is to be removed from the Node
        Returns:
        previous value associated with specified Node's 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 to TreeCache.remove(Fqn, Object)
        Specified by:
        remove in interface TreeCache<K,​V>
        Parameters:
        fqn - string representation of the Fqn to retrieve
        key - key to remove
        Returns:
        old value removed, or null if the fqn does not exist
      • removeNode

        public boolean removeNode​(Fqn fqn)
        Description copied from interface: TreeCache
        Removes a Node indicated by absolute Fqn.
        Specified by:
        removeNode in interface TreeCache<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​(String fqn)
        Description copied from interface: TreeCache
        Convenience method that takes a string representation of an Fqn. Otherwise identical to TreeCache.removeNode(Fqn)
        Specified by:
        removeNode in interface TreeCache<K,​V>
        Parameters:
        fqn - string representation of the Fqn to retrieve
        Returns:
        true if the node was found and removed, false otherwise
      • 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).
        Specified by:
        getNode in interface TreeCache<K,​V>
        Parameters:
        fqn - fqn of the node to retrieve
        Returns:
        a Node object, or a null if the node does not exist.
      • 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 to TreeCache.getNode(Fqn)
        Specified by:
        getNode in interface TreeCache<K,​V>
        Parameters:
        fqn - string representation of the Fqn to retrieve
        Returns:
        node, or null if the node does not exist
      • get

        public V get​(Fqn fqn,
                     K key)
        Description copied from interface: TreeCache
        Convenience method that allows for direct access to the data in a Node.
        Specified by:
        get in interface TreeCache<K,​V>
        Parameters:
        fqn - absolute Fqn to the Node to be accessed.
        key - key under which value is to be retrieved.
        Returns:
        returns data held under specified key in Node denoted by specified Fqn.
      • exists

        public boolean exists​(String f)
        Description copied from interface: TreeCache
        Tests if an Fqn exists. Convenience method for TreeCache.exists(Fqn)
        Specified by:
        exists in interface TreeCache<K,​V>
        Parameters:
        f - string representation of an Fqn
        Returns:
        true if the fqn exists, false otherwise
      • 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 to TreeCache.get(Fqn, Object)
        Specified by:
        get in interface TreeCache<K,​V>
        Parameters:
        fqn - string representation of the Fqn to retrieve
        key - key to fetch
        Returns:
        value, or null if the fqn does not exist.
      • 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 now

          Fqn 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 interface TreeCache<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.
      • 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.
        Specified by:
        getData in interface TreeCache<K,​V>
        Returns:
        map of data, or an empty map
      • 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.

        Specified by:
        getKeys in interface TreeCache<K,​V>
        Parameters:
        fqn - name of the node
      • 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.

        Specified by:
        clearData in interface TreeCache<K,​V>
        Parameters:
        fqn - name of the node
      • put

        public V put​(Fqn fqn,
                     K key,
                     V value)
        Description copied from interface: TreeCache
        Associates the specified value with the specified key for a Node in this cache. If the Node previously contained a mapping for this key, the old value is replaced by the specified value.
        Specified by:
        put in interface TreeCache<K,​V>
        Parameters:
        fqn - absolute Fqn to the Node 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. A null return can also indicate that the Node previously associated null with the specified key, if the implementation supports null values.
      • getCache

        public Cache<?,​?> getCache()
        Specified by:
        getCache in interface TreeCache<K,​V>
        Returns:
        a reference to the underlying cache instance
      • start

        public void start()
                   throws CacheException
        Description copied from interface: org.infinispan.commons.api.Lifecycle
        Invoked on component start
        Specified by:
        start in interface org.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 interface org.infinispan.commons.api.Lifecycle