Class CommitOrderCalculator
- java.lang.Object
-
- org.eclipse.persistence.internal.sessions.CommitOrderCalculator
-
public class CommitOrderCalculator extends Object
This class calculates a commit order for a series of classes based on the dependencies between them. It builds up a graph of dependencies (CommitOrderDependencyNodes) then applies topological sort to them to get an ordering. This is a throwaway class, which exists only for the lifetime of the calculation. The algorithm is described in the method comment for orderCommits(). This class also includes static methods for quicksort, copied from the standard libraries and adapted for these objects, since that seemed like the easiest way to sort.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
currentTime
protected Vector
nodes
protected Vector
orderedDescriptors
protected AbstractSession
session
-
Constructor Summary
Constructors Constructor Description CommitOrderCalculator(AbstractSession session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addNode(ClassDescriptor d)
void
addNodes(Vector descriptors)
void
calculateMappingDependencies()
Add to each node the dependent nodesvoid
calculateSpecifiedDependencies()
Add to each node the dependent nodesvoid
depthFirstSearch()
int
getNextTime()
Vector
getNodes()
Vector
getOrderedClasses()
Return the constraint ordered classes.Vector
getOrderedDescriptors()
Return the constraint ordered descriptors.CommitOrderDependencyNode
nodeFor(Class c)
CommitOrderDependencyNode
nodeFor(ClassDescriptor d)
void
orderCommits()
Calculate the commit order.
-
-
-
Field Detail
-
currentTime
protected int currentTime
-
nodes
protected Vector nodes
-
orderedDescriptors
protected Vector orderedDescriptors
-
session
protected AbstractSession session
-
-
Constructor Detail
-
CommitOrderCalculator
public CommitOrderCalculator(AbstractSession session)
-
-
Method Detail
-
addNode
protected void addNode(ClassDescriptor d)
-
addNodes
public void addNodes(Vector descriptors)
-
calculateMappingDependencies
public void calculateMappingDependencies()
Add to each node the dependent nodes
-
calculateSpecifiedDependencies
public void calculateSpecifiedDependencies()
Add to each node the dependent nodes
-
depthFirstSearch
public void depthFirstSearch()
-
getNextTime
public int getNextTime()
-
getNodes
public Vector getNodes()
-
getOrderedClasses
public Vector getOrderedClasses()
Return the constraint ordered classes.
-
getOrderedDescriptors
public Vector getOrderedDescriptors()
Return the constraint ordered descriptors.
-
nodeFor
public CommitOrderDependencyNode nodeFor(Class c)
-
nodeFor
public CommitOrderDependencyNode nodeFor(ClassDescriptor d)
-
orderCommits
public void orderCommits()
Calculate the commit order. Do a depth first search on the graph, skipping nodes that we have already visited or are in the process of visiting. Keep a counter and note when we first encounter a node and when we finish visiting it. Once we've visited everything, sort nodes by finishing time
-
-