SYS.Lock
Class SYS.Lock Extends %SYSTEM.Help [ Abstract, Final, SqlTableName = "", StorageStrategy = "", System = 4 ]
Interface to remove locks and query and adjust lock table parameters.
Use %SYS.LockQuery to query the contents of the lock table.
Methods
ClientSysNameToSysNum
ClassMethod ClientSysNameToSysNum(SysName As %String = "") As %Integer [ Internal ]
Convert a remote client system name to internal system number. This is used by LOCKTAB as well as by this class.
ClientSysNumToSysName
ClassMethod ClientSysNumToSysName(SysNum As %Integer = 0) As %String [ Internal ]
Convert a remote client system number to client system name. This is used by LOCKTAB as well as by this class.
DeleteAllLocks
ClassMethod DeleteAllLocks(id As %String = "") As %Status
Remove all locks from lock table.
This returns number of locks been removed from lock table.
The argument 'id' specified the category of lock entries to be deleted. See the 'Filter Specification' at the top of %SYS.LockQuery.
Example: // Delete all locks in lock table. Set rc=##Class(SYS.Lock).DeleteAllLocks() // Delete locks owned by process 2004. Set rc=##Class(SYS.Lock).DeleteAllLocks(2004) // Delete locks owned by remote client system named 'SystemA'. Set rc=##Class(SYS.Lock).DeleteAllLocks("CSystemA") // Delete locks owned by remote client systems. Set rc=##Class(SYS.Lock).DeleteAllLocks("N") // Delete locks owned by remote DDP clients. Set rc=##Class(SYS.Lock).DeleteAllLocks("NDDP")
DeleteOneLock
ClassMethod DeleteOneLock(LockRef As %String, id As %String = "", LockRefType As %Integer = 0) As %Integer
Delete One Lock item in the lock table.
This returns 1 if the lock delete operation succeeds, otherwise returns 0.
- 'LockRef' - could be a lock reference string or a DelKey depends on the 'LockRefType' parameter.
- 'id' - the owner of the lock entry to be deleted. See the 'Filter Specification' at the top of %SYS.LockQuery for the 'id'.
- 'LockRefType' - 0: the 'LockRef' is lock reference string, this is the default value. 1: the 'LockRef' is the DelKey for deleting the lock entry. The 'DelKey' is usually used when the lock's 'DelKey' value is retrieved from a query.
Example: // Delete ^|"^^c:\intersystemsdb\mgr\user"|a(1) lock. Set rc=##Class(SYS.Lock).DeleteOneLock("^|""^^c:\intersystemsdb\mgr\user""|a(1)") // Delete ^|"^^c:\intersystemdb\mgr\user"|a(1) lock owned by process 2004. Set rc=##Class(SYS.Lock).DeleteOneLock("^|""^^c:\intersystemsdb\mgr\user""|a(1)",2004) // Look through the lock table and remove all locks // to the directory with System File Number equal 2. Set Rset=##class(%ResultSet).%New("%SYS.LockQuery:List") Do Rset.Execute("") While Rset.Next() { If Rset.Data("Sfn")=2 { s rc=##Class(SYS.Lock).DeleteOneLock(Rset.Data("DelKey"),"",1) } }
GetLockSpaceInfo
ClassMethod GetLockSpaceInfo() As %String
Get lock space information.
This method returns three numbers and they are separated by ',' in the following format:
"AvailableSpace,UsableSpace,UsedSpace"
The amounts are number of bytes.
AvailableSpace: Available memory for lock, it is total configured lock memory minus UsedSpace.
UsableSpace: Estimated size of memory could be used; some of the AvailableSpace is reserved for each process. They include two LRB, one LHB and one lock reference string. They could not be used by other processes until the job released it to the free pool. So the UsableSpace is less than the AvailableSpace.
UsedSpace: Currently used memory space by lock. Note that the value of UsedSpace may be temporarily inaccurate when the system is busy, such as with heavy lock activity on many jobs; this may include having a negative value. You may need to run GetLockSpaceInfo() repeatedly to obtain a more accurate value.
GetLockSysNameTable
ClassMethod GetLockSysNameTable(ByRef SYSTEMS As %String, ByRef BYTES2 As %String, ByRef SYSN2 As %String) As %Status [ Internal, Private ]
Get lock system number and name translation table.
GetMaxLockTableSize
ClassMethod GetMaxLockTableSize() As %Integer
Get the maximum number of bytes been configured for lock system to use.
The value returned is in number of bytes.
GetNodeInfo
ClassMethod GetNodeInfo() As %String
Get node information.
This method returns the node information of current system.
This returns the following information who are separated by $C(0) in sequence.
- Node Name - node name of the current system.
- Joined Cluster - 1: this system is a cluster member, 0: otherwise.
- Cluster Master - 1: this system is a cluster master node, 0: otherwise.
- Cluster Master Node Name - The Node Name of the cluster master node.
SetMaxLockTableSize
ClassMethod SetMaxLockTableSize(NewSize As %Integer) As %Integer
Set new maximum number of bytes for lock system to use.
The 'NewSize' is in bytes, it will be round up to 64 KB.
TranslateID
ClassMethod TranslateID(id As %String) As %String [ Internal, Private ]
Translate the input ID string and return three values. 1) pid : The process ID, 0 - all processes. 2) clin: The remote client system number, -1 - all remote system. 3) ntype: The network protocol from remote client, 100 - all network protocol. 4) svrn: The remote server system number, -1 - all remote system.