Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 118cad8

Browse files
committed
Added to #703: making changes backwards-compatible with ML 7
1 parent 12b708f commit 118cad8

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

deploy/lib/server_config.rb

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -543,31 +543,57 @@ def restart_group(group = nil)
543543

544544
if group == "cluster"
545545
logger.info "Restarting MarkLogic Server cluster of #{@hostname}"
546-
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2?format=json}, "post", {
547-
'Content-Type' => 'application/json'
548-
}, nil, %Q{
549-
{ "operation": "restart-local-cluster" }
550-
})
551546
else
552547
logger.info "Restarting MarkLogic Server group #{group}"
553-
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2/groups/#{group}?format=json}, "post", {
554-
'Content-Type' => 'application/json'
555-
}, nil, %Q{
556-
{ "operation": "restart-group" }
557-
})
558548
end
559549

560-
raise ExitException.new(r.body) unless r.code.to_i == 202
550+
if @server_version > 7
551+
# MarkLogic 8+, make use of Management REST api and return details of all involved hosts
552+
553+
if group == "cluster"
554+
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2?format=json}, "post", {
555+
'Content-Type' => 'application/json'
556+
}, nil, %Q{
557+
{ "operation": "restart-local-cluster" }
558+
})
559+
else
560+
r = go(%Q{http://#{@properties["ml.server"]}:#{@properties["ml.bootstrap-port"]}/manage/v2/groups/#{group}?format=json}, "post", {
561+
'Content-Type' => 'application/json'
562+
}, nil, %Q{
563+
{ "operation": "restart-group" }
564+
})
565+
end
566+
567+
raise ExitException.new(r.body) unless r.code.to_i == 202
568+
569+
return JSON.parse(r.body)['restart']['last-startup']
570+
else
571+
# MarkLogic 7- fallback, restart as before, and only verify restart of bootstrap host
561572

562-
return JSON.parse(r.body)['restart']['last-startup']
573+
old_timestamp = go(%Q{http://#{@properties["ml.server"]}:8001/admin/v1/timestamp}, "get").body
574+
575+
logger.debug "this: #{self}"
576+
setup = File.read ServerConfig.expand_path("#{@@path}/lib/xquery/setup.xqy")
577+
r = execute_query %Q{#{setup} setup:do-restart("#{group}")}
578+
logger.debug "code: #{r.code.to_i}"
579+
580+
r.body = parse_body(r.body)
581+
logger.info r.body
582+
583+
return [{
584+
'host-id' => @properties["ml.server"],
585+
'value' => old_timestamp
586+
}]
587+
end
563588
end
564589

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

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

570-
names = {}
595+
names = { @properties["ml.server"] => @properties["ml.server"] } # ml7 fallback
596+
571597
JSON.parse(r.body)['host-default-list']['list-items']['list-item'].each do |host|
572598
names[host['idref']] = host['nameref']
573599
end

0 commit comments

Comments
 (0)