Class ExecutionGraphNode

java.lang.Object
org.mpi_sws.jmc.strategies.trust.ExecutionGraphNode

public class ExecutionGraphNode extends Object
Represents a node in the execution graph.
  • Field Details

  • Constructor Details

  • Method Details

    • clone

      public ExecutionGraphNode clone()
      Constructs a new ExecutionGraphNode copying the given node.
      Overrides:
      clone in class Object
    • key

      public Event.Key key()
    • getVectorClock

      public LamportVectorClock getVectorClock()
      Returns the vector clock of this node.
      Returns:
      The vector clock of this node.
    • addEdge

      public void addEdge(ExecutionGraphNode to, Relation adjacency)
      Adds an edge to this node. The edge is directed from this node to the given node with the given adjacency.
      Parameters:
      to - The node to which the edge is directed.
      adjacency - The adjacency of the edge.
    • removeEdge

      public void removeEdge(ExecutionGraphNode to, Relation adjacency)
      Removes the edge with the given adjacency from this node.

      Note that removing an edge invalidates the vector clock of all descendants. The concern of fixing the vector clocks is passed to the calling function.

      Parameters:
      to - The node to which the edge is directed.
      adjacency - The adjacency of the edge.
    • removeEdge

      public void removeEdge(Relation relation)
      Removes the edge with the given relation from this node.

      Leads to dandling references

      Parameters:
      relation - The relation of the edge.
    • removeAllEdgesTo

      public void removeAllEdgesTo(Event.Key to)
    • removeEdgeTo

      public void removeEdgeTo(Event.Key to, Relation adjacency)
    • removeAllEdgesFrom

      public void removeAllEdgesFrom(Event.Key from)
      Removes all edges from the given node.
      Parameters:
      from - The node from which the edges are directed.
    • removePredecessor

      public void removePredecessor(ExecutionGraphNode from, Relation adjacency)
      Removes the predecessor with the given adjacency from this node.
      Parameters:
      from - The node from which the edge is directed.
      adjacency - The adjacency of the edge.
    • removePredecessor

      public void removePredecessor(ExecutionGraphNode from)
    • removeAllPredecessors

      public void removeAllPredecessors(Relation adjacency)
      Removes all the predecessors with the given adjacency from this node.
      Parameters:
      adjacency - The adjacency of the edges.
    • getAllSuccessors

      public Map<Relation,List<Event.Key>> getAllSuccessors()
      Returns the edges of this node.
      Returns:
      The edges of this node.
    • getSuccessors

      public List<Event.Key> getSuccessors(Relation adjacency)
      Returns the neighbours of this node that have the given adjacency.
      Parameters:
      adjacency - The adjacency of the neighbours.
      Returns:
      The neighbours of this node that have the given adjacency.
    • getEdges

      public Map<Relation,List<Event.Key>> getEdges()
      Returns the edges of this node.
      Returns:
      The edges of this node.
    • hasEdge

      public boolean hasEdge(Event.Key to, Relation adjacency)
      Returns whether this node has an edge to the given node with the given adjacency.
      Parameters:
      to - The node to which the edge is directed.
      adjacency - The adjacency of the edge.
      Returns:
      Whether this node has an edge to the given node with the given adjacency.
    • getAllPredecessors

      public Map<Relation,List<Event.Key>> getAllPredecessors()
      Returns all the predecessors of this node.
      Returns:
      The predecessors of this node.
    • getPredecessors

      public List<Event.Key> getPredecessors(Relation adjacency)
      Returns the back edges of this node.
      Returns:
      The back edges of this node.
    • getInDegree

      public int getInDegree()
      Returns the number of incoming edges of this node.
      Returns:
      The number of incoming edges of this node.
    • forEachPredecessor

      public void forEachPredecessor(BiConsumer<Relation,List<Event.Key>> iterator)
    • forEachSuccessor

      public void forEachSuccessor(BiConsumer<Relation,List<Event.Key>> iterator)
    • happensBefore

      public boolean happensBefore(ExecutionGraphNode other)
      Check if `this` node is happens-before (_porf_ relation) the `other` node.

      Determined using vector clocks

      Parameters:
      other - The other node to compare against.
      Returns:
      Returns true if the `this` is happens-before `other`
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Updates the attributes of this node.
      Parameters:
      attributes - The new attributes of this node.
    • addAttribute

      public void addAttribute(String key, Object value)
      Adds an attribute to this node.
      Parameters:
      key - The key of the attribute.
      value - The value of the attribute.
    • getAttribute

      public <T> T getAttribute(String key)
      Returns the attribute with the given key.
      Type Parameters:
      T - The type of the attribute.
      Parameters:
      key - The key of the attribute.
      Returns:
      The attribute with the given key.
    • getEvent

      public Event getEvent()
      Returns the Event that this node represents.
      Returns:
      The event that this node represents.
    • toJson

      public com.google.gson.JsonElement toJson()
    • toJsonIgnoreLocation

      public com.google.gson.JsonElement toJsonIgnoreLocation()
    • getPoPredecessor

      public Event.Key getPoPredecessor()
      Returns the predecessor of this node in the program order.
      Returns:
      The predecessor of this node in the program order.
    • setVectorClock

      public void setVectorClock(LamportVectorClock newClock)
      Updates the vector clock of this node.
      Parameters:
      newClock - The new vector clock of this node.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equalsEdges

      public boolean equalsEdges(ExecutionGraphNode other)
    • hasPredecessor

      public boolean hasPredecessor(Event.Key key, Relation relation)
      Checks if this node has a predecessor with the given key and relation.
      Parameters:
      key - The key of the predecessor.
      relation - The relation of the predecessor.
      Returns:
      True if this node has a predecessor with the given key and relation, false otherwise.