HBASE-21947 TestShell is broken after we remove the jackson dependencies
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
1df99624a5
commit
37e5e47faa
|
@ -34,19 +34,20 @@ module Hbase
|
||||||
class Task
|
class Task
|
||||||
|
|
||||||
def initialize(taskMap, host)
|
def initialize(taskMap, host)
|
||||||
|
taskMap.entrySet.each do |entry|
|
||||||
taskMap.each_pair do |k,v|
|
k = entry.getKey
|
||||||
|
v = entry.getValue
|
||||||
case k
|
case k
|
||||||
when "statustimems"
|
when 'statustimems'
|
||||||
@statustime = Time.at(v/1000)
|
@statustime = Time.at(v.getAsLong / 1000)
|
||||||
when "status"
|
when 'status'
|
||||||
@status = v
|
@status = v.getAsString
|
||||||
when "starttimems"
|
when 'starttimems'
|
||||||
@starttime = Time.at(v/1000)
|
@starttime = Time.at(v.getAsLong / 1000)
|
||||||
when "description"
|
when 'description'
|
||||||
@description = v
|
@description = v.getAsString
|
||||||
when "state"
|
when 'state'
|
||||||
@state = v
|
@state = v.getAsString
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,7 +83,8 @@ module Hbase
|
||||||
def tasksOnHost(filter,host)
|
def tasksOnHost(filter,host)
|
||||||
|
|
||||||
java_import 'java.net.URL'
|
java_import 'java.net.URL'
|
||||||
java_import 'com.fasterxml.jackson.databind.ObjectMapper'
|
java_import 'java.io.InputStreamReader'
|
||||||
|
java_import 'org.apache.hbase.thirdparty.com.google.gson.JsonParser'
|
||||||
|
|
||||||
infoport = @admin.getClusterStatus().getLoad(host).getInfoServerPort().to_s
|
infoport = @admin.getClusterStatus().getLoad(host).getInfoServerPort().to_s
|
||||||
|
|
||||||
|
@ -96,16 +98,19 @@ module Hbase
|
||||||
schema = "http://"
|
schema = "http://"
|
||||||
url = schema + host.hostname + ":" + infoport + "/rs-status?format=json&filter=" + filter
|
url = schema + host.hostname + ":" + infoport + "/rs-status?format=json&filter=" + filter
|
||||||
|
|
||||||
json = URL.new(url)
|
json = URL.new(url).openStream
|
||||||
mapper = ObjectMapper.new
|
parser = JsonParser.new
|
||||||
|
|
||||||
# read and parse JSON
|
# read and parse JSON
|
||||||
tasksArrayList = mapper.readValue(json,java.lang.Object.java_class)
|
begin
|
||||||
|
tasks_array_list = parser.parse(InputStreamReader.new(json, 'UTF-8')).getAsJsonArray
|
||||||
|
ensure
|
||||||
|
json.close
|
||||||
|
end
|
||||||
# convert to an array of TaskMonitor::Task instances
|
# convert to an array of TaskMonitor::Task instances
|
||||||
tasks = Array.new
|
tasks = []
|
||||||
tasksArrayList.each do |t|
|
tasks_array_list.each do |t|
|
||||||
tasks.unshift Task.new(t,host)
|
tasks.unshift Task.new(t.getAsJsonObject, host)
|
||||||
end
|
end
|
||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
|
|
Loading…
Reference in New Issue