class Marathon::Task

This class represents a Marathon Task. See mesosphere.github.io/marathon/docs/rest-api.html#get-/v2/tasks for full list of API's methods.

Constants

ACCESSORS

Public Class Methods

delete(ids, scale = false) click to toggle source

Kill the given list of tasks and scale apps if requested. ids: Id or list of ids with target tasks. scale: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)

after killing the specified tasks.
# File lib/marathon/task.rb, line 60
def delete(ids, scale = false)
  Marathon.singleton.tasks.delete(ids, scale)
end
Also aliased as: remove, kill
delete_all(appId, host = nil, scale = false) click to toggle source

Kill tasks that belong to the application appId. appId: Application's id host: Kill only those tasks running on host host. scale: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)

after killing the specified tasks.
# File lib/marathon/task.rb, line 72
def delete_all(appId, host = nil, scale = false)
  Marathon.singleton.tasks.delete_all(appId, host, scale)
end
Also aliased as: remove_all, kill_all
get(appId) click to toggle source

List all running tasks for application appId. appId: Application's id

# File lib/marathon/task.rb, line 52
def get(appId)
  Marathon.singleton.tasks.get(appId)
end
kill(ids, scale = false)
Alias for: delete
kill_all(appId, host = nil, scale = false)
Alias for: delete_all
list(status = nil) click to toggle source

List tasks of all applications. status: Return only those tasks whose status matches this parameter.

If not specified, all tasks are returned. Possible values: running, staging.
# File lib/marathon/task.rb, line 46
def list(status = nil)
  Marathon.singleton.tasks.list(status)
end
new(hash, marathon_instance = Marathon.singleton) click to toggle source

Create a new task object. hash: Hash including all attributes marathon_instance: MarathonInstance holding a connection to marathon

Calls superclass method Marathon::Base::new
# File lib/marathon/task.rb, line 10
def initialize(hash, marathon_instance = Marathon.singleton)
  super(hash, ACCESSORS)
  @marathon_instance = marathon_instance
end
remove(ids, scale = false)
Alias for: delete
remove_all(appId, host = nil, scale = false)
Alias for: delete_all

Public Instance Methods

delete!(scale = false) click to toggle source

Kill the task that belongs to an application. scale: Scale the app down (i.e. decrement its instances setting by the number of tasks killed)

after killing the specified tasks.
# File lib/marathon/task.rb, line 18
def delete!(scale = false)
  new_task = self.class.delete(id, scale)
end
Also aliased as: kill!
kill!(scale = false)
Alias for: delete!
to_pretty_s() click to toggle source

Returns a string for listing the task.

# File lib/marathon/task.rb, line 29
  def to_pretty_s
    %Q[
Task ID:    #{id}
App ID:     #{appId}
Host:       #{host}
Ports:      #{(ports || []).join(',')}
Staged at:  #{stagedAt}
Started at: #{startedAt}
Version:    #{version}
    ].strip
  end
to_s() click to toggle source
# File lib/marathon/task.rb, line 24
def to_s
  "Marathon::Task { :id => #{self.id} :appId => #{appId} :host => #{host} }"
end