Class: TungstenAPI::TungstenReplicator

Inherits:
TungstenDataserviceManager show all
Defined in:
lib/tungsten/api.rb

Overview

Derived class of TungstenDataserviceManager, designed to handle calls to Replicator tools that provide json objects

sample usage:
   cctrl = TungstenReplicator.new('/opt/continuent/cookbook_test/tungsten/tungsten-replicator/bin')
   cctrl.list()
   puts ''
   pp cctrl.get( 'status', nil)
   pp cctrl.get( 'services', nil)
   pp cctrl.get( 'tasks', 'mysvc', 'myhost')
   pp cctrl.get( 'thl_headers', nil, nil, '-low 10 -high 80')

Instance Method Summary collapse

Methods inherited from TungstenDataserviceManager

#add_api_call, #call, #call_default, #list, #post, #set_server, #to_hash

Constructor Details

#initialize(tools_path, rmi_port = 10000) ⇒ TungstenReplicator

Registers all the known API calls for Tungsten data service



514
515
516
517
518
519
520
521
522
523
# File 'lib/tungsten/api.rb', line 514

def initialize(tools_path, rmi_port=10000)
    @api_calls = {}
    add_api_call( ReplicatorAPICall.new('status', tools_path, 'trepctl', 'status -json', 'Show replicator status', rmi_port ) )      
    %w(tasks stages stores shards).each do |option|
        add_api_call( ReplicatorAPICall.new(option, tools_path,'trepctl',  "status -name #{option} -json", "Show replicator #{option}", rmi_port ) )      
    end
    add_api_call( ReplicatorAPICall.new('services', tools_path, 'trepctl', 'services -json', 'Show replicator services', rmi_port ) )      
    add_api_call( ReplicatorAPICall.new('properties', tools_path, 'trepctl', 'properties', 'Show replicator properties', rmi_port) )      
    add_api_call( ReplicatorAPICall.new('thl_headers', tools_path, 'thl', 'list -headers -json', 'Show thl headers', nil) )      
end

Instance Method Details

#dashesObject

Overriding ancestor’s method, to make a call to ‘list’ safe



535
536
537
# File 'lib/tungsten/api.rb', line 535

def dashes
    return ReplicatorAPICall.dashes
end

#get(name, service = nil, host = nil, more_options = nil) ⇒ Object

Gets a hash from a JSON object returned from a given call

name : the api being called service : to qualify the service, if the API requires it host: to run the call with a -host option



546
547
548
# File 'lib/tungsten/api.rb', line 546

def get(name, service=nil, host=nil, more_options=nil)
    @api_calls[name].get(service,host,more_options)
end

#headerObject

Overriding ancestor’s method, to make a call to ‘list’ safe



528
529
530
# File 'lib/tungsten/api.rb', line 528

def header
    return ReplicatorAPICall.header
end