author | wenzelm |
Sun, 02 Jul 2023 19:51:03 +0200 | |
changeset 78245 | eca6ae2a09d7 |
parent 78244 | 635ba0cbfe60 |
child 78246 | 76dd9b9cf624 |
permissions | -rw-r--r-- |
77238 | 1 |
/* Title: Pure/Tools/build_process.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Build process for sessions, with build database, optional heap, and |
|
5 |
optional presentation. |
|
6 |
*/ |
|
7 |
||
8 |
package isabelle |
|
9 |
||
10 |
||
77505 | 11 |
import scala.collection.immutable.SortedMap |
77246 | 12 |
import scala.math.Ordering |
77257 | 13 |
import scala.annotation.tailrec |
77246 | 14 |
|
15 |
||
77238 | 16 |
object Build_Process { |
77436 | 17 |
/** static context **/ |
77238 | 18 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
19 |
sealed case class Context( |
78216 | 20 |
store: Store, |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
21 |
build_deps: isabelle.Sessions.Deps, |
78216 | 22 |
ml_platform: String = Isabelle_System.getenv("ML_PLATFORM"), |
23 |
hostname: String = Isabelle_System.hostname(), |
|
24 |
numa_shuffling: Boolean = false, |
|
25 |
build_heap: Boolean = false, |
|
26 |
max_jobs: Int = 1, |
|
27 |
fresh_build: Boolean = false, |
|
28 |
no_build: Boolean = false, |
|
29 |
session_setup: (String, Session) => Unit = (_, _) => (), |
|
30 |
build_uuid: String = UUID.random().toString, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
31 |
master: Boolean = false |
77246 | 32 |
) { |
77561 | 33 |
override def toString: String = |
77646 | 34 |
"Build_Process.Context(build_uuid = " + quote(build_uuid) + |
35 |
if_proper(master, ", master = true") + ")" |
|
77561 | 36 |
|
77470 | 37 |
def build_options: Options = store.options |
38 |
||
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
39 |
def sessions_structure: isabelle.Sessions.Structure = build_deps.sessions_structure |
77578
149d48a4801b
support for "isabelle build -j0": require external workers to make progress;
wenzelm
parents:
77561
diff
changeset
|
40 |
|
77594 | 41 |
def worker_active: Boolean = max_jobs > 0 |
77246 | 42 |
} |
77257 | 43 |
|
44 |
||
77436 | 45 |
|
46 |
/** dynamic state **/ |
|
77257 | 47 |
|
78238 | 48 |
sealed case class Build( |
78173 | 49 |
build_uuid: String, // Database_Progress.context_uuid |
77660 | 50 |
ml_platform: String, |
51 |
options: String, |
|
52 |
start: Date, |
|
78226 | 53 |
stop: Option[Date], |
54 |
sessions: List[String] |
|
78222 | 55 |
) { |
56 |
def active: Boolean = stop.isEmpty |
|
57 |
} |
|
77660 | 58 |
|
78238 | 59 |
sealed case class Worker( |
78173 | 60 |
worker_uuid: String, // Database_Progress.agent_uuid |
77631 | 61 |
build_uuid: String, |
62 |
start: Date, |
|
63 |
stamp: Date, |
|
64 |
stop: Option[Date], |
|
65 |
serial: Long |
|
66 |
) |
|
67 |
||
78238 | 68 |
sealed case class Task( |
77631 | 69 |
name: String, |
70 |
deps: List[String], |
|
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
71 |
info: JSON.Object.T, |
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
72 |
build_uuid: String |
77631 | 73 |
) { |
77313
f8aa1647d156
more elementary data structures, to fit better to SQL database;
wenzelm
parents:
77312
diff
changeset
|
74 |
def is_ready: Boolean = deps.isEmpty |
77585 | 75 |
def resolve(dep: String): Task = |
77313
f8aa1647d156
more elementary data structures, to fit better to SQL database;
wenzelm
parents:
77312
diff
changeset
|
76 |
if (deps.contains(dep)) copy(deps = deps.filterNot(_ == dep)) else this |
f8aa1647d156
more elementary data structures, to fit better to SQL database;
wenzelm
parents:
77312
diff
changeset
|
77 |
} |
f8aa1647d156
more elementary data structures, to fit better to SQL database;
wenzelm
parents:
77312
diff
changeset
|
78 |
|
78238 | 79 |
sealed case class Job( |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
80 |
name: String, |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
81 |
worker_uuid: String, |
77634 | 82 |
build_uuid: String, |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
83 |
node_info: Host.Node_Info, |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
84 |
build: Option[Build_Job] |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
85 |
) extends Library.Named { |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
86 |
def no_build: Job = copy(build = None) |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
87 |
} |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
88 |
|
78238 | 89 |
sealed case class Result( |
77651 | 90 |
name: String, |
91 |
worker_uuid: String, |
|
92 |
build_uuid: String, |
|
93 |
node_info: Host.Node_Info, |
|
77461 | 94 |
process_result: Process_Result, |
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77459
diff
changeset
|
95 |
output_shasum: SHA1.Shasum, |
77461 | 96 |
current: Boolean |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
97 |
) extends Library.Named { |
77259
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
98 |
def ok: Boolean = process_result.ok |
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
99 |
} |
77312 | 100 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
101 |
object Sessions { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
102 |
type Graph = isabelle.Graph[String, Build_Job.Session_Context] |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
103 |
val empty: Sessions = new Sessions(Graph.string) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
104 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
105 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
106 |
final class Sessions private(val graph: Sessions.Graph) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
107 |
override def toString: String = graph.toString |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
108 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
109 |
def apply(name: String): Build_Job.Session_Context = graph.get_node(name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
110 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
111 |
def iterator: Iterator[Build_Job.Session_Context] = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
112 |
for (name <- graph.topological_order.iterator) yield apply(name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
113 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
114 |
def make(new_graph: Sessions.Graph): Sessions = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
115 |
if (graph == new_graph) this |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
116 |
else { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
117 |
new Sessions( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
118 |
new_graph.iterator.foldLeft(new_graph) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
119 |
case (g, (name, (session, _))) => g.add_deps_acyclic(name, session.deps) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
120 |
}) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
121 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
122 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
123 |
def pull( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
124 |
data_domain: Set[String], |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
125 |
data: Set[String] => List[Build_Job.Session_Context] |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
126 |
): Sessions = { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
127 |
val dom = data_domain -- iterator.map(_.name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
128 |
make(data(dom).foldLeft(graph.restrict(dom)) { case (g, e) => g.new_node(e.name, e) }) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
129 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
130 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
131 |
def init(build_context: Context, progress: Progress = new Progress): Sessions = { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
132 |
val sessions_structure = build_context.sessions_structure |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
133 |
make( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
134 |
sessions_structure.build_graph.iterator.foldLeft(graph) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
135 |
case (graph0, (name, (info, _))) => |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
136 |
val deps = info.parent.toList |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
137 |
val prefs = info.session_prefs |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
138 |
val ancestors = sessions_structure.build_requirements(deps) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
139 |
val sources_shasum = build_context.build_deps.sources_shasum(name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
140 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
141 |
if (graph0.defined(name)) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
142 |
val session0 = graph0.get_node(name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
143 |
val prefs0 = session0.session_prefs |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
144 |
val ancestors0 = session0.ancestors |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
145 |
val sources_shasum0 = session0.sources_shasum |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
146 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
147 |
def err(msg: String, a: String, b: String): Nothing = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
148 |
error("Conflicting dependencies for session " + quote(name) + ": " + |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
149 |
msg + "\n" + a + "\nvs.\n" + b) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
150 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
151 |
if (prefs0 != prefs) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
152 |
err("preferences disagree", |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
153 |
Symbol.cartouche_decoded(prefs0), Symbol.cartouche_decoded(prefs)) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
154 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
155 |
if (ancestors0 != ancestors) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
156 |
err("ancestors disagree", commas_quote(ancestors0), commas_quote(ancestors)) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
157 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
158 |
if (sources_shasum0 != sources_shasum) { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
159 |
val a = sources_shasum0 - sources_shasum |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
160 |
val b = sources_shasum - sources_shasum0 |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
161 |
err("sources disagree", a.toString, b.toString) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
162 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
163 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
164 |
graph0 |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
165 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
166 |
else { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
167 |
val session = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
168 |
Build_Job.Session_Context.load( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
169 |
build_context.build_uuid, name, deps, ancestors, prefs, sources_shasum, |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
170 |
info.timeout, build_context.store, progress = progress) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
171 |
graph0.new_node(name, session) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
172 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
173 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
174 |
) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
175 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
176 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
177 |
lazy val max_time: Map[String, Double] = { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
178 |
val maximals = graph.maximals.toSet |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
179 |
def descendants_time(name: String): Double = { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
180 |
if (maximals.contains(name)) apply(name).old_time.seconds |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
181 |
else { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
182 |
val descendants = graph.all_succs(List(name)).toSet |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
183 |
val g = graph.restrict(descendants) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
184 |
(0.0 :: g.maximals.flatMap { desc => |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
185 |
val ps = g.all_preds(List(desc)) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
186 |
if (ps.exists(p => !graph.defined(p))) None |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
187 |
else Some(ps.map(p => apply(p).old_time.seconds).sum) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
188 |
}).max |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
189 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
190 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
191 |
Map.from( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
192 |
for (name <- graph.keys_iterator) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
193 |
yield name -> descendants_time(name)).withDefaultValue(0.0) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
194 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
195 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
196 |
lazy val ordering: Ordering[String] = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
197 |
(a: String, b: String) => |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
198 |
max_time(b) compare max_time(a) match { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
199 |
case 0 => |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
200 |
apply(b).timeout compare apply(a).timeout match { |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
201 |
case 0 => a compare b |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
202 |
case ord => ord |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
203 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
204 |
case ord => ord |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
205 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
206 |
} |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
207 |
|
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
208 |
sealed case class Snapshot( |
77660 | 209 |
builds: List[Build], // available build configurations |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
210 |
workers: List[Worker], // available worker processes |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
211 |
sessions: Sessions, // static build targets |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
212 |
pending: State.Pending, // dynamic build "queue" |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
213 |
running: State.Running, // presently running jobs |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
214 |
results: State.Results) // finished results |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
215 |
|
77496 | 216 |
object State { |
77585 | 217 |
type Pending = List[Task] |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
218 |
type Running = Map[String, Job] |
77496 | 219 |
type Results = Map[String, Result] |
77513 | 220 |
|
221 |
def inc_serial(serial: Long): Long = { |
|
78243 | 222 |
require(serial < Long.MaxValue, "serial overflow") |
77513 | 223 |
serial + 1 |
224 |
} |
|
77496 | 225 |
} |
226 |
||
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
227 |
sealed case class State( |
77372 | 228 |
serial: Long = 0, |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
229 |
numa_nodes: List[Int] = Nil, |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
230 |
sessions: Sessions = Sessions.empty, |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
231 |
pending: State.Pending = Nil, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
232 |
running: State.Running = Map.empty, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
233 |
results: State.Results = Map.empty |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
234 |
) { |
77513 | 235 |
require(serial >= 0, "serial underflow") |
236 |
def inc_serial: State = copy(serial = State.inc_serial(serial)) |
|
237 |
def set_serial(i: Long): State = { |
|
238 |
require(serial <= i, "non-monotonic change of serial") |
|
239 |
copy(serial = i) |
|
240 |
} |
|
241 |
||
77335 | 242 |
def finished: Boolean = pending.isEmpty |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
243 |
|
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
244 |
def remove_pending(name: String): State = |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
245 |
copy(pending = pending.flatMap( |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
246 |
entry => if (entry.name == name) None else Some(entry.resolve(name)))) |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
247 |
|
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
248 |
def is_running(name: String): Boolean = running.isDefinedAt(name) |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
249 |
|
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
250 |
def stop_running(): Unit = |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
251 |
for (job <- running.valuesIterator; build <- job.build) build.cancel() |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
252 |
|
77649 | 253 |
def finished_running(): List[Job] = |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
254 |
List.from( |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
255 |
for (job <- running.valuesIterator; build <- job.build if build.is_finished) |
77649 | 256 |
yield job) |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
257 |
|
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
258 |
def add_running(job: Job): State = |
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
259 |
copy(running = running + (job.name -> job)) |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
260 |
|
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
261 |
def remove_running(name: String): State = |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
262 |
copy(running = running - name) |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
263 |
|
77336 | 264 |
def make_result( |
77651 | 265 |
result_name: (String, String, String), |
77461 | 266 |
process_result: Process_Result, |
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77459
diff
changeset
|
267 |
output_shasum: SHA1.Shasum, |
77475 | 268 |
node_info: Host.Node_Info = Host.Node_Info.none, |
77461 | 269 |
current: Boolean = false |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
270 |
): State = { |
77651 | 271 |
val (name, worker_uuid, build_uuid) = result_name |
272 |
val result = |
|
273 |
Result(name, worker_uuid, build_uuid, node_info, process_result, output_shasum, current) |
|
274 |
copy(results = results + (name -> result)) |
|
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
275 |
} |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
276 |
} |
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
277 |
|
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
278 |
|
77436 | 279 |
|
280 |
/** SQL data model **/ |
|
77372 | 281 |
|
78187
2df0f3604a67
clarified signature: more explicit class SQL.Data;
wenzelm
parents:
78185
diff
changeset
|
282 |
object Data extends SQL.Data("isabelle_build") { |
78168 | 283 |
val database: Path = Path.explode("$ISABELLE_HOME_USER/build.db") |
284 |
||
78244 | 285 |
def pull[A <: Library.Named]( |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
286 |
data_domain: Set[String], |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
287 |
data_iterator: Set[String] => Iterator[A], |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
288 |
old_data: Map[String, A] |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
289 |
): Map[String, A] = { |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
290 |
val dom = data_domain -- old_data.keysIterator |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
291 |
val data = old_data -- old_data.keysIterator.filterNot(dom) |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
292 |
if (dom.isEmpty) data |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
293 |
else data_iterator(dom).foldLeft(data) { case (map, a) => map + (a.name -> a) } |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
294 |
} |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
295 |
|
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
296 |
def pull0[A <: Library.Named]( |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
297 |
new_data: Map[String, A], |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
298 |
old_data: Map[String, A] |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
299 |
): Map[String, A] = { |
78244 | 300 |
pull(new_data.keySet, dom => new_data.valuesIterator.filter(a => dom(a.name)), old_data) |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
301 |
} |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
302 |
|
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
303 |
def pull1[A <: Library.Named]( |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
304 |
data_domain: Set[String], |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
305 |
data_base: Set[String] => Map[String, A], |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
306 |
old_data: Map[String, A] |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
307 |
): Map[String, A] = { |
78244 | 308 |
pull(data_domain, dom => data_base(dom).valuesIterator, old_data) |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
309 |
} |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
310 |
|
77372 | 311 |
object Generic { |
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
312 |
val build_uuid = SQL.Column.string("build_uuid") |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
313 |
val worker_uuid = SQL.Column.string("worker_uuid") |
77372 | 314 |
val name = SQL.Column.string("name") |
315 |
||
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
316 |
def sql( |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
317 |
build_uuid: String = "", |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
318 |
worker_uuid: String = "", |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
319 |
names: Iterable[String] = Nil |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
320 |
): SQL.Source = |
77372 | 321 |
SQL.and( |
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
322 |
if_proper(build_uuid, Generic.build_uuid.equal(build_uuid)), |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
323 |
if_proper(worker_uuid, Generic.worker_uuid.equal(worker_uuid)), |
77375 | 324 |
if_proper(names, Generic.name.member(names))) |
77662 | 325 |
|
326 |
def sql_where( |
|
327 |
build_uuid: String = "", |
|
328 |
worker_uuid: String = "", |
|
329 |
names: Iterable[String] = Nil |
|
330 |
): SQL.Source = { |
|
77663 | 331 |
SQL.where(sql(build_uuid = build_uuid, worker_uuid = worker_uuid, names = names)) |
77662 | 332 |
} |
77372 | 333 |
} |
334 |
||
77536
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
335 |
|
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
336 |
/* base table */ |
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
337 |
|
77417 | 338 |
object Base { |
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
339 |
val build_uuid = Generic.build_uuid.make_primary_key |
77387
cd10b8edfdf5
clarified db content: avoid redundancy of historic ML_IDENTIFIER;
wenzelm
parents:
77385
diff
changeset
|
340 |
val ml_platform = SQL.Column.string("ml_platform") |
77372 | 341 |
val options = SQL.Column.string("options") |
77536
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
342 |
val start = SQL.Column.date("start") |
77545 | 343 |
val stop = SQL.Column.date("stop") |
77372 | 344 |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
345 |
val table = make_table("", List(build_uuid, ml_platform, options, start, stop)) |
77536
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
346 |
} |
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
347 |
|
78226 | 348 |
def read_builds(db: SQL.Database, build_uuid: String = ""): List[Build] = { |
349 |
val builds = |
|
350 |
db.execute_query_statement( |
|
351 |
Base.table.select(sql = Generic.sql_where(build_uuid = build_uuid)), |
|
352 |
List.from[Build], |
|
353 |
{ res => |
|
354 |
val build_uuid = res.string(Base.build_uuid) |
|
355 |
val ml_platform = res.string(Base.ml_platform) |
|
356 |
val options = res.string(Base.options) |
|
357 |
val start = res.date(Base.start) |
|
358 |
val stop = res.get_date(Base.stop) |
|
359 |
Build(build_uuid, ml_platform, options, start, stop, Nil) |
|
360 |
}) |
|
361 |
||
362 |
for (build <- builds.sortBy(_.start)(Date.Ordering)) yield { |
|
363 |
val sessions = Data.read_sessions_domain(db, build_uuid = build.build_uuid) |
|
364 |
build.copy(sessions = sessions.toList.sorted) |
|
365 |
} |
|
366 |
} |
|
77660 | 367 |
|
77536
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
368 |
def start_build( |
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
369 |
db: SQL.Database, |
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
370 |
build_uuid: String, |
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
371 |
ml_platform: String, |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
372 |
options: String |
77536
7c7f1473e51a
clarified database content and prepare/init stages;
wenzelm
parents:
77534
diff
changeset
|
373 |
): Unit = { |
77541 | 374 |
db.execute_statement(Base.table.insert(), body = |
375 |
{ stmt => |
|
376 |
stmt.string(1) = build_uuid |
|
377 |
stmt.string(2) = ml_platform |
|
378 |
stmt.string(3) = options |
|
379 |
stmt.date(4) = db.now() |
|
380 |
stmt.date(5) = None |
|
381 |
}) |
|
77372 | 382 |
} |
383 |
||
77545 | 384 |
def stop_build(db: SQL.Database, build_uuid: String): Unit = |
77541 | 385 |
db.execute_statement( |
77636 | 386 |
Base.table.update(List(Base.stop), sql = Base.build_uuid.where_equal(build_uuid)), |
77541 | 387 |
body = { stmt => stmt.date(1) = db.now() }) |
77538 | 388 |
|
77539
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
389 |
def clean_build(db: SQL.Database): Unit = { |
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
390 |
val old = |
77552 | 391 |
db.execute_query_statement( |
392 |
Base.table.select(List(Base.build_uuid), sql = SQL.where(Base.stop.defined)), |
|
393 |
List.from[String], res => res.string(Base.build_uuid)) |
|
77539
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
394 |
|
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
395 |
if (old.nonEmpty) { |
77658 | 396 |
for (table <- build_uuid_tables) { |
77540 | 397 |
db.execute_statement(table.delete(sql = Generic.build_uuid.where_member(old))) |
77539
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
398 |
} |
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
399 |
} |
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
400 |
} |
2b996a0df1ce
proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
wenzelm
parents:
77538
diff
changeset
|
401 |
|
77416
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
402 |
|
77531 | 403 |
/* sessions */ |
77505 | 404 |
|
77496 | 405 |
object Sessions { |
406 |
val name = Generic.name.make_primary_key |
|
407 |
val deps = SQL.Column.string("deps") |
|
408 |
val ancestors = SQL.Column.string("ancestors") |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
409 |
val options = SQL.Column.string("options") |
77496 | 410 |
val sources = SQL.Column.string("sources") |
411 |
val timeout = SQL.Column.long("timeout") |
|
412 |
val old_time = SQL.Column.long("old_time") |
|
413 |
val old_command_timings = SQL.Column.bytes("old_command_timings") |
|
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
414 |
val build_uuid = Generic.build_uuid |
77496 | 415 |
|
416 |
val table = make_table("sessions", |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
417 |
List(name, deps, ancestors, options, sources, timeout, |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
418 |
old_time, old_command_timings, build_uuid)) |
77496 | 419 |
} |
420 |
||
78218
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
421 |
def read_sessions_domain(db: SQL.Database, build_uuid: String = ""): Set[String] = |
77552 | 422 |
db.execute_query_statement( |
78218
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
423 |
Sessions.table.select(List(Sessions.name), |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
424 |
sql = if_proper(build_uuid, Sessions.name.where_equal(build_uuid))), |
77552 | 425 |
Set.from[String], res => res.string(Sessions.name)) |
77496 | 426 |
|
78218
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
427 |
def read_sessions(db: SQL.Database, |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
428 |
names: Iterable[String] = Nil, |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
429 |
build_uuid: String = "" |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
430 |
): List[Build_Job.Session_Context] = { |
77552 | 431 |
db.execute_query_statement( |
78218
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
432 |
Sessions.table.select( |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
433 |
sql = |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
434 |
SQL.where_and( |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
435 |
if_proper(names, Sessions.name.member(names)), |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
436 |
if_proper(build_uuid, Sessions.build_uuid.equal(build_uuid))) |
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
437 |
), |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
438 |
List.from[Build_Job.Session_Context], |
77552 | 439 |
{ res => |
440 |
val name = res.string(Sessions.name) |
|
441 |
val deps = split_lines(res.string(Sessions.deps)) |
|
442 |
val ancestors = split_lines(res.string(Sessions.ancestors)) |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
443 |
val options = res.string(Sessions.options) |
77552 | 444 |
val sources_shasum = SHA1.fake_shasum(res.string(Sessions.sources)) |
445 |
val timeout = Time.ms(res.long(Sessions.timeout)) |
|
446 |
val old_time = Time.ms(res.long(Sessions.old_time)) |
|
447 |
val old_command_timings_blob = res.bytes(Sessions.old_command_timings) |
|
448 |
val build_uuid = res.string(Sessions.build_uuid) |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
449 |
Build_Job.Session_Context(name, deps, ancestors, options, sources_shasum, |
77552 | 450 |
timeout, old_time, old_command_timings_blob, build_uuid) |
77496 | 451 |
} |
77552 | 452 |
) |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
453 |
} |
77496 | 454 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
455 |
def update_sessions(db: SQL.Database, sessions: Build_Process.Sessions): Boolean = { |
77496 | 456 |
val old_sessions = read_sessions_domain(db) |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
457 |
val insert = sessions.iterator.filterNot(s => old_sessions.contains(s.name)).toList |
77496 | 458 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
459 |
for (session <- insert) { |
77541 | 460 |
db.execute_statement(Sessions.table.insert(), body = |
461 |
{ stmt => |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
462 |
stmt.string(1) = session.name |
77541 | 463 |
stmt.string(2) = cat_lines(session.deps) |
464 |
stmt.string(3) = cat_lines(session.ancestors) |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
465 |
stmt.string(4) = session.session_prefs |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
466 |
stmt.string(5) = session.sources_shasum.toString |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
467 |
stmt.long(6) = session.timeout.ms |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
468 |
stmt.long(7) = session.old_time.ms |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
469 |
stmt.bytes(8) = session.old_command_timings_blob |
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77609
diff
changeset
|
470 |
stmt.string(9) = session.build_uuid |
77541 | 471 |
}) |
77496 | 472 |
} |
473 |
||
474 |
insert.nonEmpty |
|
475 |
} |
|
476 |
||
77531 | 477 |
|
478 |
/* workers */ |
|
479 |
||
480 |
object Workers { |
|
78173 | 481 |
val worker_uuid = Generic.worker_uuid.make_primary_key |
482 |
val build_uuid = Generic.build_uuid |
|
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
483 |
val start = SQL.Column.date("start") |
77531 | 484 |
val stamp = SQL.Column.date("stamp") |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
485 |
val stop = SQL.Column.date("stop") |
77531 | 486 |
val serial = SQL.Column.long("serial") |
487 |
||
78172
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
488 |
val table = make_table("workers", List(worker_uuid, build_uuid, start, stamp, stop, serial)) |
77531 | 489 |
} |
490 |
||
77655 | 491 |
def read_serial(db: SQL.Database): Long = |
492 |
db.execute_query_statementO[Long]( |
|
78151 | 493 |
Workers.table.select(List(Workers.serial.max)), _.long(Workers.serial)).getOrElse(0L) |
77655 | 494 |
|
77586 | 495 |
def read_workers( |
496 |
db: SQL.Database, |
|
497 |
build_uuid: String = "", |
|
498 |
worker_uuid: String = "" |
|
77657
a2a4adc268b8
removed redundant State.workers: directly maintained within the database, using with SQL update;
wenzelm
parents:
77656
diff
changeset
|
499 |
): List[Worker] = { |
77586 | 500 |
db.execute_query_statement( |
77662 | 501 |
Workers.table.select( |
502 |
sql = Generic.sql_where(build_uuid = build_uuid, worker_uuid = worker_uuid)), |
|
77586 | 503 |
List.from[Worker], |
504 |
{ res => |
|
505 |
Worker( |
|
506 |
worker_uuid = res.string(Workers.worker_uuid), |
|
507 |
build_uuid = res.string(Workers.build_uuid), |
|
508 |
start = res.date(Workers.start), |
|
509 |
stamp = res.date(Workers.stamp), |
|
510 |
stop = res.get_date(Workers.stop), |
|
511 |
serial = res.long(Workers.serial)) |
|
512 |
}) |
|
513 |
} |
|
514 |
||
77584 | 515 |
def start_worker( |
516 |
db: SQL.Database, |
|
517 |
worker_uuid: String, |
|
518 |
build_uuid: String, |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
519 |
serial: Long |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
520 |
): Unit = { |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
521 |
def err(msg: String): Nothing = |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
522 |
error("Cannot start worker " + worker_uuid + if_proper(msg, "\n" + msg)) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
523 |
|
77552 | 524 |
val build_stop = |
525 |
db.execute_query_statementO( |
|
77636 | 526 |
Base.table.select(List(Base.stop), sql = Base.build_uuid.where_equal(build_uuid)), |
77552 | 527 |
res => res.get_date(Base.stop)) |
528 |
||
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
529 |
build_stop match { |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
530 |
case Some(None) => |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
531 |
case Some(Some(_)) => err("for already stopped build process " + build_uuid) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
532 |
case None => err("for unknown build process " + build_uuid) |
77531 | 533 |
} |
534 |
||
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
535 |
db.execute_statement(Workers.table.insert(), body = |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
536 |
{ stmt => |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
537 |
val now = db.now() |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
538 |
stmt.string(1) = worker_uuid |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
539 |
stmt.string(2) = build_uuid |
78172
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
540 |
stmt.date(3) = now |
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
541 |
stmt.date(4) = now |
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
542 |
stmt.date(5) = None |
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
543 |
stmt.long(6) = serial |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
544 |
}) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
545 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
546 |
|
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
547 |
def stamp_worker( |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
548 |
db: SQL.Database, |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
549 |
worker_uuid: String, |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
550 |
serial: Long, |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
551 |
stop: Boolean = false |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
552 |
): Unit = { |
78241 | 553 |
db.execute_statement( |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
554 |
Workers.table.update(List(Workers.stamp, Workers.stop, Workers.serial), |
78241 | 555 |
sql = Workers.worker_uuid.where_equal(worker_uuid)), |
556 |
body = { stmt => |
|
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
557 |
val now = db.now() |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
558 |
stmt.date(1) = now |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
559 |
stmt.date(2) = if (stop) Some(now) else None |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
560 |
stmt.long(3) = serial |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
561 |
}) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
562 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
563 |
|
77531 | 564 |
|
565 |
/* pending jobs */ |
|
566 |
||
567 |
object Pending { |
|
568 |
val name = Generic.name.make_primary_key |
|
569 |
val deps = SQL.Column.string("deps") |
|
570 |
val info = SQL.Column.string("info") |
|
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
571 |
val build_uuid = Generic.build_uuid |
77531 | 572 |
|
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
573 |
val table = make_table("pending", List(name, deps, info, build_uuid)) |
77531 | 574 |
} |
575 |
||
77585 | 576 |
def read_pending(db: SQL.Database): List[Task] = |
77552 | 577 |
db.execute_query_statement( |
578 |
Pending.table.select(sql = SQL.order_by(List(Pending.name))), |
|
77585 | 579 |
List.from[Task], |
77552 | 580 |
{ res => |
581 |
val name = res.string(Pending.name) |
|
582 |
val deps = res.string(Pending.deps) |
|
583 |
val info = res.string(Pending.info) |
|
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
584 |
val build_uuid = res.string(Pending.build_uuid) |
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
585 |
Task(name, split_lines(deps), JSON.Object.parse(info), build_uuid) |
77552 | 586 |
}) |
77372 | 587 |
|
77496 | 588 |
def update_pending(db: SQL.Database, pending: State.Pending): Boolean = { |
77372 | 589 |
val old_pending = read_pending(db) |
590 |
val (delete, insert) = Library.symmetric_difference(old_pending, pending) |
|
591 |
||
592 |
if (delete.nonEmpty) { |
|
77540 | 593 |
db.execute_statement( |
77662 | 594 |
Pending.table.delete(sql = Generic.sql_where(names = delete.map(_.name)))) |
77372 | 595 |
} |
596 |
||
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
597 |
for (task <- insert) { |
77541 | 598 |
db.execute_statement(Pending.table.insert(), body = |
599 |
{ stmt => |
|
77661
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
600 |
stmt.string(1) = task.name |
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
601 |
stmt.string(2) = cat_lines(task.deps) |
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
602 |
stmt.string(3) = JSON.Format(task.info) |
45bd5c26cbcc
proper build_uuid for Build_Process.Task: thus old entries are removed via prepare_database/clean_build;
wenzelm
parents:
77660
diff
changeset
|
603 |
stmt.string(4) = task.build_uuid |
77541 | 604 |
}) |
77372 | 605 |
} |
606 |
||
607 |
delete.nonEmpty || insert.nonEmpty |
|
608 |
} |
|
609 |
||
77531 | 610 |
|
611 |
/* running jobs */ |
|
612 |
||
613 |
object Running { |
|
614 |
val name = Generic.name.make_primary_key |
|
77587 | 615 |
val worker_uuid = Generic.worker_uuid |
77634 | 616 |
val build_uuid = Generic.build_uuid |
77531 | 617 |
val hostname = SQL.Column.string("hostname") |
618 |
val numa_node = SQL.Column.int("numa_node") |
|
619 |
||
77634 | 620 |
val table = make_table("running", List(name, worker_uuid, build_uuid, hostname, numa_node)) |
77531 | 621 |
} |
622 |
||
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
623 |
def read_running(db: SQL.Database): State.Running = |
77552 | 624 |
db.execute_query_statement( |
625 |
Running.table.select(sql = SQL.order_by(List(Running.name))), |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
626 |
Map.from[String, Job], |
77552 | 627 |
{ res => |
628 |
val name = res.string(Running.name) |
|
77587 | 629 |
val worker_uuid = res.string(Running.worker_uuid) |
77634 | 630 |
val build_uuid = res.string(Running.build_uuid) |
77552 | 631 |
val hostname = res.string(Running.hostname) |
632 |
val numa_node = res.get_int(Running.numa_node) |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
633 |
name -> Job(name, worker_uuid, build_uuid, Host.Node_Info(hostname, numa_node), None) |
77552 | 634 |
} |
635 |
) |
|
77372 | 636 |
|
77496 | 637 |
def update_running(db: SQL.Database, running: State.Running): Boolean = { |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
638 |
val running0 = read_running(db).valuesIterator.toList |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
639 |
val running1 = running.valuesIterator.map(_.no_build).toList |
77372 | 640 |
|
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
641 |
val (delete, insert) = Library.symmetric_difference(running0, running1) |
77372 | 642 |
|
643 |
if (delete.nonEmpty) { |
|
77540 | 644 |
db.execute_statement( |
77662 | 645 |
Running.table.delete(sql = Generic.sql_where(names = delete.map(_.name)))) |
77372 | 646 |
} |
647 |
||
648 |
for (job <- insert) { |
|
77541 | 649 |
db.execute_statement(Running.table.insert(), body = |
650 |
{ stmt => |
|
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
651 |
stmt.string(1) = job.name |
77587 | 652 |
stmt.string(2) = job.worker_uuid |
77634 | 653 |
stmt.string(3) = job.build_uuid |
654 |
stmt.string(4) = job.node_info.hostname |
|
655 |
stmt.int(5) = job.node_info.numa_node |
|
77541 | 656 |
}) |
77372 | 657 |
} |
658 |
||
659 |
delete.nonEmpty || insert.nonEmpty |
|
660 |
} |
|
661 |
||
77531 | 662 |
|
663 |
/* job results */ |
|
664 |
||
665 |
object Results { |
|
666 |
val name = Generic.name.make_primary_key |
|
77651 | 667 |
val worker_uuid = Generic.worker_uuid |
668 |
val build_uuid = Generic.build_uuid |
|
77531 | 669 |
val hostname = SQL.Column.string("hostname") |
670 |
val numa_node = SQL.Column.string("numa_node") |
|
671 |
val rc = SQL.Column.int("rc") |
|
672 |
val out = SQL.Column.string("out") |
|
673 |
val err = SQL.Column.string("err") |
|
674 |
val timing_elapsed = SQL.Column.long("timing_elapsed") |
|
675 |
val timing_cpu = SQL.Column.long("timing_cpu") |
|
676 |
val timing_gc = SQL.Column.long("timing_gc") |
|
77651 | 677 |
val output_shasum = SQL.Column.string("output_shasum") |
678 |
val current = SQL.Column.bool("current") |
|
77531 | 679 |
|
680 |
val table = |
|
681 |
make_table("results", |
|
77651 | 682 |
List(name, worker_uuid, build_uuid, hostname, numa_node, |
683 |
rc, out, err, timing_elapsed, timing_cpu, timing_gc, output_shasum, current)) |
|
77531 | 684 |
} |
685 |
||
77496 | 686 |
def read_results_domain(db: SQL.Database): Set[String] = |
77552 | 687 |
db.execute_query_statement( |
688 |
Results.table.select(List(Results.name)), |
|
689 |
Set.from[String], res => res.string(Results.name)) |
|
77496 | 690 |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
691 |
def read_results(db: SQL.Database, names: Iterable[String] = Nil): State.Results = |
77552 | 692 |
db.execute_query_statement( |
693 |
Results.table.select(sql = if_proper(names, Results.name.where_member(names))), |
|
77651 | 694 |
Map.from[String, Result], |
77552 | 695 |
{ res => |
696 |
val name = res.string(Results.name) |
|
77651 | 697 |
val worker_uuid = res.string(Results.worker_uuid) |
698 |
val build_uuid = res.string(Results.build_uuid) |
|
77552 | 699 |
val hostname = res.string(Results.hostname) |
700 |
val numa_node = res.get_int(Results.numa_node) |
|
77651 | 701 |
val node_info = Host.Node_Info(hostname, numa_node) |
702 |
||
77552 | 703 |
val rc = res.int(Results.rc) |
704 |
val out = res.string(Results.out) |
|
705 |
val err = res.string(Results.err) |
|
706 |
val timing = |
|
707 |
res.timing( |
|
708 |
Results.timing_elapsed, |
|
709 |
Results.timing_cpu, |
|
710 |
Results.timing_gc) |
|
711 |
val process_result = |
|
712 |
Process_Result(rc, |
|
713 |
out_lines = split_lines(out), |
|
714 |
err_lines = split_lines(err), |
|
715 |
timing = timing) |
|
77651 | 716 |
|
717 |
val output_shasum = SHA1.fake_shasum(res.string(Results.output_shasum)) |
|
718 |
val current = res.bool(Results.current) |
|
719 |
||
720 |
name -> |
|
721 |
Result(name, worker_uuid, build_uuid, node_info, process_result, output_shasum, current) |
|
77496 | 722 |
} |
77552 | 723 |
) |
77372 | 724 |
|
77496 | 725 |
def update_results(db: SQL.Database, results: State.Results): Boolean = { |
726 |
val old_results = read_results_domain(db) |
|
77651 | 727 |
val insert = results.valuesIterator.filterNot(res => old_results.contains(res.name)).toList |
77372 | 728 |
|
77651 | 729 |
for (result <- insert) { |
77372 | 730 |
val process_result = result.process_result |
77541 | 731 |
db.execute_statement(Results.table.insert(), body = |
732 |
{ stmt => |
|
77651 | 733 |
stmt.string(1) = result.name |
734 |
stmt.string(2) = result.worker_uuid |
|
735 |
stmt.string(3) = result.build_uuid |
|
736 |
stmt.string(4) = result.node_info.hostname |
|
737 |
stmt.int(5) = result.node_info.numa_node |
|
738 |
stmt.int(6) = process_result.rc |
|
739 |
stmt.string(7) = cat_lines(process_result.out_lines) |
|
740 |
stmt.string(8) = cat_lines(process_result.err_lines) |
|
741 |
stmt.long(9) = process_result.timing.elapsed.ms |
|
742 |
stmt.long(10) = process_result.timing.cpu.ms |
|
743 |
stmt.long(11) = process_result.timing.gc.ms |
|
744 |
stmt.string(12) = result.output_shasum.toString |
|
745 |
stmt.bool(13) = result.current |
|
77541 | 746 |
}) |
77372 | 747 |
} |
748 |
||
749 |
insert.nonEmpty |
|
750 |
} |
|
751 |
||
77531 | 752 |
|
753 |
/* collective operations */ |
|
754 |
||
78187
2df0f3604a67
clarified signature: more explicit class SQL.Data;
wenzelm
parents:
78185
diff
changeset
|
755 |
override val tables = |
77596 | 756 |
SQL.Tables( |
77534 | 757 |
Base.table, |
758 |
Workers.table, |
|
759 |
Sessions.table, |
|
760 |
Pending.table, |
|
761 |
Running.table, |
|
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
762 |
Results.table) |
77534 | 763 |
|
77658 | 764 |
val build_uuid_tables = |
78187
2df0f3604a67
clarified signature: more explicit class SQL.Data;
wenzelm
parents:
78185
diff
changeset
|
765 |
tables.filter(table => |
77658 | 766 |
table.columns.exists(column => column.name == Generic.build_uuid.name)) |
767 |
||
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
768 |
def pull_database( |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
769 |
db: SQL.Database, |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
770 |
worker_uuid: String, |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
771 |
hostname: String, |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
772 |
state: State |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
773 |
): State = { |
77655 | 774 |
val serial_db = read_serial(db) |
775 |
if (serial_db == state.serial) state |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
776 |
else { |
77655 | 777 |
val serial = serial_db max state.serial |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
778 |
stamp_worker(db, worker_uuid, serial) |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
779 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
780 |
val sessions = state.sessions.pull(read_sessions_domain(db), read_sessions(db, _)) |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
781 |
val pending = read_pending(db) |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
782 |
val running = pull0(read_running(db), state.running) |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
783 |
val results = pull1(read_results_domain(db), read_results(db, _), state.results) |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
784 |
|
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
785 |
state.copy(serial = serial, sessions = sessions, pending = pending, |
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
786 |
running = running, results = results) |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
787 |
} |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
788 |
} |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
789 |
|
77416
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
790 |
def update_database( |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
791 |
db: SQL.Database, |
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
792 |
worker_uuid: String, |
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77527
diff
changeset
|
793 |
build_uuid: String, |
77416
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
794 |
hostname: String, |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
795 |
state: State |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
796 |
): State = { |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
797 |
val changed = |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
798 |
List( |
77496 | 799 |
update_sessions(db, state.sessions), |
77416
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
800 |
update_pending(db, state.pending), |
d88c12f22ab0
clarified scope of "serial" and "numa_index" within database;
wenzelm
parents:
77415
diff
changeset
|
801 |
update_running(db, state.running), |
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
802 |
update_results(db, state.results)) |
77372 | 803 |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
804 |
val serial0 = state.serial |
77513 | 805 |
val serial = if (changed.exists(identity)) State.inc_serial(serial0) else serial0 |
77372 | 806 |
|
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
807 |
stamp_worker(db, worker_uuid, serial) |
77657
a2a4adc268b8
removed redundant State.workers: directly maintained within the database, using with SQL update;
wenzelm
parents:
77656
diff
changeset
|
808 |
state.set_serial(serial) |
77372 | 809 |
} |
810 |
} |
|
78218
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
811 |
|
a625bfb0e549
clarified signature: more operations and options;
wenzelm
parents:
78217
diff
changeset
|
812 |
def read_builds(db: SQL.Database): List[Build] = |
78224 | 813 |
Data.transaction_lock(db, create = true) { Data.read_builds(db) } |
77396 | 814 |
} |
77372 | 815 |
|
816 |
||
77436 | 817 |
|
818 |
/** main process **/ |
|
77259
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
819 |
|
77505 | 820 |
class Build_Process( |
77530 | 821 |
protected final val build_context: Build_Process.Context, |
822 |
protected final val build_progress: Progress |
|
77505 | 823 |
) |
77436 | 824 |
extends AutoCloseable { |
825 |
/* context */ |
|
826 |
||
78178 | 827 |
protected final val store: Store = build_context.store |
77530 | 828 |
protected final val build_options: Options = store.options |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
829 |
protected final val build_deps: isabelle.Sessions.Deps = build_context.build_deps |
77653 | 830 |
protected final val hostname: String = build_context.hostname |
77530 | 831 |
protected final val build_uuid: String = build_context.build_uuid |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
832 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
833 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
834 |
/* progress backed by database */ |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
835 |
|
78214 | 836 |
private val _database_server: Option[SQL.Database] = |
837 |
try { store.maybe_open_database_server() } |
|
838 |
catch { case exn: Throwable => close(); throw exn } |
|
839 |
||
78203 | 840 |
private val _build_database: Option[SQL.Database] = |
78234 | 841 |
try { |
842 |
for (db <- store.maybe_open_build_database()) yield { |
|
843 |
val shared_db = db.is_postgresql |
|
844 |
Build_Process.Data.transaction_lock(db, create = true) { |
|
845 |
Build_Process.Data.clean_build(db) |
|
846 |
if (shared_db) Store.Data.tables.lock(db, create = true) |
|
847 |
} |
|
848 |
Build_Process.Data.vacuum(db, |
|
849 |
more_tables = if (shared_db) Store.Data.tables else SQL.Tables.empty) |
|
850 |
db |
|
851 |
} |
|
852 |
} |
|
78214 | 853 |
catch { case exn: Throwable => close(); throw exn } |
77259
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
854 |
|
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
855 |
private val _host_database: Option[SQL.Database] = |
78223 | 856 |
try { store.maybe_open_build_database(path = Host.Data.database) } |
78214 | 857 |
catch { case exn: Throwable => close(); throw exn } |
78213
fd0430a7b7a4
avoid repeated open_database_server: synchronized transaction_lock;
wenzelm
parents:
78205
diff
changeset
|
858 |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
859 |
protected val (progress, worker_uuid) = synchronized { |
78203 | 860 |
_build_database match { |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
861 |
case None => (build_progress, UUID.random().toString) |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
862 |
case Some(db) => |
78214 | 863 |
try { |
864 |
val progress_db = store.open_build_database(Progress.Data.database) |
|
865 |
val progress = |
|
866 |
new Database_Progress(progress_db, build_progress, |
|
867 |
hostname = hostname, |
|
78240 | 868 |
context_uuid = build_uuid, |
869 |
kind = "build_process") |
|
78214 | 870 |
(progress, progress.agent_uuid) |
871 |
} |
|
872 |
catch { case exn: Throwable => close(); throw exn } |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
873 |
} |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
874 |
} |
77638 | 875 |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
876 |
protected val log: Logger = Logger.make_system_log(progress, build_options) |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
877 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
878 |
def close(): Unit = synchronized { |
78214 | 879 |
Option(_database_server).flatten.foreach(_.close()) |
880 |
Option(_build_database).flatten.foreach(_.close()) |
|
881 |
Option(_host_database).flatten.foreach(_.close()) |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
882 |
progress match { |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
883 |
case db_progress: Database_Progress => |
78242 | 884 |
db_progress.exit(close = true) |
78159 | 885 |
case _ => |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
886 |
} |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
887 |
} |
77436 | 888 |
|
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
889 |
/* global state: internal var vs. external database */ |
77436 | 890 |
|
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
891 |
private var _state: Build_Process.State = Build_Process.State() |
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
892 |
|
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
893 |
protected def synchronized_database[A](body: => A): A = synchronized { |
78203 | 894 |
_build_database match { |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
895 |
case None => body |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
896 |
case Some(db) => |
78187
2df0f3604a67
clarified signature: more explicit class SQL.Data;
wenzelm
parents:
78185
diff
changeset
|
897 |
Build_Process.Data.transaction_lock(db) { |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
898 |
progress.asInstanceOf[Database_Progress].sync() |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
899 |
_state = Build_Process.Data.pull_database(db, worker_uuid, hostname, _state) |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
900 |
val res = body |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
901 |
_state = |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
902 |
Build_Process.Data.update_database(db, worker_uuid, build_uuid, hostname, _state) |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
903 |
res |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
904 |
} |
77522
a1d30297cd61
more complete coverage of non-final Progress methods, notably for Server.Connection_Progress;
wenzelm
parents:
77521
diff
changeset
|
905 |
} |
a1d30297cd61
more complete coverage of non-final Progress methods, notably for Server.Connection_Progress;
wenzelm
parents:
77521
diff
changeset
|
906 |
} |
a1d30297cd61
more complete coverage of non-final Progress methods, notably for Server.Connection_Progress;
wenzelm
parents:
77521
diff
changeset
|
907 |
|
77505 | 908 |
|
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
909 |
/* policy operations */ |
77333 | 910 |
|
77415
6b928419f109
clarified signature: allow more general init, e.g. from existing database;
wenzelm
parents:
77414
diff
changeset
|
911 |
protected def init_state(state: Build_Process.State): Build_Process.State = { |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
912 |
val sessions1 = state.sessions.init(build_context, progress = build_progress) |
77496 | 913 |
|
77415
6b928419f109
clarified signature: allow more general init, e.g. from existing database;
wenzelm
parents:
77414
diff
changeset
|
914 |
val old_pending = state.pending.iterator.map(_.name).toSet |
6b928419f109
clarified signature: allow more general init, e.g. from existing database;
wenzelm
parents:
77414
diff
changeset
|
915 |
val new_pending = |
6b928419f109
clarified signature: allow more general init, e.g. from existing database;
wenzelm
parents:
77414
diff
changeset
|
916 |
List.from( |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
917 |
for (session <- sessions1.iterator if !old_pending(session.name)) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
918 |
yield Build_Process.Task(session.name, session.deps, JSON.Object.empty, build_uuid)) |
77496 | 919 |
val pending1 = new_pending ::: state.pending |
920 |
||
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
921 |
state.copy( |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
922 |
numa_nodes = Host.numa_nodes(enabled = build_context.numa_shuffling), |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
923 |
sessions = sessions1, |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
924 |
pending = pending1) |
77415
6b928419f109
clarified signature: allow more general init, e.g. from existing database;
wenzelm
parents:
77414
diff
changeset
|
925 |
} |
77259
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
926 |
|
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
927 |
protected def next_job(state: Build_Process.State): Option[String] = |
77578
149d48a4801b
support for "isabelle build -j0": require external workers to make progress;
wenzelm
parents:
77561
diff
changeset
|
928 |
if (progress.stopped || state.running.size < build_context.max_jobs) { |
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
929 |
state.pending.filter(entry => entry.is_ready && !state.is_running(entry.name)) |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
930 |
.sortBy(_.name)(state.sessions.ordering) |
77313
f8aa1647d156
more elementary data structures, to fit better to SQL database;
wenzelm
parents:
77312
diff
changeset
|
931 |
.headOption.map(_.name) |
77296
eeaa2872320b
clarified signature: more explicit synchronized operations;
wenzelm
parents:
77295
diff
changeset
|
932 |
} |
eeaa2872320b
clarified signature: more explicit synchronized operations;
wenzelm
parents:
77295
diff
changeset
|
933 |
else None |
77259
61fc2afe4c8b
clarified signature: prefer stateful object-oriented style, to make it fit better into physical world;
wenzelm
parents:
77258
diff
changeset
|
934 |
|
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
935 |
protected def start_session(state: Build_Process.State, session_name: String): Build_Process.State = { |
77468 | 936 |
val ancestor_results = |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
937 |
for (a <- state.sessions(session_name).ancestors) yield state.results(a) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
938 |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
939 |
val sources_shasum = state.sessions(session_name).sources_shasum |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
940 |
|
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77459
diff
changeset
|
941 |
val input_shasum = |
77650 | 942 |
if (ancestor_results.isEmpty) ML_Process.bootstrap_shasum() |
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77459
diff
changeset
|
943 |
else SHA1.flat_shasum(ancestor_results.map(_.output_shasum)) |
77257 | 944 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
945 |
val store_heap = |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
946 |
build_context.build_heap || Sessions.is_pure(session_name) || |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
947 |
state.sessions.iterator.exists(_.ancestors.contains(session_name)) |
77469 | 948 |
|
949 |
val (current, output_shasum) = |
|
950 |
store.check_output(session_name, |
|
77675
9e5f8f6e58a0
more thorough treatment of build prefs, guarded by system option "build_through": avoid accidental rebuild of HOL etc.;
wenzelm
parents:
77664
diff
changeset
|
951 |
session_options = build_context.sessions_structure(session_name).options, |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
952 |
sources_shasum = sources_shasum, |
77469 | 953 |
input_shasum = input_shasum, |
954 |
fresh_build = build_context.fresh_build, |
|
955 |
store_heap = store_heap) |
|
956 |
||
78195 | 957 |
val finished = current && ancestor_results.forall(_.current) |
958 |
val skipped = build_context.no_build |
|
959 |
val cancelled = progress.stopped || !ancestor_results.forall(_.ok) |
|
77257 | 960 |
|
78196
140a6f2e3728
restore heaps from database, which takes precedence over file-system;
wenzelm
parents:
78195
diff
changeset
|
961 |
if (!skipped && !cancelled) { |
78213
fd0430a7b7a4
avoid repeated open_database_server: synchronized transaction_lock;
wenzelm
parents:
78205
diff
changeset
|
962 |
ML_Heap.restore(_database_server, session_name, store.output_heap(session_name), |
fd0430a7b7a4
avoid repeated open_database_server: synchronized transaction_lock;
wenzelm
parents:
78205
diff
changeset
|
963 |
cache = store.cache.compress) |
78196
140a6f2e3728
restore heaps from database, which takes precedence over file-system;
wenzelm
parents:
78195
diff
changeset
|
964 |
} |
140a6f2e3728
restore heaps from database, which takes precedence over file-system;
wenzelm
parents:
78195
diff
changeset
|
965 |
|
77651 | 966 |
val result_name = (session_name, worker_uuid, build_uuid) |
967 |
||
78195 | 968 |
if (finished) { |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
969 |
state |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
970 |
.remove_pending(session_name) |
77651 | 971 |
.make_result(result_name, Process_Result.ok, output_shasum, current = true) |
77260 | 972 |
} |
78195 | 973 |
else if (skipped) { |
77521
5642de4d225d
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77514
diff
changeset
|
974 |
progress.echo("Skipping " + session_name + " ...", verbose = true) |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
975 |
state. |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
976 |
remove_pending(session_name). |
77651 | 977 |
make_result(result_name, Process_Result.error, output_shasum) |
77260 | 978 |
} |
78195 | 979 |
else if (cancelled) { |
77452 | 980 |
progress.echo(session_name + " CANCELLED") |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
981 |
state |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
982 |
.remove_pending(session_name) |
77651 | 983 |
.make_result(result_name, Process_Result.undefined, output_shasum) |
77452 | 984 |
} |
985 |
else { |
|
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
986 |
def used_nodes: Set[Int] = |
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
987 |
Set.from(for (job <- state.running.valuesIterator; i <- job.node_info.numa_node) yield i) |
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
988 |
val numa_node = |
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
989 |
for { |
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
990 |
db <- _host_database |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
991 |
n <- Host.next_numa_node(db, hostname, state.numa_nodes, used_nodes) |
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
992 |
} yield n |
77653 | 993 |
val node_info = Host.Node_Info(hostname, numa_node) |
77551 | 994 |
|
995 |
progress.echo( |
|
996 |
(if (store_heap) "Building " else "Running ") + session_name + |
|
997 |
if_proper(node_info.numa_node, " on " + node_info) + " ...") |
|
77260 | 998 |
|
78217 | 999 |
store.clean_output(_database_server, session_name, session_init = true) |
77257 | 1000 |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
1001 |
val session = state.sessions(session_name) |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
1002 |
|
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
1003 |
val build = |
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
1004 |
Build_Job.start_session(build_context, session, progress, log, _database_server, |
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78234
diff
changeset
|
1005 |
build_deps.background(session_name), sources_shasum, input_shasum, node_info, store_heap) |
77630
86ef80d13544
clarified signature: avoid confusion due to object-orientation;
wenzelm
parents:
77629
diff
changeset
|
1006 |
|
77634 | 1007 |
val job = Build_Process.Job(session_name, worker_uuid, build_uuid, node_info, Some(build)) |
1008 |
||
78174
cc0bd66eb498
separate host.db for independent db.transaction_lock;
wenzelm
parents:
78173
diff
changeset
|
1009 |
state.add_running(job) |
77260 | 1010 |
} |
1011 |
} |
|
77257 | 1012 |
|
77436 | 1013 |
|
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1014 |
/* build process roles */ |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1015 |
|
77654 | 1016 |
final def is_session_name(job_name: String): Boolean = |
1017 |
!Long_Name.is_qualified(job_name) |
|
77648 | 1018 |
|
77654 | 1019 |
protected final def start_build(): Unit = synchronized_database { |
78203 | 1020 |
for (db <- _build_database) { |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1021 |
Build_Process.Data.start_build(db, build_uuid, build_context.ml_platform, |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1022 |
build_context.sessions_structure.session_prefs) |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1023 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1024 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1025 |
|
77654 | 1026 |
protected final def stop_build(): Unit = synchronized_database { |
78203 | 1027 |
for (db <- _build_database) { |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1028 |
Build_Process.Data.stop_build(db, build_uuid) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1029 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1030 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1031 |
|
77654 | 1032 |
protected final def start_worker(): Unit = synchronized_database { |
78203 | 1033 |
for (db <- _build_database) { |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
1034 |
_state = _state.inc_serial |
78172
43ed2541b758
omit redundant data: already stored in progress database;
wenzelm
parents:
78170
diff
changeset
|
1035 |
Build_Process.Data.start_worker(db, worker_uuid, build_uuid, _state.serial) |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1036 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1037 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1038 |
|
77654 | 1039 |
protected final def stop_worker(): Unit = synchronized_database { |
78203 | 1040 |
for (db <- _build_database) { |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1041 |
Build_Process.Data.stamp_worker(db, worker_uuid, _state.serial, stop = true) |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1042 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1043 |
} |
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1044 |
|
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1045 |
|
77436 | 1046 |
/* run */ |
77372 | 1047 |
|
77579
69d3547206db
clarified signature: prefer Build_Process.Context for parameters;
wenzelm
parents:
77578
diff
changeset
|
1048 |
def run(): Map[String, Process_Result] = { |
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
1049 |
if (build_context.master) synchronized_database { _state = init_state(_state) } |
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
1050 |
|
77466
94dcf2c3895a
more thorough synchronized_database for internal *and* external state;
wenzelm
parents:
77465
diff
changeset
|
1051 |
def finished(): Boolean = synchronized_database { _state.finished } |
77400
f3e5b3fe230e
clarified signature: more explicit "synchronized" regions;
wenzelm
parents:
77398
diff
changeset
|
1052 |
|
77437
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
1053 |
def sleep(): Unit = |
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
1054 |
Isabelle_Thread.interrupt_handler(_ => progress.stop()) { |
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
1055 |
build_options.seconds("editor_input_delay").sleep() |
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
1056 |
} |
dcbf96acae27
clarified signature: do not expose global state to object-oriented variants;
wenzelm
parents:
77436
diff
changeset
|
1057 |
|
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1058 |
def start_job(): Boolean = synchronized_database { |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1059 |
next_job(_state) match { |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1060 |
case Some(name) => |
77648 | 1061 |
if (is_session_name(name)) { |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1062 |
_state = start_session(_state, name) |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1063 |
true |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1064 |
} |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1065 |
else error("Unsupported build job name " + quote(name)) |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1066 |
case None => false |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1067 |
} |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1068 |
} |
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1069 |
|
77335 | 1070 |
if (finished()) { |
1071 |
progress.echo_warning("Nothing to build") |
|
1072 |
Map.empty[String, Process_Result] |
|
1073 |
} |
|
1074 |
else { |
|
77579
69d3547206db
clarified signature: prefer Build_Process.Context for parameters;
wenzelm
parents:
77578
diff
changeset
|
1075 |
if (build_context.master) start_build() |
78241 | 1076 |
start_worker() |
77578
149d48a4801b
support for "isabelle build -j0": require external workers to make progress;
wenzelm
parents:
77561
diff
changeset
|
1077 |
|
77580
32f9e75c92e9
clarified worker state: always maintain database content via worker_uuid;
wenzelm
parents:
77579
diff
changeset
|
1078 |
if (build_context.master && !build_context.worker_active) { |
32f9e75c92e9
clarified worker state: always maintain database content via worker_uuid;
wenzelm
parents:
77579
diff
changeset
|
1079 |
progress.echo("Waiting for external workers ...") |
32f9e75c92e9
clarified worker state: always maintain database content via worker_uuid;
wenzelm
parents:
77579
diff
changeset
|
1080 |
} |
77578
149d48a4801b
support for "isabelle build -j0": require external workers to make progress;
wenzelm
parents:
77561
diff
changeset
|
1081 |
|
77538 | 1082 |
try { |
1083 |
while (!finished()) { |
|
77639 | 1084 |
synchronized_database { |
1085 |
if (progress.stopped) _state.stop_running() |
|
77310 | 1086 |
|
77649 | 1087 |
for (job <- _state.finished_running()) { |
77651 | 1088 |
val result_name = (job.name, worker_uuid, build_uuid) |
77649 | 1089 |
val (process_result, output_shasum) = job.build.get.join |
77538 | 1090 |
_state = _state. |
77649 | 1091 |
remove_pending(job.name). |
1092 |
remove_running(job.name). |
|
77651 | 1093 |
make_result(result_name, process_result, output_shasum, node_info = job.node_info) |
77538 | 1094 |
} |
1095 |
} |
|
1096 |
||
77652
5f706f7c624b
more thorough synchronization of internal "_state" vs. external "_database";
wenzelm
parents:
77651
diff
changeset
|
1097 |
if (!start_job()) sleep() |
77396 | 1098 |
} |
77310 | 1099 |
} |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1100 |
finally { |
77580
32f9e75c92e9
clarified worker state: always maintain database content via worker_uuid;
wenzelm
parents:
77579
diff
changeset
|
1101 |
stop_worker() |
77579
69d3547206db
clarified signature: prefer Build_Process.Context for parameters;
wenzelm
parents:
77578
diff
changeset
|
1102 |
if (build_context.master) stop_build() |
77546
9b9179cda155
clarified build process roles: "worker" vs. "build";
wenzelm
parents:
77545
diff
changeset
|
1103 |
} |
77467
e27bc7957297
more robust: proper synchronization of transition from next_job to start_session;
wenzelm
parents:
77466
diff
changeset
|
1104 |
|
77466
94dcf2c3895a
more thorough synchronized_database for internal *and* external state;
wenzelm
parents:
77465
diff
changeset
|
1105 |
synchronized_database { |
77334
0231e62956a6
clarified state: more explicit type as plain value, which is also easier to sync with external db;
wenzelm
parents:
77333
diff
changeset
|
1106 |
for ((name, result) <- _state.results) yield name -> result.process_result |
77257 | 1107 |
} |
1108 |
} |
|
1109 |
} |
|
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1110 |
|
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1111 |
|
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1112 |
/* snapshot */ |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1113 |
|
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1114 |
def snapshot(): Build_Process.Snapshot = synchronized_database { |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1115 |
val (builds, workers) = |
78203 | 1116 |
_build_database match { |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1117 |
case None => (Nil, Nil) |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1118 |
case Some(db) => |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1119 |
(Build_Process.Data.read_builds(db), |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1120 |
Build_Process.Data.read_workers(db)) |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1121 |
} |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1122 |
Build_Process.Snapshot( |
77660 | 1123 |
builds = builds, |
77659
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1124 |
workers = workers, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1125 |
sessions = _state.sessions, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1126 |
pending = _state.pending, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1127 |
running = _state.running, |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1128 |
results = _state.results) |
d7eb6a4522b8
more explicit snapshot of "_state" and "_database";
wenzelm
parents:
77658
diff
changeset
|
1129 |
} |
78156
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1130 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1131 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1132 |
/* toString */ |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1133 |
|
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1134 |
override def toString: String = |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1135 |
"Build_Process(worker_uuid = " + quote(worker_uuid) + ", build_uuid = " + quote(build_uuid) + |
da5cc332ded3
prefer Database_Progress, which is more robust (amending afb1a19307c4);
wenzelm
parents:
78154
diff
changeset
|
1136 |
if_proper(build_context.master, ", master = true") + ")" |
77238 | 1137 |
} |