src/Pure/Build/build_process.scala
changeset 79892 c793de82db34
parent 79887 17220dc05991
child 79904 1cfc913987d9
equal deleted inserted replaced
79891:d8b4bfe82bb5 79892:c793de82db34
    70   sealed case class Result(
    70   sealed case class Result(
    71     name: String,
    71     name: String,
    72     worker_uuid: String,
    72     worker_uuid: String,
    73     build_uuid: String,
    73     build_uuid: String,
    74     node_info: Host.Node_Info,
    74     node_info: Host.Node_Info,
       
    75     start_date: Date,
    75     process_result: Process_Result,
    76     process_result: Process_Result,
    76     output_shasum: SHA1.Shasum,
    77     output_shasum: SHA1.Shasum,
    77     current: Boolean
    78     current: Boolean
    78   ) extends Library.Named {
    79   ) extends Library.Named {
    79     def ok: Boolean = process_result.ok
    80     def ok: Boolean = process_result.ok
   265 
   266 
   266     def make_result(
   267     def make_result(
   267       result_name: (String, String, String),
   268       result_name: (String, String, String),
   268       process_result: Process_Result,
   269       process_result: Process_Result,
   269       output_shasum: SHA1.Shasum,
   270       output_shasum: SHA1.Shasum,
       
   271       start_date: Date,
   270       node_info: Host.Node_Info = Host.Node_Info.none,
   272       node_info: Host.Node_Info = Host.Node_Info.none,
   271       current: Boolean = false
   273       current: Boolean = false
   272     ): State = {
   274     ): State = {
   273       val (name, worker_uuid, build_uuid) = result_name
   275       val (name, worker_uuid, build_uuid) = result_name
   274       val result =
   276       val result =
   275         Result(name, worker_uuid, build_uuid, node_info, process_result, output_shasum, current)
   277         Result(name, worker_uuid, build_uuid, node_info, start_date, process_result, output_shasum,
       
   278           current)
   276       copy(results = results + (name -> result))
   279       copy(results = results + (name -> result))
   277     }
   280     }
   278 
   281 
   279     def ancestor_results(name: String): Option[List[Result]] = {
   282     def ancestor_results(name: String): Option[List[Result]] = {
   280       val defined =
   283       val defined =
   810       val worker_uuid = Generic.worker_uuid
   813       val worker_uuid = Generic.worker_uuid
   811       val build_uuid = Generic.build_uuid
   814       val build_uuid = Generic.build_uuid
   812       val hostname = SQL.Column.string("hostname")
   815       val hostname = SQL.Column.string("hostname")
   813       val numa_node = SQL.Column.int("numa_node")
   816       val numa_node = SQL.Column.int("numa_node")
   814       val rel_cpus = SQL.Column.string("rel_cpus")
   817       val rel_cpus = SQL.Column.string("rel_cpus")
       
   818       val start_date = SQL.Column.date("start_date")
   815       val rc = SQL.Column.int("rc")
   819       val rc = SQL.Column.int("rc")
   816       val out = SQL.Column.string("out")
   820       val out = SQL.Column.string("out")
   817       val err = SQL.Column.string("err")
   821       val err = SQL.Column.string("err")
   818       val timing_elapsed = SQL.Column.long("timing_elapsed")
   822       val timing_elapsed = SQL.Column.long("timing_elapsed")
   819       val timing_cpu = SQL.Column.long("timing_cpu")
   823       val timing_cpu = SQL.Column.long("timing_cpu")
   821       val output_shasum = SQL.Column.string("output_shasum")
   825       val output_shasum = SQL.Column.string("output_shasum")
   822       val current = SQL.Column.bool("current")
   826       val current = SQL.Column.bool("current")
   823 
   827 
   824       val table =
   828       val table =
   825         make_table(
   829         make_table(
   826           List(name, worker_uuid, build_uuid, hostname, numa_node, rel_cpus,
   830           List(name, worker_uuid, build_uuid, hostname, numa_node, rel_cpus, start_date,
   827             rc, out, err, timing_elapsed, timing_cpu, timing_gc, output_shasum, current),
   831             rc, out, err, timing_elapsed, timing_cpu, timing_gc, output_shasum, current),
   828           name = "results")
   832           name = "results")
   829 
   833 
   830       lazy val table_index: Int = tables.index(table)
   834       lazy val table_index: Int = tables.index(table)
   831     }
   835     }
   839             val build_uuid = res.string(Results.build_uuid)
   843             val build_uuid = res.string(Results.build_uuid)
   840             val hostname = res.string(Results.hostname)
   844             val hostname = res.string(Results.hostname)
   841             val numa_node = res.get_int(Results.numa_node)
   845             val numa_node = res.get_int(Results.numa_node)
   842             val rel_cpus = res.string(Results.rel_cpus)
   846             val rel_cpus = res.string(Results.rel_cpus)
   843             val node_info = Host.Node_Info(hostname, numa_node, Host.Range.from(rel_cpus))
   847             val node_info = Host.Node_Info(hostname, numa_node, Host.Range.from(rel_cpus))
       
   848 
       
   849             val start_date = res.date(Results.start_date)
   844 
   850 
   845             val rc = res.int(Results.rc)
   851             val rc = res.int(Results.rc)
   846             val out = res.string(Results.out)
   852             val out = res.string(Results.out)
   847             val err = res.string(Results.err)
   853             val err = res.string(Results.err)
   848             val timing =
   854             val timing =
   857                 timing = timing)
   863                 timing = timing)
   858 
   864 
   859             val output_shasum = SHA1.fake_shasum(res.string(Results.output_shasum))
   865             val output_shasum = SHA1.fake_shasum(res.string(Results.output_shasum))
   860             val current = res.bool(Results.current)
   866             val current = res.bool(Results.current)
   861 
   867 
   862             Result(name, worker_uuid, build_uuid, node_info, process_result, output_shasum, current)
   868             Result(name, worker_uuid, build_uuid, node_info, start_date, process_result,
       
   869               output_shasum, current)
   863           })
   870           })
   864       )
   871       )
   865 
   872 
   866     def update_results(
   873     def update_results(
   867       db: SQL.Database,
   874       db: SQL.Database,
   884             stmt.string(2) = result.worker_uuid
   891             stmt.string(2) = result.worker_uuid
   885             stmt.string(3) = result.build_uuid
   892             stmt.string(3) = result.build_uuid
   886             stmt.string(4) = result.node_info.hostname
   893             stmt.string(4) = result.node_info.hostname
   887             stmt.int(5) = result.node_info.numa_node
   894             stmt.int(5) = result.node_info.numa_node
   888             stmt.string(6) = Host.Range(result.node_info.rel_cpus)
   895             stmt.string(6) = Host.Range(result.node_info.rel_cpus)
   889             stmt.int(7) = process_result.rc
   896             stmt.date(7) = result.start_date
   890             stmt.string(8) = cat_lines(process_result.out_lines)
   897             stmt.int(8) = process_result.rc
   891             stmt.string(9) = cat_lines(process_result.err_lines)
   898             stmt.string(9) = cat_lines(process_result.out_lines)
   892             stmt.long(10) = process_result.timing.elapsed.ms
   899             stmt.string(10) = cat_lines(process_result.err_lines)
   893             stmt.long(11) = process_result.timing.cpu.ms
   900             stmt.long(11) = process_result.timing.elapsed.ms
   894             stmt.long(12) = process_result.timing.gc.ms
   901             stmt.long(12) = process_result.timing.cpu.ms
   895             stmt.string(13) = result.output_shasum.toString
   902             stmt.long(13) = process_result.timing.gc.ms
   896             stmt.bool(14) = result.current
   903             stmt.string(14) = result.output_shasum.toString
       
   904             stmt.bool(15) = result.current
   897           })
   905           })
   898       }
   906       }
   899 
   907 
   900       update
   908       update
   901     }
   909     }
  1182       }
  1190       }
  1183     }
  1191     }
  1184 
  1192 
  1185     val result_name = (session_name, worker_uuid, build_uuid)
  1193     val result_name = (session_name, worker_uuid, build_uuid)
  1186 
  1194 
       
  1195     val start = progress.now()
       
  1196 
  1187     if (finished) {
  1197     if (finished) {
  1188       state
  1198       state
  1189         .remove_pending(session_name)
  1199         .remove_pending(session_name)
  1190         .make_result(result_name, Process_Result.ok, output_shasum, current = true)
  1200         .make_result(result_name, Process_Result.ok, output_shasum, start, current = true)
  1191     }
  1201     }
  1192     else if (skipped) {
  1202     else if (skipped) {
  1193       progress.echo("Skipping " + session_name + " ...", verbose = true)
  1203       progress.echo("Skipping " + session_name + " ...", verbose = true)
  1194       state.
  1204       state.
  1195         remove_pending(session_name).
  1205         remove_pending(session_name).
  1196         make_result(result_name, Process_Result.error, output_shasum)
  1206         make_result(result_name, Process_Result.error, output_shasum, start)
  1197     }
  1207     }
  1198     else if (cancelled) {
  1208     else if (cancelled) {
  1199       progress.echo(session_name + " CANCELLED")
  1209       progress.echo(session_name + " CANCELLED")
  1200       state
  1210       state
  1201         .remove_pending(session_name)
  1211         .remove_pending(session_name)
  1202         .make_result(result_name, Process_Result.undefined, output_shasum)
  1212         .make_result(result_name, Process_Result.undefined, output_shasum, start)
  1203     }
  1213     }
  1204     else {
  1214     else {
  1205       val build_log_verbose = build_options.bool("build_log_verbose")
  1215       val build_log_verbose = build_options.bool("build_log_verbose")
  1206 
  1216 
  1207       val start = progress.now()
       
  1208       val start_time = start - build_start
  1217       val start_time = start - build_start
  1209       val start_time_msg = build_log_verbose
  1218       val start_time_msg = build_log_verbose
  1210 
  1219 
  1211       val node_info = next_node_info(state, session_name)
  1220       val node_info = next_node_info(state, session_name)
  1212       val node_info_msg = node_info.numa || build_log_verbose
  1221       val node_info_msg = node_info.numa || build_log_verbose
  1318         remove_pending(job.name).
  1327         remove_pending(job.name).
  1319         remove_running(job.name).
  1328         remove_running(job.name).
  1320         make_result(result_name,
  1329         make_result(result_name,
  1321           result.process_result,
  1330           result.process_result,
  1322           result.output_shasum,
  1331           result.output_shasum,
       
  1332           job.start_date,
  1323           node_info = job.node_info)
  1333           node_info = job.node_info)
  1324     }
  1334     }
  1325 
  1335 
  1326     for (name <- next_jobs(_state)) {
  1336     for (name <- next_jobs(_state)) {
  1327       if (is_session_name(name)) {
  1337       if (is_session_name(name)) {