技术开发 频道

ClearQuest V7.1从乐观锁定到悲观锁定

3. 补充

    实际上,锁定一条或多条记录,除了上面讲到的建立一个Base的行为Lock以外,也可以类似与Unlock行为一样,建立一个类型为RECORD_SCRIPT_ALIAS的Lock行为,这样做可以方便用户自己决定是否锁定记录。

    感兴趣的朋友还可以通过findrecordlocks.pl 进一步找到当前被锁记录的一些相关信息,该脚本在ClearQuest V7.1的安装目录下  \IBM\RationalSDLC\ClearQuest\,运行:

    cqperl findrecordlocks.pl  [-dbset <dbset_name>]
                               [-database <user_database>]
                               <clearquest_login>
                               <clearquest_password>
                               { <record_type_list> | -all }
                               [-unlock]
                               [-scan <interval>]
                               [-timeout <interval>]
                               [-times <times>]
                               [-loglevel <error|info|verbose>]


    以上面的记录SAMPL00000001为例,Alice锁住了记录SAMPL00000001,运行:

    cqperl "F:\Program Files\IBM\RationalSDLC\ClearQuest\findrecordlocks.pl"-dbset ss admin "" Defect,看看结果是不是如实际操作的一样。

4. 附录

    类型为RECORD_SCRIPT_ALIAS的Lock行为的perl脚本

    sub Defect_LockRecord {
        my($result);
        my($param) = @_;
        # record type name is Defect

        if (ref ($param) eq "CQEventObject") {
            # add your CQEventObject parameter handling code here
        } elsif (ref (\$param) eq "SCALAR") {
            # add your scalar parameter handling code here
            # The Web clients support scalar paramter type only,
            # so the hook code added in the above section, needs to be duplicated here
        } else {
            # add your handling code for other type parameters here, for example:
            # die("Unknown parameter type");
    }
    $entity->LockRecord(0);
        return $result;
    }

5.结束语

    本文介绍了ClearQuest V7.1中的记录锁定机制,重点让大家了解了两种锁定机制及如何使用"悲观锁定。"

0
相关文章