module Syskit::Runtime

Namespace containing all the system management at runtime (propagation of states, triggering of connection updates, …)

Public Class Methods

abort_process_server(plan, process_server) click to toggle source
# File lib/syskit/runtime/update_deployment_states.rb, line 34
def self.abort_process_server(plan, process_server)
    client = process_server.client
    # Before we can terminate Syskit, we need to abort all
    # deployments that were managed by this client
    deployments = plan.find_tasks(Syskit::Deployment).
        find_all { |t| t.arguments[:on] == process_server.name }
    deployments.each { |t| t.aborted_event.emit if !t.pending? && !t.finished? }
    Syskit.conf.remove_process_server(process_server.name)
end
apply_requirement_modifications(plan, force: false) click to toggle source
# File lib/syskit/runtime/apply_requirement_modifications.rb, line 90
def self.apply_requirement_modifications(plan, force: false)
    if plan.syskit_has_async_resolution?
        # We're already running a resolution, make sure it is not
        # obsolete
        if force || !plan.syskit_valid_async_resolution?
            plan.syskit_cancel_async_resolution
        elsif plan.syskit_finished_async_resolution?
            running_requirement_tasks = plan.find_tasks(Syskit::InstanceRequirementsTask).running
            begin
                plan.syskit_apply_async_resolution_results
            rescue ::Exception => e
                running_requirement_tasks.each do |t|
                    t.failed_event.emit(e)
                end
                return
            end
            running_requirement_tasks.each do |t|
                t.success_event.emit
            end
            return
        end
    end

    if !plan.syskit_has_async_resolution?
        if force || plan.find_tasks(Syskit::InstanceRequirementsTask).running.any? { true }
            requirement_tasks = NetworkGeneration::Engine.discover_requirement_tasks_from_plan(plan)
            if !requirement_tasks.empty?
                # We're not resolving anything, but new IR tasks have been
                # started. Deploy them
                plan.syskit_start_async_resolution(requirement_tasks)
            end
        end
    end
end
update_deployment_states(plan) click to toggle source

This method is called once at the beginning of each execution cycle to update the state of Deployment tasks w.r.t. the state of the underlying process

# File lib/syskit/runtime/update_deployment_states.rb, line 6
def self.update_deployment_states(plan)
    # We first announce all the dead processes and only then call
    # #cleanup_dead_connections, thus avoiding to disconnect connections
    # between already-dead processes

    all_dead_deployments = Set.new
    server_config = Syskit.conf.each_process_server_config.to_a
    server_config.each do |config|
        begin
            dead_deployments = config.client.wait_termination(0)
        rescue ::Exception => e
            deployments = abort_process_server(plan, config)
            all_dead_deployments.merge(deployments)
            plan.execution_engine.add_framework_error(e, "update_deployment_states")
            next
        end

        dead_deployments.each do |p, exit_status|
            d = Deployment.deployment_by_process(p)
            if !d.finishing?
                d.warn "#{p.name} unexpectedly died on process server #{config.name}"
            end
            all_dead_deployments << d
            d.dead!(exit_status)
        end
    end
end