%SYS
Lock Class Reference

Interface to remove locks and query and adjust lock table parameters. More...

Inheritance diagram for Lock:
Collaboration diagram for Lock:

Static Public Member Functions

_.Library.Status DeleteAllLocks (_.Library.String id)
 Interface to remove locks and query and adjust lock table parameters. More...
 
_.Library.Integer DeleteOneLock (_.Library.String LockRef, _.Library.String id, _.Library.Integer LockRefType)
 Delete One Lock item in the lock table. More...
 
_.Library.String GetLockSpaceInfo ()
 Get lock space information. More...
 
_.Library.Integer GetMaxLockTableSize ()
 Get the maximum number of bytes been configured for lock system to use. More...
 
_.Library.String GetNodeInfo ()
 Get node information. More...
 
_.Library.Integer SetMaxLockTableSize (_.Library.Integer NewSize)
 Set new maximum number of bytes for lock system to use. More...
 

Detailed Description

Interface to remove locks and query and adjust lock table parameters.


Use <class>SYS.LockQuery</class> to query the contents of the lock table.

Member Function Documentation

◆ DeleteAllLocks()

_.Library.Status DeleteAllLocks ( _.Library.String  id)
static

Interface to remove locks and query and adjust lock table parameters.


Use <class>SYS.LockQuery</class> to query the contents of the lock table.

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 <class>SYS.LockQuery</class>.
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()

_.Library.Integer DeleteOneLock ( _.Library.String  LockRef,
_.Library.String  id,
_.Library.Integer  LockRefType 
)
static

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 <class>SYS.LockQuery</class> 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()

_.Library.String GetLockSpaceInfo ( )
static

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 <method>GetLockSpaceInfo()</method> repeatedly to obtain a more accurate value.

◆ GetMaxLockTableSize()

_.Library.Integer GetMaxLockTableSize ( )
static

Get the maximum number of bytes been configured for lock system to use.


The value returned is in number of bytes.

◆ GetNodeInfo()

_.Library.String GetNodeInfo ( )
static

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.

1) Node Name - node name of the current system.
2) Joined Cluster - 1: this system is a cluster member, 0: otherwise.
3) Cluster Master - 1: this system is a cluster master node, 0: otherwise.
4) Cluster Master Node Name - The Node Name of the cluster master node.

◆ SetMaxLockTableSize()

_.Library.Integer SetMaxLockTableSize ( _.Library.Integer  NewSize)
static

Set new maximum number of bytes for lock system to use.


The 'NewSize' is in bytes, it will be round up to 64 KB.