MogileFS::Admin

MogileFS administration client, this has little real-world usage and is considered a work-in-progress

Public Instance Methods

change_device_state(host, device, state) view method source

Changes the device status of device on host to state which can be ‘alive’, ‘down’, or ‘dead’.

clear_cache() view method source

Clears the tracker caches. Not implemented in all versions of MogileFS

create_class(domain, klass, policy) view method source

Creates a new class in domain named klass with policy for replication. Raises on failure.

create_domain(domain) view method source

Creates a new domain named domain. Returns nil if creation failed.

create_host(host, args = {}) view method source

Creates a new host named host. args must contain :ip and :port. Returns true if successful, false if not.

delete_class(domain, klass) view method source

Removes class klass from domain. Returns true if successful. Raises on failure

delete_domain(domain) view method source

Deletes domain. Returns true if successful, raises MogileFS::Backend::DomainNotFoundError if not

delete_host(host) view method source

Deletes host host. Returns nil on failure.

Enumerates fids using list_fids. Returns the number of valid fids processed

get_devices(devid = nil) view method source

Returns an Array of device status Hashes. If devid is given only that device is returned.

admin.get_devices 1

Returns:

[{"status"=>"alive",
  "mb_asof"=>nil,
  "mb_free"=>666000,
  "devid"=>1,
  "hostid"=>1,
  "mb_used"=>666,
  "mb_total"=>666666}]
get_domains() view method source

Returns the domains and classes, and their policies present in the mogilefs.

admin.get_domains

Returns (on newer MogileFS servers):

{
  "test" => {
    "default" => {
      "mindevcount" => 2,
      "replpolicy" => "MultipleHosts()"
    }
  }
}

Returns (on older MogileFS servers without replication policies):

{"test"=>{"normal"=>3, "default"=>2}}
get_hosts(hostid = nil) view method source

Returns an Array of host status Hashes. If hostid is given only that host is returned.

admin.get_hosts 1

Returns:

[{"status"=>"alive",
  "http_get_port"=>nil,
  "http_port"=>"",
  "hostid"=>"1",
  "hostip"=>"",
  "hostname"=>"rur-1",
  "altip"=>"",
  "altmask"=>""}]
get_stats(type = 'all') view method source

Returns a statistics structure representing the state of mogilefs.

*** This command no longer works with recent versions of MogileFS *** *** Use mogstats(1) from the MogileFS::Utils package on CPAN ***

admin.get_stats

Returns:

{"fids"=>{"max"=>"99", "count"=>"2"},
 "device"=>
  [{"status"=>"alive", "files"=>"2", "id"=>"1", "host"=>"rur-1"},
   {"status"=>"alive", "files"=>"2", "id"=>"2", "host"=>"rur-2"}],
 "replication"=>
  [{"files"=>"2", "class"=>"normal", "devcount"=>"2", "domain"=>"test"}],
 "file"=>[{"files"=>"2", "class"=>"normal", "domain"=>"test"}]}
list_fids(from_fid, count = 100) view method source

Returns an Array of fid Hashes from from_fid, limited to count

admin.list_fids 0, 100

Returns:

[{"fid"=>99,
  "class"=>"normal",
  "domain"=>"test",
  "devcount"=>2,
  "length"=>4,
  "key"=>"file_key"},
 {"fid"=>82,
  "class"=>"normal",
  "devcount"=>2,
  "domain"=>"test",
  "length"=>9,
  "key"=>"new_new_key"}]
replicate_now() view method source

reschedules all deferred replication, returns a hash with the number of files rescheduled:

admin.replicate_now => { "count" => 5 }
update_class(domain, klass, policy) view method source

Updates class klass in domain with policy for replication. Raises on failure.

update_host(host, args = {}) view method source

Updates host with args. Returns true if successful, false if not.

Protected Instance Methods

clean(count, prefix, res, underscore = true, to_i = []) view method source

Turns the response res from the backend into an Array of Hashes from 1 to res. If underscore is true then a ‘_’ character is assumed between the prefix and the hash key value.

res = {"host1_remoteroot"=>"/mnt/mogilefs/rur-1",
       "host1_hostname"=>"rur-1",
       "host1_hostid"=>"1",
       "host1_http_get_port"=>"",
       "host1_altip"=>"",
       "hosts"=>"1",
       "host1_hostip"=>"",
       "host1_http_port"=>"",
       "host1_status"=>"alive",
       "host1_altmask"=>""}
admin.clean 'hosts', 'host', res

Returns:

[{"status"=>"alive",
  "http_get_port"=>"",
  "http_port"=>"",
  "hostid"=>"1",
  "hostip"=>"",
  "hostname"=>"rur-1",
  "remoteroot"=>"/mnt/mogilefs/rur-1",
  "altip"=>"",
  "altmask"=>""}]
modify_class(domain, klass, policy, action) view method source

Modifies klass on domain to store files on mindevcount devices via action. Returns the class name if successful, raises if not

modify_host(host, args = {}, action = 'create') view method source

Modifies host using args via action. Returns true if successful, false if not.

Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.