DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  DataPower sleep CLI

    Posted Fri December 27, 2024 04:49 PM

    Team,

    Is there a wait / sleep DataPower CLI?

    Thanks.



    ------------------------------
    Gosha Belenkiy
    Solution Architect | Cloud | Integration
    ------------------------------


  • 2.  RE: DataPower sleep CLI

    Posted Sat December 28, 2024 12:36 PM

    Unfortunately, no.   However, with that said, what is your use case?



    ------------------------------
    Joseph Morgan
    CEO - Independent
    Dallas TX
    ------------------------------



  • 3.  RE: DataPower sleep CLI

    Posted Sun December 29, 2024 08:31 AM

    Actually, there is sleep() and setTimeout() both in gateway-script(GwS).  There is no sleep in XSLT but you can do hacky things like ping an unreachable ip addr which gives a 6 second delay.

    I did a rather interesting study of GwS sleep using asynchronous and synchronous callbacks a few years ago.   I did this study because my requirements included very precise latency for use as backend in "fixed latency" performance testing.  The results showed the async callback latency has very wide variance while the synchronous approach is much more precise and blocks a thread while sleeping.  

    First is async approach:

    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }
    // Introduce latency if requested
    if (min_latency_ms != 0 || max_latency_ms != 0) {
       sleep_ms = Math.floor(Math.random() * (max_latency_ms - min_latency_ms + 1) + min_latency_ms);
       await sleep(sleep_ms);
    }

    Above is async, below is synchronous---------------------------------------------------

    // Callback for setTimeout()
    function timeout_expired_callback() {
       //Do something 
    }

    if (min_latency_ms != 0 || max_latency_ms != 0) {
       sleep_ms = Math.floor(Math.random() * (max_latency_ms - min_latency_ms + 1) + min_latency_ms);
       setTimeout(timeout_expired_callback, sleep_ms);
    }

    If you can accept a few mS of variance in the callback then the async approach is recommended in order to avoid occupying a GwS runtime engine while sleeping.  You can monitor the GwS engine availability using the gatewayscript-status CLI which is also available from the rest-mgmt, xml-mgmt and GUI interfaces.

    dp809:idg(config)# sh gatewayscript-st
     
    Available run times: 64 
       In-use run times: 0 
            Queued work: 0 
       Runtime failures: 0 

    Hope this helps.

    -Ivanh  



    ------------------------------
    Ivan Heninger
    ------------------------------



  • 4.  RE: DataPower sleep CLI

    Posted Fri January 03, 2025 08:39 AM
    Edited by Hermann Stamm-Wilbrandt Fri January 03, 2025 08:39 AM

    > ... There is no sleep in XSLT but ...
    >
    You can call any GatewayScript directly from XSLT:
    https://www.ibm.com/docs/en/datapower-gateway/10.5.0?topic=functions-dpgatewayscript


    You can even call in the other direction, call XQuery from XSLT, and XSLT being called from GatewayScript:
    https://stamm-wilbrandt.de/en/blog/3lang.js

    $ coproc2 happy.js <("") http://dp-hermann-work.fyre.ibm.com:2227; echo
    2025
    $ cat happy.js 
    for(var sum=0,i=1;i<=9;++i){sum+=i*i*i}
    session.output.write(sum);



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support, IBM DataPower Gateways
    IBM
    Boeblingen
    ------------------------------



  • 5.  RE: DataPower sleep CLI

    Posted Fri January 03, 2025 12:18 PM

    The question is if sleep/wait exists as a DataPower CLI (or SSH for that matter).



    ------------------------------
    Gosha Belenkiy
    Solution Architect | Cloud | Integration
    ------------------------------



  • 6.  RE: DataPower sleep CLI

    Posted Sun January 05, 2025 02:01 PM

    No there isn't.  However, when you take it down to SSH, then you're likely sending CLI commands from a shell script?  In that case, you can simply use the shell scripting equivalent. 

    For linux/unix, it is simply "sleep ##p", where the '##' is replacing with an amount and 'p' is the time period, such as 's' for seconds, 'm' for minutes.   So to sleep for one second, you'd add "sleep 1s" to the script.

    For PowerShell,  use the "Start-Sleep" command, which also comes with a time period and a number, but in reverse, such as "Start-Sleep -Seconds 1".

    On a side note, KumbaSoft just added a "sleep" command to their CLI implementation in their DPAA (DataPower Administrator's Assistant) tool, where it creates a simulation of a DataPower sleep. 



    ------------------------------
    Joseph Morgan
    CEO - Independent
    Dallas TX
    ------------------------------