Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/344#discussion_r24093420
  
    --- Diff: 
flink-runtime/src/main/scala/org/apache/flink/runtime/jobmanager/MemoryArchivist.scala
 ---
    @@ -25,48 +25,82 @@ import org.apache.flink.runtime.jobgraph.JobID
     import org.apache.flink.runtime.messages.ArchiveMessages._
     import org.apache.flink.runtime.messages.JobManagerMessages._
     
    +import scala.collection.mutable.LinkedHashMap
    +import scala.ref.SoftReference
    +
     class MemoryArchivist(private val max_entries: Int) extends Actor with 
ActorLogMessages with
     ActorLogging {
       /**
        * Map of execution graphs belonging to recently started jobs with the 
time stamp of the last
    -   * received job event.
    +   * received job event. The insert order is preserved through a 
LinkedHashMap.
        */
    -  val graphs = collection.mutable.HashMap[JobID, ExecutionGraph]()
    -  val lru = collection.mutable.Queue[JobID]()
    +  val graphs = LinkedHashMap[JobID, SoftReference[ExecutionGraph]]()
     
       override def receiveWithLogMessages: Receive = {
    +    /* Receive Execution Graph to archive */
         case ArchiveExecutionGraph(jobID, graph) => {
    -      graphs.update(jobID, graph)
    +      // wrap graph inside a soft reference
    +      graphs.update(jobID, new SoftReference(graph))
    +
    +      // clear all execution edges of the graph
    +      val iter = graph.getAllExecutionVertices().iterator()
    +      while (iter.hasNext) {
    +        iter.next().clearExecutionEdges()
    +      }
    +
           cleanup(jobID)
         }
     
         case RequestArchivedJobs => {
    -      sender ! ArchivedJobs(graphs.values)
    +      sender ! ArchivedJobs(getAllGraphs())
         }
     
         case RequestJob(jobID) => {
    -      graphs.get(jobID) match {
    -        case Some(graph) => sender ! JobFound(jobID, graph)
    -        case None => sender ! JobNotFound(jobID)
    +      getGraph(jobID) match {
    --- End diff --
    
    Nice read. I'll try to avoid null the next time.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to