Package tenapull.util

Class RecursiveMap<K>

java.lang.Object
tenapull.util.RecursiveMap<K>
Type Parameters:
K - the key type for the recursive map. The value will always be another recursive map representing that key (and containing the keys it points to)
All Implemented Interfaces:
java.util.Map<K,​RecursiveMap<K>>

public class RecursiveMap<K>
extends java.lang.Object
implements java.util.Map<K,​RecursiveMap<K>>
A recursive map is a map of maps that point to each other. It is essentially a way to map keys as nodes that each point to other keys (via that keys' map). The origin map is the only map which does not represent a key, and also contains all keys that have been added to any of the recursive maps that originated from it. The primary use-case for this in TenaPull is to determine where thread deadlocks may be happening, by finding circular references between threads blocking each other. In this scenario, each thread represents a key, and its value is a recursive map of all the threads it is blocking from obtaining a lock (or actually... the recursive maps representing each of those threads, with the threads themselves as the keys, etc...)
  • Constructor Details

    • RecursiveMap

      public RecursiveMap()
      Instantiates a new Recursive map.
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface java.util.Map<K,​RecursiveMap<K>>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface java.util.Map<K,​RecursiveMap<K>>
    • containsKey

      public boolean containsKey​(java.lang.Object key)
      Specified by:
      containsKey in interface java.util.Map<K,​RecursiveMap<K>>
    • containsValue

      public boolean containsValue​(java.lang.Object value)
      Specified by:
      containsValue in interface java.util.Map<K,​RecursiveMap<K>>
    • get

      public RecursiveMap<K> get​(java.lang.Object key)
      Specified by:
      get in interface java.util.Map<K,​RecursiveMap<K>>
    • put

      public RecursiveMap<K> put​(K key)
      Put recursive map.
      Parameters:
      key - the key
      Returns:
      the recursive map
    • putChild

      public RecursiveMap<K> putChild​(K parent, K child)
      Put child recursive map.
      Parameters:
      parent - the parent
      child - the child
      Returns:
      the recursive map
    • put

      public RecursiveMap<K> put​(K key, RecursiveMap<K> value) throws java.lang.UnsupportedOperationException
      Specified by:
      put in interface java.util.Map<K,​RecursiveMap<K>>
      Throws:
      java.lang.UnsupportedOperationException
    • remove

      public RecursiveMap<K> remove​(java.lang.Object key)
      Specified by:
      remove in interface java.util.Map<K,​RecursiveMap<K>>
    • putAll

      public void putAll​(java.util.Map<? extends K,​? extends RecursiveMap<K>> m)
      Specified by:
      putAll in interface java.util.Map<K,​RecursiveMap<K>>
    • putAll

      public void putAll​(java.util.Set<K> keys)
      Put all.
      Parameters:
      keys - the keys
    • clear

      public void clear()
      Specified by:
      clear in interface java.util.Map<K,​RecursiveMap<K>>
    • keySet

      public java.util.Set<K> keySet()
      Specified by:
      keySet in interface java.util.Map<K,​RecursiveMap<K>>
    • values

      public java.util.Collection<RecursiveMap<K>> values()
      Specified by:
      values in interface java.util.Map<K,​RecursiveMap<K>>
    • entrySet

      public java.util.Set<java.util.Map.Entry<K,​RecursiveMap<K>>> entrySet()
      Specified by:
      entrySet in interface java.util.Map<K,​RecursiveMap<K>>
    • getParents

      public java.util.Set<K> getParents()
      Gets parents.
      Returns:
      the parents
    • getKey

      public K getKey()
      Gets key.
      Returns:
      the key
    • getOrigin

      public RecursiveMap<K> getOrigin()
      Gets origin.
      Returns:
      the origin
    • isOrigin

      public boolean isOrigin()
      Is origin boolean.
      Returns:
      the boolean
    • getCircularKeys

      public java.util.Set<K> getCircularKeys()
      Gets circular keys.
      Returns:
      the circular keys
    • containsUpstream

      public boolean containsUpstream​(K key)
      Contains upstream boolean.
      Parameters:
      key - the key
      Returns:
      the boolean
    • containsUpstream

      public boolean containsUpstream​(K startingPoint, K searchingFor)
      Contains upstream boolean.
      Parameters:
      startingPoint - the starting point
      searchingFor - the searching for
      Returns:
      the boolean
    • containsDownstream

      public boolean containsDownstream​(K key)
      Contains downstream boolean.
      Parameters:
      key - the key
      Returns:
      the boolean
    • containsDownstream

      public boolean containsDownstream​(K startingPoint, K searchingFor)
      Contains downstream boolean.
      Parameters:
      startingPoint - the starting point
      searchingFor - the searching for
      Returns:
      the boolean
    • containsUpOrDownstream

      public boolean containsUpOrDownstream​(K key)
      Contains up or downstream boolean.
      Parameters:
      key - the key
      Returns:
      the boolean
    • getMaxSizeToPrint

      public int getMaxSizeToPrint()
      Gets max size to print.
      Returns:
      the max size to print
    • setMaxSizeToPrint

      public void setMaxSizeToPrint​(int maxSizeToPrint)
      Sets max size to print.
      Parameters:
      maxSizeToPrint - the max size to print
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object