DataT
- the type of the data stored in the graph nodesNodeT
- the type of the nodes in the graphpublic class DAGraph<DataT,NodeT extends DAGNode<DataT,NodeT>> extends Graph<DataT,NodeT>
each node in a DAG is represented by DAGNode
Modifier and Type | Field and Description |
---|---|
protected List<DAGraph<DataT,NodeT>> |
parentDAGs
the immediate parent graphs of this graph.
|
protected ConcurrentLinkedQueue<String> |
queue
to perform topological sort on the graph.
|
Constructor and Description |
---|
DAGraph(NodeT rootNode)
Creates a new DAG.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependencyGraph(DAGraph<DataT,NodeT> dependencyGraph)
Mark root of this DAG depends on given DAG's root.
|
void |
addDependentGraph(DAGraph<DataT,NodeT> dependentGraph)
Mark root of the given DAG depends on this DAG's root.
|
NodeT |
getNext()
Gets next node in the DAG which has no dependency or all of it's dependencies are resolved and
ready to be consumed.
|
NodeT |
getNode(String key)
Gets a node from the graph with the given key.
|
boolean |
hasParents() |
boolean |
isPreparer() |
boolean |
isRootNode(NodeT node)
Checks whether the given node is root node of this DAG.
|
void |
prepareForEnumeration()
Prepares this DAG for node enumeration using getNext method, each call to getNext returns next node
in the DAG with no dependencies.
|
void |
reportCompletion(NodeT completed)
Reports that a node is resolved hence other nodes depends on it can consume it.
|
void |
reportError(NodeT faulted,
Throwable throwable)
Reports that a node is faulted.
|
protected NodeT |
root() |
protected List<DAGraph<DataT,NodeT extends DAGNode<DataT,NodeT>>> parentDAGs
protected ConcurrentLinkedQueue<String> queue
public DAGraph(NodeT rootNode)
rootNode
- the root node of this DAGpublic boolean hasParents()
protected NodeT root()
public boolean isRootNode(NodeT node)
node
- the node DAGNode
to be checkedpublic boolean isPreparer()
public NodeT getNode(String key)
key
- the key of the nodepublic void addDependencyGraph(DAGraph<DataT,NodeT> dependencyGraph)
dependencyGraph
- the dependency DAGpublic void addDependentGraph(DAGraph<DataT,NodeT> dependentGraph)
dependentGraph
- the dependent DAGpublic void prepareForEnumeration()
public NodeT getNext()
public void reportCompletion(NodeT completed)
completed
- the node ready to be consumedCopyright © 2019. All rights reserved.