Hi All,

xdmp:http-head(..) will return code as 200 & message as "OK" only when we hit 
HTTP Servers. For XDBC server & WebDav servers it will always return 404/Not 
Found.
"xdmp:host-status(xdmp:host())//*:port"  will all ports used in MarkLogic 
server only.

For example:

I have following app servers with authentication scheme as "digest", you can 
test this with any auth scheme (I tested for all).


1-      Http server (cms_http) running on port 8007

2-      Xdbc server (cms_xdbc) running on port 8003

3-      WebDav server (cms_webdav) running on port 8006

4-      Http server (content_http) running on port 8005

Used the following>>

declare function local:get-port-status($authScheme as xs:string?,
                             $port as xs:string?,$userName as 
xs:string?,$password as xs:string?)
{
   xdmp:http-head(fn:concat("http://localhost:",$port),
     <options xmlns="xdmp:http">
       <authentication method="{$authScheme}">
         <username>{$userName}</username>
         <password>{$password}</password>
       </authentication>
     </options>)
};

try{
   local:get-port-status("digest","8007","admin","passw0rd"),
   local:get-port-status("digest","8003","admin","passw0rd"),
   local:get-port-status("digest","8006","admin","passw0rd"),
   local:get-port-status("digest","8005","admin","passw0rd")

}catch($e){
   $e
}

Response is:

<results warning="more than one root item">
 <response xmlns="xdmp:http">
    <code>200</code>
    <message>OK</message>
    <headers>
      <content-type>text/html; charset=UTF-8</content-type>
      <server>MarkLogic</server>
      <connection>close</connection>
    </headers>
  </response>
  <response xmlns="xdmp:http">
    <code>404</code>
    <message>Not Found</message>
    <headers>
      <content-type>text/html; charset=utf-8</content-type>
      <server>MarkLogic 5.0-1.2</server>
      <connection>close</connection>
    </headers>
  </response>
  <response xmlns="xdmp:http">
    <code>404</code>
    <message>Not Found</message>
    <headers>
      <content-type>text/html; charset=utf-8</content-type>
      <server>MarkLogic</server>
      <connection>close</connection>
    </headers>
  </response>
 <response xmlns="xdmp:http">
    <code>200</code>
    <message>OK</message>
    <headers>
      <content-type>text/html; charset=UTF-8</content-type>
      <server>MarkLogic</server>
      <connection>close</connection>
    </headers>
  </response>

</results>

Thanks,
Abhinav Kumar Mishra

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jakob Fix
Sent: Friday, May 17, 2013 11:41 AM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] how can i check whether an appserver

what do you think? seems to work quite nicely.

let $port := xdmp:random(65535 + 8003) + 8003 (: yes, let's force ports above 
8003 :)
return
try {
  if (xdmp:http-head("http://127.0.0.1:"; || $port)) then
    (: try again :)
  else
    $port
} catch($e) {
  $port
}



cheers,
Jakob.

On Fri, May 17, 2013 at 8:01 AM, Jakob Fix 
<[email protected]<mailto:[email protected]>> wrote:
Argh, that's right, I didn't think of that! All right, I'll do that then.
Bedankt!

cheers,
Jakob.

On Fri, May 17, 2013 at 7:37 AM, Geert Josten 
<[email protected]<mailto:[email protected]>> wrote:
Hi Jakob,

The port could be in use by an external (non-ML) process. You could also do 
xdmp:http-get on the port number. Make sure to use a small timeout though.. ;-)

Cheers,
Geert

Van: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 Namens Jakob Fix
Verzonden: vrijdag 17 mei 2013 7:17
Aan: MarkLogic Developer Discussion
Onderwerp: Re: [MarkLogic Dev General] how can i check whether an appserver

Thanks David, that does the job perfectly.

cheers,
Jakob.

On Fri, May 17, 2013 at 12:59 AM, David Lee 
<[email protected]<mailto:[email protected]>> wrote:
$port = xdmp:host-status(xdmp:host())//*:port

-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224<tel:%2B1%20812-482-5224>
Cell:  +1 812-630-7622<tel:%2B1%20812-630-7622>
www.marklogic.com<http://www.marklogic.com/>

From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Jakob Fix
Sent: Thursday, May 16, 2013 6:56 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] how can i check whether an appserver

Hello,

if I wanted to script the creation of an xdbc appserver and I don't really care 
about the port number to use (so let's say I use xdmp:random(65535) + 8003), 
how can I find out whether that port is already in use by an already existing 
server?

Basically I'm looking for a definition of the local:port-number-in-use($pn) 
below.
declare function local:get-port-number()
as xs:integer
{
    let $pn := xdmp:random(65535 + 8003)
    return
        if (local:port-number-in-use($pn))
            then local:get-port-number()
            else $pn
};
cheers,
Jakob.

_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general


This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful.
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to