DAGNode<DataT,NodeT> Class

Type Parameters

DataT

the type of the data stored in the node

NodeT

the type of the node

public class DAGNode<DataT,NodeT>
extends Node<DataT,NodeT>

The type representing node in a DAGraph<DataT,NodeT>.

Constructor Summary

Constructor Description
DAGNode(String key, DataT data)

Creates a DAG node.

Method Summary

Modifier and Type Method and Description
void addDependency(String dependencyKey)

Mark the node identified by the given key as this node's dependency.

void addDependent(String key)

Mark the node identified by the given key as dependent of this node.

List<String> dependencyKeys()
boolean hasDependencies()
void initialize()

Initialize the node so that traversal can be performed on the parent DAG.

boolean isPreparer()
ReentrantLock lock()
protected void onFaultedResolution(String dependencyKey, Throwable throwable)

Reports a dependency of this node has been faulted.

protected void onSuccessfulResolution(String dependencyKey)

Reports a dependency of this node has been successfully resolved.

void removeDependency(String dependencyKey)

Remove the dependency node identified by the given key from the dependencies.

void setPreparer(boolean isPreparer)

Mark or un-mark this node as preparer.

Methods inherited from Node

Methods inherited from java.lang.Object

Constructor Details

DAGNode

public DAGNode(String key, DataT data)

Creates a DAG node.

Parameters:

key - unique id of the node
data - data to be stored in the node

Method Details

addDependency

public void addDependency(String dependencyKey)

Mark the node identified by the given key as this node's dependency.

Parameters:

dependencyKey - the id of the dependency node

addDependent

public void addDependent(String key)

Mark the node identified by the given key as dependent of this node.

Parameters:

key - the id of the dependent node

dependencyKeys

public List dependencyKeys()

Returns:

a list of keys of nodes in DAGraph<DataT,NodeT> that this node depends on

hasDependencies

public boolean hasDependencies()

Returns:

true if this node has any dependency

initialize

public void initialize()

Initialize the node so that traversal can be performed on the parent DAG.

isPreparer

public boolean isPreparer()

Returns:

true if this node is marked as preparer

lock

public ReentrantLock lock()

Returns:

the lock to be used while performing thread safe operation on this node.

onFaultedResolution

protected void onFaultedResolution(String dependencyKey, Throwable throwable)

Reports a dependency of this node has been faulted.

Parameters:

dependencyKey - the id of the dependency node
throwable - the reason for unsuccessful resolution

onSuccessfulResolution

protected void onSuccessfulResolution(String dependencyKey)

Reports a dependency of this node has been successfully resolved.

Parameters:

dependencyKey - the id of the dependency node

removeDependency

public void removeDependency(String dependencyKey)

Remove the dependency node identified by the given key from the dependencies.

Parameters:

dependencyKey - the id of the dependency node

setPreparer

public void setPreparer(boolean isPreparer)

Mark or un-mark this node as preparer.

Parameters:

isPreparer - true if this node needs to be marked as preparer, false otherwise.

Applies to