[OPUS]

File_pstat_lock - Opus_lock object for file name-based PSTAT's.


Availability:

This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here

Constructors:
File_pstat_lock( )
~File_pstat_lock( )

Methods:
assign( ) sets the target file
lock( ) locks the target file
release( ) releases the lock
operator==( ) tests locks for equality
get_target( ) gets copy of locked PSTAT file as a File_pstat object

Description

This class manages lock files for PSTAT entries that are stored on the file system. A masked version of the target file name is stored in a subdirectory of the PSTAT blackboard directory and serves as the lock. The mask pads all fields except the unique, identifying fields in each entry (the Pid and Node fields). Because the mask does not contain all of the information in the target PSTAT file name, a copy of the locked file name at the time the lock is obtained is maintained by this object for reference.

Derived from

Pstat_lock, private Opus_lock_file

See Also:


File_pstat_lock::File_pstat_lock - The File_pstat_lock object constructor.

Synopsis


File_pstat_lock::File_pstat_lock() : locked_ent(0)

File_pstat_lock::File_pstat_lock(
                                 const File_pstat* ent,  // I - PSTAT file
                                                         //     to lock
                                 const std::string& dir)      // I - directory
                                                         //     containing
                                                         //     the PSTAT
                                                         //     files

Description

The constructor creates an Opus_lock_file object for the indicated PSTAT file, if supplied.

Exceptions Thrown

Bad_val<string> - if the string does not appear to be a directory specification or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if a problem occurs determining the current working directory; Io_error.arg contains the value of errno
Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument
Bad_val<string> - if the extension prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Bad_val<string> - if dangle prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if an IO error occurs creation of the lock directory; Io_error.arg contains the value of errno
Bad_val<File_pstat*> - if the first argument is null; Bad_val.arg points to the first argument


File_pstat_lock::~File_pstat_lock - The File_pstat_lock object destructor.

Synopsis


File_pstat_lock::~File_pstat_lock()

Description

The destructor destroys the object and deletes its internal copy of the target File_pstat object.

Exceptions Thrown

none


File_pstat_lock::lock - Attempt to lock the PSTAT file.

Synopsis


void File_pstat_lock::lock()

Description

An attempt is made to lock the target up to three times.

Exceptions Thrown

Locked<string> - if the target file is locked already; Locked.arg contains the target name
Io_error<int> - if an IO error occurs during the lock attempt; Io_error.arg contains the value of errno
Bad_val<string> - if the stretch cannot be resolved; Bad_val.arg contains the stretched file name
Bad_val<vector<string>> - if the calling arguments are incorrect; Bad_val.arg is a vector containing the calling arguments
Io_error<int> - if the disk space check fails; Io_error.arg contains the value of errno
Bad_val<vector<string>> - if calling arguments are incorrect; Bad_val.arg is a vector containing the calling arguments
Exec<int> - if the subprocess spawn attempt fails; Exec.arg contains the return status from the spawn attemp
Bad_val<string> - if the string does not appear to be a directory specification or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if a problem occurs determining the current working directory; Io_error.arg contains the value of errno
Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument
Bad_val<string> - if the extension prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Bad_val<string> - if dangle prefix is not present or invalid characters are present; Bad_val.arg contains the calling argument
Io_error<int> - if an IO error occurs creation of the lock directory; Io_error.arg contains the value of errno


File_pstat_lock::release - Release lock on PSTAT file.

Synopsis


void File_pstat_lock::release()

Description

This method deletes the lock file, if one is present and the file is locked.

Exceptions Thrown

Io_error<int> - if an IO error occurs during delete; Io_error.arg contains the value of errno


File_pstat_lock::operator== - Compare the File_pstat_lock object with another.

Synopsis


bool File_pstat_lock::operator==(
                                 const Opus_lock* ol) // I - lock to compare
                                                      //     to
                                 const

Description

This operator compares the object with the File_pstat_lock object argument. Two File_pstat_lock objects are equal if the lock file names are identical.

***Note that a pointer (not a reference) to the object with which the comparison is to be made is required.

Returns

    true  - if the locks are identical

false - if the locks are not identical

Exceptions Thrown

none


File_pstat_lock::get_target - Get a copy of the target PSTAT file as a File_pstat object.

Synopsis


Pstat* File_pstat_lock::get_target() const

Description

A copy of the locked File_pstat object is fetched off disk (if necessary), and a copy is constructed off the heap and returned to the caller. The target must be locked prior to calling this method. The client should delete the new object when it is no longer needed.

Returns

    The File_pstat object that is the target of this lock.

Exceptions Thrown

Not_ready<void*> - if the target has not been locked; Not_ready.arg points to null.
Io_error<const char*> - if an IO error occurs while searching for the file; Io_error.arg contains the error message


OPUS API index · STScI Home Page · Search · Topics · Index

Copyright © 1997-2000 The Association of Universities for Research in Astronomy, Inc. All Rights Reserved.


For more information, contact opushelp@stsci.edu

Last modified: 25 April 2000