Created
June 27, 2013 18:08
-
-
Save ableasdale/5878835 to your computer and use it in GitHub Desktop.
Hit an endpoint on each host in a cluster
This file contains hidden or 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
xquery version "1.0-ml"; | |
import module namespace admin = 'http://marklogic.com/xdmp/admin' at '/MarkLogic/admin.xqy'; | |
declare variable $USER as xs:string := "q"; | |
declare variable $PASS as xs:string := "q"; | |
declare variable $PORT as xs:string := "9999"; | |
declare variable $ENDPOINT as xs:string := "/endpoint.xqy"; | |
declare function local:generate-cluster-endpoints() as xs:string* { | |
for $h in xdmp:hosts() | |
return concat ("http://",xdmp:host-name($h),":",$PORT, $ENDPOINT) | |
}; | |
for $uri in local:generate-cluster-endpoints() | |
return xdmp:document-get($uri, | |
<options xmlns="xdmp:document-get" xmlns:http="xdmp:http"> | |
<format>xml</format> | |
<http:authentication> | |
<http:username>{$USER}</http:username> | |
<http:password>{$PASS}</http:password> | |
</http:authentication> | |
</options>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment