Module: Aspera::Plugins::Xfer::TransferActions
- Defined in:
- lib/aspera/plugins/xfer/transfer_actions.rb
Overview
Mounted on plugin config (manifest mounts): async transfer management actions.
Exposes three sub-commands under config agents jobs (config transfer is a deprecated alias):
status <job_id> Re-query a running/completed transfer
list List all persisted async transfer entries (jobs not ended are re-queried)
cleanup Remove completed/failed/cancelled entries
Architecture:
- remote-daemon agents (desktop, node, connect, transferd): transfer_id + agent_params
are persisted in AsyncTransferStore (without secrets, taken from current options);
status is re-queried via Agent::Xxx.transfer_status
- direct agent: transfers live in Ruby threads - store is the agent's @sessions;
status is not persistable across process restarts (returns an informational message)
A status unknown (agent not reachable, missing secret, agent of another process...) does not replace the saved status.
Instance Method Summary collapse
-
#action_agents_jobs_cleanup ⇒ Object
Delete completed, failed, and cancelled entries from the store.
-
#action_agents_jobs_list ⇒ Object
List async transfer jobs: the jobs not ended are re-queried as with
status, else their saved state is shown, with a warning. -
#action_agents_jobs_status(job_id:) ⇒ Object
Re-query the status of a single async transfer job.
Instance Method Details
#action_agents_jobs_cleanup ⇒ Object
Delete completed, failed, and cancelled entries from the store.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/aspera/plugins/xfer/transfer_actions.rb', line 68 def action_agents_jobs_cleanup(**) store = async_transfer_store deleted = store.list .select { |e| TERMINAL_STATUSES.include?(e['status']) } .map do |e| store.delete(e['job_id']) e['job_id'] end Cli::Result::Status.new("Deleted #{deleted.size} completed transfer(s)#{": #{deleted.join(', ')}" unless deleted.empty?}") end |
#action_agents_jobs_list ⇒ Object
List async transfer jobs: the jobs not ended are re-queried as with status, else their saved state is shown, with a warning.
Their agents are queried in parallel, by batches of MAX_PARALLEL_QUERIES.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aspera/plugins/xfer/transfer_actions.rb', line 51 def action_agents_jobs_list(**) store = async_transfer_store entries = store.list live_statuses = query_live_statuses(entries.reject { |entry| ended?(entry) }.map { |entry| query_entry(store, entry) }) # Job identifiers by reason of a status not refreshed: one warning for each reason not_refreshed_jobs = Hash.new { |hash, reason| hash[reason] = [] } rows = entries.map do |entry| next entry if ended?(entry) entry, not_refreshed = apply_live_status(store, entry, live_statuses[entry['job_id']]) not_refreshed_jobs[not_refreshed['error']].push(entry['job_id']) if not_refreshed&.key?('error') entry end not_refreshed_jobs.each { |reason, job_ids| Log.log.warn { "Status not refreshed for job #{job_ids.join(', ')}: #{reason}" } } Cli::Result::ObjectList.new(rows, fields: LIST_FIELDS) end |
#action_agents_jobs_status(job_id:) ⇒ Object
Re-query the status of a single async transfer job.
When its agent gives no status, the saved state is shown, with the reason (error or note).
41 42 43 44 45 46 47 |
# File 'lib/aspera/plugins/xfer/transfer_actions.rb', line 41 def action_agents_jobs_status(job_id:, **) store = async_transfer_store entry = store.read(job_id) Aspera.assert(!entry.nil?, type: Cli::BadArgument) { "Unknown job_id: #{job_id}" } entry, not_refreshed = refresh_job(store, entry) Cli::Result::SingleObject.new(entry.merge(not_refreshed || {})) end |