Skip to content

Commit

Permalink
Added to marklogic-community#703: making changes backwards-compatible…
Browse files Browse the repository at this point in the history
… with ML 7
  • Loading branch information
grtjn committed Jun 1, 2017
1 parent 2f02c72 commit 53fbcb8
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,31 +543,57 @@ def restart_group(group = nil)

if group == "cluster"
logger.info "Restarting MarkLogic Server cluster of #{@hostname}"
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2?format=json}, "post", {
'Content-Type' => 'application/json'
}, nil, %Q{
{ "operation": "restart-local-cluster" }
})
else
logger.info "Restarting MarkLogic Server group #{group}"
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2/groups/#{group}?format=json}, "post", {
'Content-Type' => 'application/json'
}, nil, %Q{
{ "operation": "restart-group" }
})
end

raise ExitException.new(r.body) unless r.code.to_i == 202
if @server_version > 7
# MarkLogic 8+, make use of Management REST api and return details of all involved hosts

if group == "cluster"
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2?format=json}, "post", {
'Content-Type' => 'application/json'
}, nil, %Q{
{ "operation": "restart-local-cluster" }
})
else
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2/groups/#{group}?format=json}, "post", {
'Content-Type' => 'application/json'
}, nil, %Q{
{ "operation": "restart-group" }
})
end

raise ExitException.new(r.body) unless r.code.to_i == 202

return JSON.parse(r.body)['restart']['last-startup']
else
# MarkLogic 7- fallback, restart as before, and only verify restart of bootstrap host

return JSON.parse(r.body)['restart']['last-startup']
old_timestamp = go(%Q{http://#{@properties["ml.server"]}:8001/admin/v1/timestamp}, "get").body

logger.debug "this: #{self}"
setup = File.read ServerConfig.expand_path("#{@@path}/lib/xquery/setup.xqy")
r = execute_query %Q{#{setup} setup:do-restart("#{group}")}
logger.debug "code: #{r.code.to_i}"

r.body = parse_body(r.body)
logger.info r.body

return [{
'host-id' => @properties["ml.server"],
'value' => old_timestamp
}]
end
end

def get_host_names
r = go(%Q{http://#{@properties["ml.server"]}:8002/manage/v2/hosts?format=json}, "get")

raise ExitException.new(r.body) unless r.code.to_i == 200

names = {}
names = { @properties["ml.server"] => @properties["ml.server"] } # ml7 fallback

JSON.parse(r.body)['host-default-list']['list-items']['list-item'].each do |host|
names[host['idref']] = host['nameref']
end
Expand Down

0 comments on commit 53fbcb8

Please sign in to comment.