forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAPR-HBASE-199: Command 'processlist' fails with ERROR: Unexpected en…
…d of file from server on secure cluster
- Loading branch information
1 parent
bd84cc9
commit 41ec48a
Showing
2 changed files
with
26 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,29 +83,37 @@ def initialize(configuration) | |
def tasksOnHost(filter,host) | ||
|
||
java_import 'java.net.URL' | ||
java_import 'java.net.SocketException' | ||
java_import 'java.io.InputStreamReader' | ||
java_import 'org.apache.hbase.thirdparty.com.google.gson.JsonParser' | ||
|
||
infoport = @admin.getClusterStatus().getLoad(host).getInfoServerPort().to_s | ||
|
||
# Note: This condition use constants from hbase-server | ||
#if ([email protected]().getBoolean(org.apache.hadoop.hbase.http.ServerConfigurationKeys::HBASE_SSL_ENABLED_KEY, | ||
# org.apache.hadoop.hbase.http.ServerConfigurationKeys::HBASE_SSL_ENABLED_DEFAULT)) | ||
# schema = "http://" | ||
#else | ||
# schema = "https://" | ||
#end | ||
schema = "http://" | ||
url = schema + host.hostname + ":" + infoport + "/rs-status?format=json&filter=" + filter | ||
|
||
json = URL.new(url).openStream | ||
begin | ||
schema = "http://" | ||
url = schema + host.hostname + ':' + infoport + '/rs-status?format=json&filter=' + filter | ||
json = URL.new(url).openStream | ||
rescue SocketException => e | ||
# Let's try with https when SocketException occur | ||
schema = "https://" | ||
url = schema + host.hostname + ':' + infoport + '/rs-status?format=json&filter=' + filter | ||
# MAPR-HBASE-199 in secure cluster, authentication is required, we have mapr negotiation here as system command | ||
cmd = "curl -s -k -H \"Authorization: MAPR-Negotiate $(java -cp `mapr classpath` com.mapr.security.client.examples.MapRClient "\ | ||
"gettoken -url \"#{url}\" 2> /dev/null | grep 'Obtained challenge string' | "\ | ||
"sed -E 's/Obtained challenge string (.*)/\\1/')\" \"#{url}\" | python -m json.tool" | ||
json = %x(#{cmd}) | ||
end | ||
|
||
parser = JsonParser.new | ||
|
||
# read and parse JSON | ||
begin | ||
tasks_array_list = parser.parse(InputStreamReader.new(json, 'UTF-8')).getAsJsonArray | ||
ensure | ||
json.close | ||
if schema == "http://" | ||
tasks_array_list = parser.parse(InputStreamReader.new(json, 'UTF-8')).getAsJsonArray | ||
json.close | ||
else | ||
tasks_array_list = parser.parse(json).getAsJsonArray | ||
end | ||
end | ||
# convert to an array of TaskMonitor::Task instances | ||
tasks = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters