class TungstenStatus
Constants
- COMPOSITE_SERVICE
- COORDINATOR
- DATASERVER
- DATASERVICE
- DATASOURCES
- HOSTNAME
- LATENCY
- MANAGER
- MASTER
- PHYSICAL_SERVICE
- REPLICATION_SERVICE
- REPLICATOR
- REPLICATORS
- ROLE
- ROUTERS
- SEQNO
- SERVICE_TYPE
- STATUS
Public Class Methods
new(install, dataservice = nil)
click to toggle source
# File lib/tungsten/status.rb, line 24 def initialize(install, dataservice = nil) @install = install @dataservice = dataservice @service_type = nil @props = nil end
Public Instance Methods
coordinator()
click to toggle source
# File lib/tungsten/status.rb, line 93 def coordinator self.parse() return @props.getProperty(['coordinator','host']) end
datasource_role(hostname)
click to toggle source
# File lib/tungsten/status.rb, line 113 def datasource_role(hostname) datasource_value(hostname, 'role') end
datasource_status(hostname)
click to toggle source
# File lib/tungsten/status.rb, line 117 def datasource_status(hostname) datasource_value(hostname, 'state') end
datasource_value(hostname, argument)
click to toggle source
# File lib/tungsten/status.rb, line 133 def datasource_value(hostname, argument) self.parse() return @props.getProperty([DATASOURCES, hostname, argument]) end
datasources()
click to toggle source
# File lib/tungsten/status.rb, line 103 def datasources self.parse() return @props.getPropertyOr([DATASOURCES], {}).keys() end
force_output()
click to toggle source
# File lib/tungsten/status.rb, line 173 def force_output() self.parse() TU.force_output(self.to_s) end
is_composite?()
click to toggle source
# File lib/tungsten/status.rb, line 153 def is_composite? self.parse() return @props.getProperty(SERVICE_TYPE) == COMPOSITE_SERVICE end
is_physical?()
click to toggle source
# File lib/tungsten/status.rb, line 148 def is_physical? self.parse() return @props.getProperty(SERVICE_TYPE) == PHYSICAL_SERVICE end
is_replication?()
click to toggle source
# File lib/tungsten/status.rb, line 143 def is_replication? self.parse() return @props.getProperty(SERVICE_TYPE) == REPLICATION_SERVICE end
name()
click to toggle source
# File lib/tungsten/status.rb, line 88 def name self.parse() return @props.getProperty(DATASERVICE) end
output()
click to toggle source
# File lib/tungsten/status.rb, line 168 def output() self.parse() TU.output(self.to_s) end
parse()
click to toggle source
# File lib/tungsten/status.rb, line 31 def parse if @props != nil return end if @dataservice == nil if @install.dataservices().size > 1 raise "Unable to parse trepctl because there are multiple dataservices defined for this replicator. Try specifying a specific replication service." end @dataservice = @install.dataservices()[0] end if @install.is_manager?() unless @install.is_running?("manager") raise "Unable to provide status for #{@dataservice} from #{@install.hostname()}:#{@install.root()} because the manager is not running" end parse_manager() elsif @install.is_replicator?() unless @install.is_running?("replicator") raise "Unable to provide status for #{@dataservice} from #{@install.hostname()}:#{@install.root()} because the replicator is not running" end parse_replicator() else raise "Unable to provide status for #{@dataservice} from #{@install.hostname()}:#{@install.root()} because it is not a database server" end end
parse_manager()
click to toggle source
# File lib/tungsten/status.rb, line 58 def parse_manager @props = Properties.new() mgr = TungstenDataserviceManager.new(@install.mgr_api_uri()) result = mgr.get(@dataservice, 'status') result = result["outputPayload"]["dataServiceState"] @props.setProperty(DATASERVICE, @dataservice) if result["composite"] == true @props.setProperty(SERVICE_TYPE, COMPOSITE_SERVICE) else @props.setProperty(SERVICE_TYPE, PHYSICAL_SERVICE) end @props.setProperty(COORDINATOR, { "host" => result["coordinator"], "mode" => result["policyManagerMode"] }) @props.setProperty(DATASOURCES, result["dataSources"]) @props.setProperty(REPLICATORS, result["replicators"]) end
parse_replicator()
click to toggle source
# File lib/tungsten/status.rb, line 79 def parse_replicator @props = Properties.new() @props.setProperty(DATASERVICE, @dataservice) @props.setProperty(SERVICE_TYPE, REPLICATION_SERVICE) r_props = JSON.parse(TU.cmd_result("#{@install.trepctl(@dataservice)} status -json")) @props.setProperty([REPLICATORS, @install.hostname()], r_props) end
policy()
click to toggle source
# File lib/tungsten/status.rb, line 98 def policy self.parse() return @props.getProperty(['coordinator','mode']) end
replicator_latency(hostname)
click to toggle source
# File lib/tungsten/status.rb, line 129 def replicator_latency(hostname) replicator_value(hostname, 'appliedLatency').to_f() end
replicator_role(hostname)
click to toggle source
# File lib/tungsten/status.rb, line 121 def replicator_role(hostname) replicator_value(hostname, 'role') end
replicator_status(hostname)
click to toggle source
# File lib/tungsten/status.rb, line 125 def replicator_status(hostname) replicator_value(hostname, 'state') end
replicator_value(hostname, argument)
click to toggle source
# File lib/tungsten/status.rb, line 138 def replicator_value(hostname, argument) self.parse() return @props.getProperty([REPLICATORS, hostname, argument]) end
replicators()
click to toggle source
# File lib/tungsten/status.rb, line 108 def replicators self.parse() return @props.getPropertyOr([REPLICATORS], {}).keys() end
to_hash()
click to toggle source
# File lib/tungsten/status.rb, line 163 def to_hash self.parse() return @props.props end
to_s()
click to toggle source
# File lib/tungsten/status.rb, line 158 def to_s self.parse() return @props.to_s() end