⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafpool.rxp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 RXP
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2001                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//******************************************************************************//* STAF_SERVICE_INTERFACE_LEVEL:2                                             *//******************************************************************************//* REXX Resource Service for Software Testing Automation Framework (STAF)     *//* -------------------------------------------------------------------------- *//* Desc: External service providing exclusive use of a resource pool resource *//* -------------------------------------------------------------------------- *//* Options:                                                                   *//*                                                                            *//*   CREATE  - Creates a resource pool                                        *//*   DELETE  - Deletes a resource pool                                        *//*   QUERY   - Displays information about a resource pool                     *//*   REQUEST - Request exclusive access to next available resource in a pool  *//*   ADD     - Add a resource to a specified resource pool                    *//*   REMOVE  - Removes a resource from a specified resource pool              *//*   RELEASE - Releases exclusive use of a resource from a resource pool      *//*   LIST    - Display a list of resource pools                               *//*   HELP    - Returns syntax information                                     *//*                                                                            *//* -------------------------------------------------------------------------- *//* History:                                                                   *//*  1.00  PEP  09/11/1998  Initial implementation                             *//*  1.01  PEP  09/22/1998  Updates per 9/17/98 code review                    *//*  1.10  CVR  03/09/1999  Overhaul for new STAF features in STAF V1.2        *//*  1.11  CVR  04/03/2000  Fixed problem removing an owned resource, and      *//*                         fixed problem w/ not waking up waiters on addition *//*                         of new resource, and added VERSION command         *//******************************************************************************/OPTIONS "EXMODE ETMODE"parse source osType invokeType functionName/**********************************//* Initialize STAF error messages *//**********************************/call STAFErrorTextcall STAFPoolErrorText/*******************************************//* Make sure we are being called correctly *//*******************************************/if invokeType \= "FUNCTION" then    RETURN MakeSTAFResult(STAFError.!ServiceConfigurationError)/********************************************//* Now simply call the appropriate function *//********************************************/SIGNAL VALUE TRANSLATE(functionName)/****************************************************************************//* STAFServiceInit - Initializes the service                                *//*                                                                          *//* Accepts: The name of this service                                        *//*          The service parameters                                          *//* Returns: 0                                                               *//****************************************************************************/STAFServiceInit:  parse arg serviceName, serviceParms  ext = '.rpl'  /***********************************************/  /* Load STAF, RexxUtil, and RxThread Functions */  /***********************************************/  call RxFuncAdd "STAFLoadFuncs", "RXSTAF", "STAFLoadFuncs"  call STAFLoadFuncs  call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"  call SysLoadFuncs  call RxFuncAdd "RxThreadLoadFuncs", "RxThread", "RxThreadLoadFuncs"  call RxThreadLoadFuncs  /**********************************************/  /* Register with STAF                         */  /**********************************************/  call STAFRegister "STAF/Service/"serviceName  if RESULT \= 0 then  do      RETURN MakeSTAFResult(STAFError.!STAFRegistrationError,,                            STAFError.!STAFRegistrationError.!Text":" RESULT)  end  self = "STAF/Service/"serviceName  errorBuffer = ""  /************************/  /* Query STAF Variables */  /************************/  call ResolveStandardVariables  if RESULT \= 0 then RETURN MakeSTAFResult(RESULT, errorBuffer)  /******************************************/  /* Find all the pools and initialize them */  /******************************************/  call SysFileTree pooldir || delimit'*'ext, 'find', 'FSO'  do i = 1 to find.0      /* Open the pool file */      call OpenFile find.i, "read"      if RESULT \= 0 then          RETURN MakeSTAFResult(STAFError.!FileOpenError, find.i)      /* Read and validate pool file version */      thisPoolFileVersion = LINEIN(find.i)      if thisPoolFileVersion \= 0 then      do          RETURN MakeSTAFResult(STAFPoolError.!PoolFileVersionError,,                                thisPoolFileVersion)      end      /* Read main pool data */      call VAL 'POOL.'i'.!Name', LINEIN(find.i)      call VAL 'POOL.'i'.!Description', LINEIN(find.i)      call VAL 'POOL.'i'.!Request.0', 0      /* Read the pool entries */      do j = 1 while LINES(find.i)          call VAL 'POOL.'i'.!Resource.'j'.!Entry', LINEIN(find.i)          call VAL 'POOL.'i'.!Resource.'j'.!Owner', ';Available'      end      call VAL 'POOL.'i'.!Resource.0', j - 1      /* Close the file */      call STREAM find.i, 'C', 'CLOSE'  end  /* do for each pool */  /* Set number of pools */  call VAL 'POOL.0', i - 1  RETURN MakeSTAFResult(STAFError.!Ok)/* End of STAFServiceInit *//******************************************************************************//* STAFServiceAcceptRequest - Handles a service request from STAF             *//*                                                                            *//* Accepts: The name of this service                                          *//*          The name of the this machine                                      *//*          The name of the client machine                                    *//*          The effective name of the client machine                          *//*          The trust level of the client machine                             *//*          The registered name of the originating process                    *//*          The handle of the originating process                             *//*          The actual request string                                         *//*                                                                            *//* Returns: 0 , on success                                                    *//*          >0, otherwise                                                     *//******************************************************************************/STAFServiceAcceptRequest:  parse arg serviceName, thisMachine, orgMachineLong, orgMachine, trustLevel,,            orgName, orgHandle, request  version = "1.11"  poolFileVersion = 0  ext = '.rpl'  self = "STAF/Service/"serviceName  mutexSemName = self"/Mutex"  eventSemName = self"/Event"  clientMachine = orgMachineLong    /* For ResolveVariable: */  origHandle = orgHandle            /* For ResolveVariable: */  if request = '' then      RETURN MakeSTAFResult(STAFError.!InvalidRequestString)  /* Register with STAF */  call STAFRegister "STAF/Service/"serviceName  if RESULT \= 0 then      RETURN MakeSTAFResult(STAFError.!STAFRegistrationError, RESULT)  /* Resolve STAF Variables */  call ResolveStandardVariables  /* Throw away untrusted clients immediately */  if trustLevel = 0 then      RETURN MakeSTAFResult(STAFError.!AccessDenied)  /* Initialize parser and parse the request */  call InitResParser request  call ParseString request, "errorBuffer"  if RESULT \= 0 then RETURN MakeSTAFResult(RESULT, errorBuffer)  mainCommand = TRANSLATE(WORD(request, 1))  select      when mainCommand = "VERSION" then      do          if trustLevel < 1 then              RETURN MakeSTAFResult(STAFError.!AccessDenied)          RETURN MakeSTAFResult(STAFError.!Ok, version)      end      when mainCommand = "CREATE" then RETURN HandleCreate()      when mainCommand = "DELETE" then RETURN HandleDelete()      when mainCommand = "QUERY" then RETURN HandleQuery()      when mainCommand = "REQUEST" then RETURN HandleRequest()      when mainCommand = "ADD" then RETURN HandleAdd()      when mainCommand = "REMOVE" then RETURN HandleRemove()      when mainCommand = "RELEASE" then RETURN HandleRelease()      when mainCommand = "LIST" then RETURN HandleList()      when mainCommand = "HELP" then RETURN HandleHelp()      otherwise RETURN MakeSTAFResult(STAFError.!InvalidRequestString)  end  RETURN MakeSTAFResult(STAFError.!UnknownError)/* End of STAFServiceAcceptRequest *//****************************************************************************//* STAFServiceTerm - Terminates the service                                 *//*                                                                          *//* Accepts: The name of this service                                        *//* Returns: 0                                                               *//****************************************************************************/STAFServiceTerm:    parse arg serviceName    RETURN MakeSTAFResult(STAFError.!Ok)/* End of STAFServiceTerm *//******************************************************************************//*                   STAFPool Function Definitions                            *//******************************************************************************//****************************************************************************//* InitResParser - Defines the syntax of each request type for the Parser   *//*                                                                          *//* Accepts: The request                                                     *//*                                                                          *//* Returns: 0                                                               *//****************************************************************************/InitResParser:  parse arg IRP_Request  IRP_MainCommand = TRANSLATE(WORD(IRP_Request, 1))  /* Initialize the Parser options for each request type */  call InitParser  call AddOptionGroup "CREATE DELETE QUERY REQUEST ADD REMOVE RELEASE LIST",                      "HELP VERSION", 1, 1  select      when IRP_MainCommand = "CREATE" then      do          call AddOption "CREATE", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "DESCRIPTION", 1, "YES"          call AddOptionNeed "CREATE", "POOL"          call AddOptionNeed "CREATE", "DESCRIPTION"      end      when IRP_MainCommand = "DELETE" then      do          call AddOption "DELETE", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "CONFIRM", 1, "NO"          call AddOption "FORCE", 0, "NO"          call AddOptionNeed "DELETE", "POOL"          call AddOptionNeed "DELETE", "CONFIRM"      end      when IRP_MainCommand = "QUERY" then      do          call AddOption "QUERY", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOptionNeed "QUERY", "POOL"      end      when IRP_MainCommand = "REQUEST" then      do          call AddOption "REQUEST", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "FIRST", 0, "NO"          call AddOption "RANDOM", 0, "NO"          call AddOptionGroup "FIRST RANDOM", 0, 1          call AddOptionNeed "REQUEST", "POOL"          call AddOption "TIMEOUT", 0, "YES"      end      when IRP_MainCommand = "ADD" then      do          call AddOption "ADD", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "ENTRY", 0, "YES"          call AddOptionNeed "ADD", "POOL"          call AddOptionNeed "ADD", "ENTRY"      end      when IRP_MainCommand = "REMOVE" then      do          call AddOption "REMOVE", 1, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "ENTRY", 0, "YES"          call AddOption "CONFIRM", 1, "NO"          call AddOptionNeed "REMOVE", "POOL"          call AddOptionNeed "REMOVE", "ENTRY"          call AddOptionNeed "REMOVE", "CONFIRM"          call AddOption "FORCE", 0, "NO"      end      when IRP_MainCommand = "RELEASE" then      do          call AddOption "RELEASE", 1, "NO"          call AddOption "FORCE", 0, "NO"          call AddOption "POOL", 1, "YES"          call AddOption "ENTRY", 1, "YES"          call AddOptionNeed "RELEASE", "POOL"          call AddOptionNeed "RELEASE", "ENTRY"      end      when IRP_MainCommand = "LIST" then call AddOption "LIST", 1, "NO"      when IRP_MainCommand = "HELP" then call AddOption "HELP", 1, "NO"      when IRP_MainCommand = "VERSION" then call AddOption "VERSION", 1, "NO"      otherwise NOP  end  /* select on type */  RETURN 0/* End of InitResParser *//****************************************************************************//* RequestMutexSem - Gets a STAF mutex sem                                  *//*                                                                          *//* Accepts: No parameters                                                   *//*                                                                          *//* Returns: 0 , if no errors encountered                                    *//*          STAFExit data, if an error occurs                               *//****************************************************************************/RequestMutexSem:  STAFRC = STAFSubmit("LOCAL", "SEM", "MUTEX" mutexSemName "REQUEST")  if STAFRC \= 0 then RETURN MakeSTAFResult(STAFRC, STAFResult)  RETURN 0/* End of RequestMutexSem *//****************************************************************************//* ReleaseMutexSem - Gives back the mutex sem to STAF                     *//*                                                                          *//* Accepts: No parameters                                                   *//*                                                                          *//* Returns: 0 , if no errors encountered                                    *//*          STAFExit data, if an error occurs                               *//****************************************************************************/ReleaseMutexSem:  STAFRC = STAFSubmit("LOCAL", "SEM", "MUTEX" mutexSemName "RELEASE")  if STAFRC \= 0 then RETURN MakeSTAFResult(STAFRC, STAFResult)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -