@@ -533,7 +533,10 @@ def execute_query(query, properties = {})
533533 return r
534534 end
535535
536- def restart_group ( group = nil )
536+ def restart_group ( group = nil , legacy = false )
537+ logger . debug "group: #{ group } "
538+ logger . debug "legacy: #{ legacy } "
539+
537540 if ! group
538541 # Note:
539542 # Restarting partial cluster is unsafe when working with multiple groups.
@@ -547,7 +550,7 @@ def restart_group(group = nil)
547550 logger . info "Restarting MarkLogic Server group #{ group } "
548551 end
549552
550- if @server_version > 7
553+ if @server_version > 7 && ! legacy
551554 # MarkLogic 8+, make use of Management REST api and return details of all involved hosts
552555
553556 if group == "cluster"
@@ -572,7 +575,6 @@ def restart_group(group = nil)
572575
573576 old_timestamp = go ( %Q{http://#{ @properties [ "ml.server" ] } :8001/admin/v1/timestamp} , "get" ) . body
574577
575- logger . debug "this: #{ self } "
576578 setup = File . read ServerConfig . expand_path ( "#{ @@path } /lib/xquery/setup.xqy" )
577579 r = execute_query %Q{#{ setup } setup:do-restart("#{ group } ")}
578580 logger . debug "code: #{ r . code . to_i } "
@@ -604,6 +606,11 @@ def get_host_names
604606 def restart
605607 # Default to verified restart
606608 verify = find_arg ( [ '--verify' ] ) != 'false'
609+ # Default to using Management Rest api (if available)
610+ legacy = find_arg ( [ '--legacy' ] ) != nil
611+
612+ logger . debug "verify: #{ verify } "
613+ logger . debug "legacy: #{ legacy } "
607614
608615 group = next_arg ( "^[^-]" )
609616
@@ -615,12 +622,12 @@ def restart
615622 end
616623
617624 if ! verify
618- restart_group ( group )
625+ restart_group ( group , legacy )
619626 else
620- old_timestamps = restart_group ( group )
621-
622627 host_names = get_host_names ( )
623628
629+ old_timestamps = restart_group ( group , legacy )
630+
624631 # Iterate until all hosts have restarted (or max is reached)
625632 old_timestamps . each do |host |
626633 host_name = host_names [ host [ 'host-id' ] ]
0 commit comments