467 task <- state.next_ready |
467 task <- state.next_ready |
468 node = graph.get_node(task.name) |
468 node = graph.get_node(task.name) |
469 if hostname == node.node_info.hostname |
469 if hostname == node.node_info.hostname |
470 if graph.imm_preds(node.job_name).subsetOf(state.results.keySet) |
470 if graph.imm_preds(node.job_name).subsetOf(state.results.keySet) |
471 } yield task.name |
471 } yield task.name |
|
472 |
|
473 def update(state: Build_Process.State): Schedule = { |
|
474 val start1 = Date.now() |
|
475 val pending = state.pending.map(_.name).toSet |
|
476 |
|
477 def shift_elapsed(graph: Schedule.Graph, name: String): Schedule.Graph = |
|
478 graph.map_node(name, { node => |
|
479 val elapsed = start1.time - state.running(name).start_date.time |
|
480 node.copy(duration = node.duration - elapsed) |
|
481 }) |
|
482 |
|
483 def shift_starts(graph: Schedule.Graph, name: String): Schedule.Graph = |
|
484 graph.map_node(name, { node => |
|
485 val starts = start1 :: graph.imm_preds(node.job_name).toList.map(graph.get_node(_).end) |
|
486 node.copy(start = starts.max(Date.Ordering)) |
|
487 }) |
|
488 |
|
489 val graph0 = state.running.keys.foldLeft(graph.restrict(pending.contains))(shift_elapsed) |
|
490 val graph1 = graph0.topological_order.foldLeft(graph0)(shift_starts) |
|
491 |
|
492 copy(start = start1, graph = graph1) |
|
493 } |
472 } |
494 } |
473 |
495 |
474 case class State(build_state: Build_Process.State, current_time: Time, finished: Schedule) { |
496 case class State(build_state: Build_Process.State, current_time: Time, finished: Schedule) { |
475 def start(config: Config): State = |
497 def start(config: Config): State = |
476 copy(build_state = |
498 copy(build_state = |
955 else { |
977 else { |
956 val current = state.next_ready.filter(task => is_current(state, task.name)) |
978 val current = state.next_ready.filter(task => is_current(state, task.name)) |
957 if (current.nonEmpty) current.map(_.name) |
979 if (current.nonEmpty) current.map(_.name) |
958 else { |
980 else { |
959 val start = Time.now() |
981 val start = Time.now() |
960 val schedule = scheduler.build_schedule(state) |
982 |
|
983 val new_schedule = scheduler.build_schedule(state) |
|
984 val schedule = |
|
985 if (_schedule.graph.is_empty) new_schedule |
|
986 else List(_schedule.update(state), new_schedule).minBy(_.end)(Date.Ordering) |
|
987 |
961 val elapsed = Time.now() - start |
988 val elapsed = Time.now() - start |
962 |
989 |
963 val timing_msg = if (elapsed.is_relevant) " (took " + elapsed.message + ")" else "" |
990 val timing_msg = if (elapsed.is_relevant) " (took " + elapsed.message + ")" else "" |
964 progress.echo_if(_schedule.deviation(schedule).minutes > 1, schedule.message + timing_msg) |
991 progress.echo_if(_schedule.deviation(schedule).minutes > 1, schedule.message + timing_msg) |
965 |
992 |