Class: Aliyun::Odps::Instances

Inherits:
ServiceObject show all
Defined in:
lib/aliyun/odps/model/instances.rb

Constant Summary collapse

DEFAULT_PRIORITY =
9

Instance Attribute Summary

Attributes inherited from ServiceObject

#master

Instance Method Summary collapse

Methods inherited from ServiceObject

build, #client, #initialize, #project, service_pool

Constructor Details

This class inherits a constructor from Aliyun::Odps::ServiceObject

Instance Method Details

#create(tasks, options = {}) ⇒ Instance

Create a instance job

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (String)

    Specify the instance name

  • :comment (String)

    Specify comment of the instance

  • :priority (Integer)

    Specify priority of the instance

Returns:

Raises:

  • InstanceNameInvalidError if instance name not valid

See Also:



44
45
46
47
48
49
50
51
52
# File 'lib/aliyun/odps/model/instances.rb', line 44

def create(tasks, options = {})
  Utils.stringify_keys!(options)
  path = "/projects/#{project.name}/instances"

  instance = validate_and_build_instance(tasks, options)
  resp = client.post(path, body: build_create_body(instance))

  append_location(instance, resp.headers['Location'])
end

#list(options = {}) ⇒ List

List instances of project

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

  • jobname (Hash)

    a customizable set of options

  • onlyowner (Hash)

    a customizable set of options

Options Hash (options):

  • :datarange (String)

    specify the starttime range time range

  • :status (String)

    supported value: Running, Suspended, Terminated

  • :marker (String)
  • :maxitems (String) — default: 1000

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
# File 'lib/aliyun/odps/model/instances.rb', line 20

def list(options = {})
  Utils.stringify_keys!(options)
  path = "/projects/#{project.name}/instances"
  query = Utils.hash_slice(options, 'datarange', 'status', 'jobname', 'onlyowner', 'marker', 'maxitems')
  result = client.get(path, query: query).parsed_response

  Aliyun::Odps::List.build(result, %w(Instances Instance)) do |hash|
    Instance.new(hash.merge(project: project))
  end
end

#status(name) ⇒ Object

Get status of instance

Returns:

  • Instance status: Suspended, Running, Terminated

See Also:



61
62
63
64
65
66
67
68
# File 'lib/aliyun/odps/model/instances.rb', line 61

def status(name)
  instance = Instance.new(
    name: name,
    project: project
  )

  instance.get_status
end