The Resource Pool (ResPool) service is described in section "8.15 Resource Pool (ResPool) Service" in the STAF User's Guide at http://staf.sourceforge.net/current/STAFUG.htm#HDRRESSRV. In particular, see sub-section "8.15.10 REQUEST" for more information and examples (especially in the "Command Line sub-sub-section") about how to request a resource from a resource pool using the ResPool service.
A REQUEST request submitted to the ResPool service obtains exclusive access to an entry in the resource pool. If an entry is available that meets the specified criteria in the request, then the entry will become owned by the STAF handle on the machine that submitted the REQUEST POOL request to the ResPool service. If an entry is not currently available that meets the specified criteria in the request, the request will be added to the "Pending Requests" list in ascending order by "priority" and then by the timestamp when the request was submitted, and the request will wait indefinitely until a resource is available (or you can specify the TIMEOUR option to specify the longest time you are willing to wait for a resource to become available). When you are finished with a resource, you can submit a RELEASE request to the ResPool service so that that resource is now available and can be used to satisfy other requests. Here's an example of creating a machine pool containing 2 machines (via the command line): C:\>STAF local RESPOOL CREATE POOL MachinePool DESCRIPTION "Machine Pool" Response -------- C:\>STAF local RESPOOL ADD POOL MachinePool ENTRY machine1.company.com Response -------- C:\>STAF local RESPOOL ADD POOL MachinePool ENTRY machine2.company.com Response -------- You can query the pool and see that both of these machines in the machine pool are currently available: C:\>STAF local RESPOOL QUERY Pool MachinePool Response -------- { Description : Machine Pool Pending Requests: [] Resources : [ { Entry: machine1.company.com Owner: <None> } { Entry: machine2.company.com Owner: <None> } ] } You can request an entry from this pool to obtain exclusive access to a random machine in the pool so that while you own this resource, the resource pool will not make this resource available to another REQUEST submitted to the ResPool service for this resource pool. Note, instead you could specify to request a particular entry from the pool or the first available entry in the pool instead of requesting a random entry from the pool. Since I'm showing you this example using the command line, I need to create a STAF handle and set the STAF_HANDLE_NAME environment variable to that handle number. If you were submitting these STAF service requests via a Java/Python/Perl/Tclprogram, you would have already created a STAF handle to use to submit STAF service requests, or if submitting this request via a STAX job, a STAF handle is created automatically for each STAX job and you can simply use the <stafcmd> element to submit a RESPOOL REQUEST request (or another request to the RESPOOL service). C:\>STAF local HANDLE CREATE HANDLE NAME ResourcePoolHandle Response -------- 18 C:\>set STAF_STATIC_HANDLE=18 C:\>STAF local RESPOOL REQUEST POOL MachinePool Response -------- machine2.company.com C:\>STAF local RESPOOL QUERY POOL MachinePool Response -------- { Description : Machine Pool Pending Requests: [] Resources : [ { Entry: machine1.company.com Owner: <None> } { Entry: machine2.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:04 Date-Time Acquired : 20140326-15:43:04 Perform Garbage Collection: Yes } } ] } You could then request another resource from this machine pool (via this STAF handle or via another STAF handle, or another STAX job, etc) and you will get the other available resource in the resource pool and now both resources in this machine pool are owned (none are currently available to be requested) as shown by the QUERY request: C:\>STAF local RESPOOL REQUEST POOL MachinePool Response -------- machine1.company.com C:\>STAF local RESPOOL QUERY POOL MachinePool Response -------- { Description : Machine Pool Pending Requests: [] Resources : [ { Entry: machine1.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:52 Date-Time Acquired : 20140326-15:43:52 Perform Garbage Collection: Yes } } { Entry: machine2.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:04 Date-Time Acquired : 20140326-15:43:04 Perform Garbage Collection: Yes } } ] } Since all the resources in this machine pool are owned and none are available, if you request another resource, the request will wait (will not complete) until one of the resources are released. C:\>STAF local RESPOOL REQUEST POOL MachinePool If you opened another command prompt, and submitted a QUERY request to the RESPOOL service to query the machine pool, you'll see that there is now an entry in the "Pending Requests" list for this machine pool. C:\>STAF local RESPOOL QUERY Pool MachinePool Response -------- { Description : Machine Pool Pending Requests: [ { Priority : 50 Date-Time Requested : 20140326-15:44:06 Requested Entry : <None> Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Perform Garbage Collection: Yes } ] Resources : [ { Entry: machine1.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:52 Date-Time Acquired : 20140326-15:43:52 Perform Garbage Collection: Yes } } { Entry: machine2.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:04 Date-Time Acquired : 20140326-15:43:04 Perform Garbage Collection: Yes } } ] } Once you release a machine that you own from the machine pool, then the pending request will become satisfied: C:\>STAF local RESPOOL RELEASE POOL MachinePool ENTRY machine2.company.com Response -------- C:\>STAF local RESPOOL QUERY POOL MachinePool Response -------- { Description : Machine Pool Pending Requests: [] Resources : [ { Entry: machine1.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:43:52 Date-Time Acquired : 20140326-15:43:52 Perform Garbage Collection: Yes } } { Entry: machine2.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:44:06 Date-Time Acquired : 20140326-15:45:02 Perform Garbage Collection: Yes } } ] } Here's an example of releasing the machine1.company.com entry in the machine pool and querying the machine pool to show that this entry is no longer owned: C:\>STAF local RESPOOL RELEASE POOL MachinePool ENTRY machine1.company.com Response -------- C:\>STAF local RESPOOL QUERY POOL MachinePool Response -------- { Description : Machine Pool Pending Requests: [] Resources : [ { Entry: machine1.company.com Owner: <None> } { Entry: machine2.company.com Owner: { Machine : IBM-0JUBIF7T5B8 Handle Name : ResourcePoolHandle Handle : 18 User : none://anonymous Endpoint : local://local Date-Time Requested : 20140326-15:44:06 Date-Time Acquired : 20140326-15:45:02 Perform Garbage Collection: Yes } } ] } Hope this helps you understand the ResPool service better. -------------------------------------------------------------- Sharon Lucas IBM Austin, luc...@us.ibm.com (512) 286-7313 or Tieline 363-7313 From: "Zhu, Cindy" <cindy....@ihs.com> To: "staf-users@lists.sourceforge.net" <staf-users@lists.sourceforge.net>, Date: 03/25/2014 04:55 PM Subject: [staf-users] ResPool Service Hi, We have a group of machines that needed to be shared by numerous test cases. I guess ResPool service is the right one to go with. Can you give me some examples or links of examples to show how to use this service to run test cases whenever one resource in the pool is available? Thanks, Cindy ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
_______________________________________________ staf-users mailing list staf-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/staf-users