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...)
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description RecursiveMap()
Instantiates a new Recursive map. -
Method Summary
Modifier and Type Method Description void
clear()
boolean
containsDownstream(K key)
Contains downstream boolean.boolean
containsDownstream(K startingPoint, K searchingFor)
Contains downstream boolean.boolean
containsKey(java.lang.Object key)
boolean
containsUpOrDownstream(K key)
Contains up or downstream boolean.boolean
containsUpstream(K key)
Contains upstream boolean.boolean
containsUpstream(K startingPoint, K searchingFor)
Contains upstream boolean.boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,RecursiveMap<K>>>
entrySet()
RecursiveMap<K>
get(java.lang.Object key)
java.util.Set<K>
getCircularKeys()
Gets circular keys.K
getKey()
Gets key.int
getMaxSizeToPrint()
Gets max size to print.RecursiveMap<K>
getOrigin()
Gets origin.java.util.Set<K>
getParents()
Gets parents.boolean
isEmpty()
boolean
isOrigin()
Is origin boolean.java.util.Set<K>
keySet()
RecursiveMap<K>
put(K key)
Put recursive map.RecursiveMap<K>
put(K key, RecursiveMap<K> value)
void
putAll(java.util.Map<? extends K,? extends RecursiveMap<K>> m)
void
putAll(java.util.Set<K> keys)
Put all.RecursiveMap<K>
putChild(K parent, K child)
Put child recursive map.RecursiveMap<K>
remove(java.lang.Object key)
void
setMaxSizeToPrint(int maxSizeToPrint)
Sets max size to print.int
size()
java.lang.String
toString()
java.util.Collection<RecursiveMap<K>>
values()
-
Constructor Details
-
RecursiveMap
public RecursiveMap()Instantiates a new Recursive map.
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfacejava.util.Map<K,RecursiveMap<K>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfacejava.util.Map<K,RecursiveMap<K>>
-
containsKey
public boolean containsKey(java.lang.Object key)- Specified by:
containsKey
in interfacejava.util.Map<K,RecursiveMap<K>>
-
containsValue
public boolean containsValue(java.lang.Object value)- Specified by:
containsValue
in interfacejava.util.Map<K,RecursiveMap<K>>
-
get
- Specified by:
get
in interfacejava.util.Map<K,RecursiveMap<K>>
-
put
Put recursive map.- Parameters:
key
- the key- Returns:
- the recursive map
-
putChild
Put child recursive map.- Parameters:
parent
- the parentchild
- the child- Returns:
- the recursive map
-
put
public RecursiveMap<K> put(K key, RecursiveMap<K> value) throws java.lang.UnsupportedOperationException- Specified by:
put
in interfacejava.util.Map<K,RecursiveMap<K>>
- Throws:
java.lang.UnsupportedOperationException
-
remove
- Specified by:
remove
in interfacejava.util.Map<K,RecursiveMap<K>>
-
putAll
- Specified by:
putAll
in interfacejava.util.Map<K,RecursiveMap<K>>
-
putAll
Put all.- Parameters:
keys
- the keys
-
clear
public void clear()- Specified by:
clear
in interfacejava.util.Map<K,RecursiveMap<K>>
-
keySet
- Specified by:
keySet
in interfacejava.util.Map<K,RecursiveMap<K>>
-
values
- Specified by:
values
in interfacejava.util.Map<K,RecursiveMap<K>>
-
entrySet
- Specified by:
entrySet
in interfacejava.util.Map<K,RecursiveMap<K>>
-
getParents
Gets parents.- Returns:
- the parents
-
getKey
Gets key.- Returns:
- the key
-
getOrigin
Gets origin.- Returns:
- the origin
-
isOrigin
public boolean isOrigin()Is origin boolean.- Returns:
- the boolean
-
getCircularKeys
Gets circular keys.- Returns:
- the circular keys
-
containsUpstream
Contains upstream boolean.- Parameters:
key
- the key- Returns:
- the boolean
-
containsUpstream
Contains upstream boolean.- Parameters:
startingPoint
- the starting pointsearchingFor
- the searching for- Returns:
- the boolean
-
containsDownstream
Contains downstream boolean.- Parameters:
key
- the key- Returns:
- the boolean
-
containsDownstream
Contains downstream boolean.- Parameters:
startingPoint
- the starting pointsearchingFor
- the searching for- Returns:
- the boolean
-
containsUpOrDownstream
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 classjava.lang.Object
-