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 voidclear()booleancontainsDownstream(K key)Contains downstream boolean.booleancontainsDownstream(K startingPoint, K searchingFor)Contains downstream boolean.booleancontainsKey(java.lang.Object key)booleancontainsUpOrDownstream(K key)Contains up or downstream boolean.booleancontainsUpstream(K key)Contains upstream boolean.booleancontainsUpstream(K startingPoint, K searchingFor)Contains upstream boolean.booleancontainsValue(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.KgetKey()Gets key.intgetMaxSizeToPrint()Gets max size to print.RecursiveMap<K>getOrigin()Gets origin.java.util.Set<K>getParents()Gets parents.booleanisEmpty()booleanisOrigin()Is origin boolean.java.util.Set<K>keySet()RecursiveMap<K>put(K key)Put recursive map.RecursiveMap<K>put(K key, RecursiveMap<K> value)voidputAll(java.util.Map<? extends K,? extends RecursiveMap<K>> m)voidputAll(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)voidsetMaxSizeToPrint(int maxSizeToPrint)Sets max size to print.intsize()java.lang.StringtoString()java.util.Collection<RecursiveMap<K>>values()
-
Constructor Details
-
RecursiveMap
public RecursiveMap()Instantiates a new Recursive map.
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfacejava.util.Map<K,RecursiveMap<K>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacejava.util.Map<K,RecursiveMap<K>>
-
containsKey
public boolean containsKey(java.lang.Object key)- Specified by:
containsKeyin interfacejava.util.Map<K,RecursiveMap<K>>
-
containsValue
public boolean containsValue(java.lang.Object value)- Specified by:
containsValuein interfacejava.util.Map<K,RecursiveMap<K>>
-
get
- Specified by:
getin 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:
putin interfacejava.util.Map<K,RecursiveMap<K>>- Throws:
java.lang.UnsupportedOperationException
-
remove
- Specified by:
removein interfacejava.util.Map<K,RecursiveMap<K>>
-
putAll
- Specified by:
putAllin interfacejava.util.Map<K,RecursiveMap<K>>
-
putAll
Put all.- Parameters:
keys- the keys
-
clear
public void clear()- Specified by:
clearin interfacejava.util.Map<K,RecursiveMap<K>>
-
keySet
- Specified by:
keySetin interfacejava.util.Map<K,RecursiveMap<K>>
-
values
- Specified by:
valuesin interfacejava.util.Map<K,RecursiveMap<K>>
-
entrySet
- Specified by:
entrySetin 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:
toStringin classjava.lang.Object
-