Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created June 27, 2013 18:08
Show Gist options
  • Save ableasdale/5878835 to your computer and use it in GitHub Desktop.
Save ableasdale/5878835 to your computer and use it in GitHub Desktop.
Hit an endpoint on each host in a cluster
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