Commit 13139b5f authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Core] enh: add ticket in hook execution context

parent 18971d4a
Pipeline #1186 failed with stages
in 23 minutes and 29 seconds
......@@ -24,6 +24,7 @@ import org.openmole.core.preference.Preference
import org.openmole.core.serializer.SerializerService
import org.openmole.core.threadprovider.ThreadProvider
import org.openmole.core.workflow.builder.{ InfoConfig, InputOutputConfig }
import org.openmole.core.workflow.mole.Ticket
import org.openmole.core.workflow.tools._
import org.openmole.core.workspace.{ TmpDirectory, Workspace }
import org.openmole.tool.cache.KeyValueCache
......@@ -33,6 +34,7 @@ import org.openmole.tool.random.RandomProvider
case class HookExecutionContext(
cache: KeyValueCache,
ticket: Ticket,
implicit val preference: Preference,
implicit val threadProvider: ThreadProvider,
implicit val fileService: FileService,
......
......@@ -259,6 +259,7 @@ object MoleExecution extends JavaLogger {
val services = executionContext.services
HookExecutionContext(
cache = cache,
ticket = ticket,
preference = services.preference,
threadProvider = services.threadProvider,
fileService = services.fileService,
......@@ -681,7 +682,7 @@ class MoleExecution(
def endTime(implicit s: MoleExecution.SynchronisationContext) = sync(_endTime)
private[mole] var ticketNumber = 1L
private[mole] val rootTicket = Ticket(id, 0)
private[mole] val rootTicket = Ticket.root(0L)
private[mole] var moleId = 0L
......
......@@ -18,19 +18,26 @@
package org.openmole.core.workflow.mole
object Ticket {
def apply(category: String, content: Long) = new Ticket(content, null)
def root(content: Long) = new Ticket(content, null)
def apply(parent: Ticket, content: Long) = new Ticket(content, parent)
implicit def ordering = Ordering.by[Ticket, Long](_.content)
def toString(t: Ticket): String = t.content.toString
}
class Ticket(val content: Long, _parent: Ticket) {
def parent = Some(_parent)
sealed class Ticket(val content: Long, _parent: Ticket) {
def parent = Option(_parent)
def parentOrException = parent.getOrElse(throw new InternalError("This is a root ticket, it has no parent."))
def isRoot: Boolean = _parent == null
override def equals(obj: Any): Boolean = content == obj
override def toString = Ticket.toString(this)
override def equals(obj: Any): Boolean = obj match {
case t: Ticket t.content == content
case t: Long t == content
case _ false
}
override def hashCode = content.hashCode
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment