All the functions in this facility are members of the class os_dbutil. Call the following function before using any other members of os_dbutil:
static void os_dbutil::initialize();You only need to call this function once in each application.
static void chgrp( const char *pathname, const char *gname );Changes the primary group of the rawfs directory or database whose name is pathname. gname is the name of the new group.This function does not check for transaction consistency.
See oschgrp in ObjectStore Management.
static void chmod( const char *pathname, const os_unsigned_int32 mode );Changes the protections on the rawfs database or directory whose name is pathname. mode specifies the new protections. This function does not check for transaction consistency
See oschmod in ObjectStore Management.
static void chown( const char *pathname, const char *uname );Changes the owner of the rawfs directory or database whose name is pathname. uname is the user name of the new owner. This function does not check for transaction consistency
See oschown in ObjectStore Management.
See Chapter 10, Database Utility API, in ObjectStore Advanced C++ API User Guide.
os_dbutil::close_all_server_connections()
static void close_all_server_connections();Closes all connections the application has to ObjectStore Servers.
static void close_server_connection(const char *hostname);Closes the connection the application has to the ObjectStore Server running on the machine named hostname.
static char *cmgr_remove_file( const char *hostname, os_int32 cm_version_number );Makes the Cache Manager on the machine with the specified hostname delete all the cache and commseg files that are not in use by any client. The argument cm_version_number must match the Cache Manager's version number. Returns a pointer to the result message string.
See oscmrf in ObjectStore Management.
static char *cmgr_shutdown( const char *hostname, os_int32 cm_version_number );Shuts down the Cache Manager running on the machine with the specified hostname. The argument cm_version_number must match the Cache Manager's version number. Returns a pointer to the result message string.
See oscmshtd in ObjectStore Management.
static void cmgr_stat( const char *hostname, os_int32 cm_version_number, os_cmgr_stat *cmstat_data );Gets information for the Cache Manager on the machine with the specified hostname. The argument cm_version_number must match the Cache Manager's version number.
The constructor sets struct_version to the value of os_free_blocks_version in the dbutil.hh file included by your application. If this version is different from that used by the library, err_misc is signaled. The constructor initializes all other members to 0.
os_cmgr_stat_client public data members
os_cmgr_stat_client has the following public data members:
os_cmgr_stat_svr public data members
os_cmgr_stat_svr has the following public data members:
os_unsigned_int32 | struct_version; |
char | *host_name; |
os_int32 | client_pid; |
char | *status_str; |
os_cmgr_stat_file_usage public data members
os_cmgr_stat_file_usage has the following public data members:
os_unsigned_int32 | struct_version; |
char | *file_name; |
os_unsigned_int32 | file_length; |
os_boolean | is_free; |
See oscmstat in ObjectStore Management for additional information.
os_dbutil::compare_schemas()
static os_boolean compare_schemas( const os_database* db1, const os_database* db2, os_boolean verbose = 1 );Compares the schemas of db1 and db2. Returns nonzero if the schemas are incompatible, 0 otherwise. Each database can contain an application schema, a compilation schema, or a database schema. If the database contains a database schema, it can be local or remote.
If verbose is nonzero, the function issues a message to the default output describing any incompatibility.
See osscheq in ObjectStore Management.
static os_boolean copy_database( const char *src_database_name, const char *dest_database_name );Copies the database named src_database_name and names the copy dest_database_name. No transaction can be in progress. The source database cannot be in use. If there is already a database named dest_database_name, it is silently overwritten. Returns 0 for success, 1 if per-segment access control information has been changed during copy (which can happen when copying a rawfs database to a file database, since file databases do not have separate segment-level protections).
See oscp in ObjectStore Management.
static void disk_free( const char *hostname, os_free_blocks *blocks );Gets disk space usage in the rawfs managed by the Server on the machine named hostname. blocks points to an instance of os_free_blocks allocated by the caller, using the zero-argument constructor.
os_unsigned_int32 | struct_version; |
os_unsigned_int32 | free_blocks; |
os_unsigned_int32 | file_system_size; |
os_unsigned_int32 | used_blocks; |
disk_free() sets the values of these data members for the instance of os_free_blocks pointed to by the argument blocks.
os_dbutil::expand_global()
static os_char_p *expand_global( char const *glob_path, os_unsigned_int32 &n_entries );Returns an array of pointers to rawfs pathnames matching glob_path by expanding glob_path's wildcards (*, ?, {}, and []). n_entries is set to refer to the number of pathnames returned. It is the caller's responsibility to delete the array and pathnames when they are no longer needed.
See osglob in ObjectStore Management.
static char const* get_client_name();Returns the pointer last passed to set_client_name(). If there was no prior call to set_client_name(), 0 is returned. This function does not allocate any memory.
static os_unsigned_int32 get_sector_size();Returns 512, the size of a sector in bytes. Certain ObjectStore utilities report some of their results in numbers of sectors, and some Server parameters are specified in sectors. See ObjectStore Management.
static void initialize();Call this before using any other members of os_dbutil.
static os_rawfs_entry_p *list_directory( const char *path, os_unsigned_int32 &n_entries );Lists the contents of the rawfs directory named path. Returns an array of pointers to os_rawfs_entry_p objects. n_entries is set to the number of elements in the returned array. If path does not specify the location of a directory, err_not_a_directory is signaled. It is the caller's responsibility to delete the array and os_rawfs_entry_p objects when they are no longer needed.
See osls in ObjectStore Management.
static void make_link( const char *target_name, const char *link_name );Makes a rawfs soft link. target_name is the path pointed to by the link. link_name is the pathname of the link. Signals err_database_exists or err_directory_exists if link_name already points to an existing database or directory.
A rawfs can have symbolic links pointing within itself or to another Server's rawfs. The Server follows symbolic links within its rawfs for all os_dbutil members that pass pathname arguments, unless specified otherwise by a function's description; only os_dbutil::stat() can override this behavior. All members passing pathname arguments also follow cross-server links on the application side, unless specified otherwise by a function's description.
A rawfs symbolic link always has the ownership and the permissions of the parent directory.
See osln, rehost_link, and rehost_all_links in ObjectStore Management.
static void mkdir( const char *path, const os_unsigned_int32 mode, os_boolean create_missing_dirs = 0 );Makes a rawfs directory whose pathname is path. The new directory's protection is specified by mode. If create_missing_dirs is nonzero, creates the missing intermediate directories. Signals err_directory_not_found if create_missing_dirs is 0 and there are missing intermediate directories. Signals err_directory_exists if there is already a directory with the specified path. Signals err_database_exists if there is already a database with the specified path.
See osmkdir in ObjectStore Management.
static os_int32 ossize( const char *pathname, const os_size_options *options );Prints to standard output the size of the database whose name is pathname. options points to an instance of os_size_options allocated by the caller using the zero-argument constructor.
Each member corresponds to an option for the utility ossize. See ossize in ObjectStore Management.
os_dbutil::osverifydb()
static os_unsigned_int32 osverifydb( const char *dbname, os_verifydb_options* opt= 0 );Prints to standard output all pointers and references in the database named dbname. opt points to an instance of os_verify_db_options allocated by the caller using the zero-argument constructor. You must have called os_collection::initialize() and os_mop::initialize() prior to calling this function.
If OS_ _DBUTIL_NO_MVCC is set, this function opens the database for read only, rather than MVCC (the default).
Returns 0 for success, 1 for failure.
Upgrading databases created on 16K page size platforms
In releases prior to ObjectStore 5.1, there is a bug in our support of heterogeneous access to databases created on machines with a 16K page size: databases created on 16K page big-endian platforms cannot be accessed from small-endian platforms. Older databases might need to be upgraded. You can use the upgrade tool by means of the os_verifydb_options argument to the API os_dbutil::osverifydb() with os_verifydb_options::info_sector_tag_verify_opt set to the desired value:
class os_verifydb_options { public: ... enum info_sector_tag_verify_opt_enum { verify_skip = 0, /* do not verify info sector tag */ verify_report_only = 1, /* report only */ verify_upgrade = 2, /* upgrade info sector tag */ verify_skip_others = 4 /* skip other verifications */ } info_sector_tag_verify_opt ; ... }Valid os_verifydb_options::info_sector_tag_verify_opt values are:
verify_skip verify_report_only verify_upgrade verify_report_only | verify_skip_others verify_upgrade | verify_skip_othersSee also, osverifydb in ObjectStore Management.
static os_unsigned_int32 osverifydb_one_segment( const char *dbname, os_unsigned_int32 segment_number, os_unsigned_int32 starting_offset = 0, os_unsigned_int32 ending_offset = 0, os_verifydb_options *opt = 0 );Prints to standard output all pointers and references in segment segment_number in the database named dbname. The offset items specify the starting and ending offsets (in bytes) within the segment where verification is done. If starting_offset is not specified, it defaults to 0. This means verification starts at the beginning of the segment. Similarly, If ending_offset is not specified, it defaults to 0. This means verify to the end of the segment. opt points to an instance of os_verify_db_options allocated by the caller using the zero-argument constructor.
Returns 0 for success, 1 for failure. You must have called os_collection::initialize() and os_mop::initialize() prior to calling this function. If OS__DBUTIL_NO_MVCC is set, this function opens the database for read only, rather than MVCC (the default).
os_dbutil::osprmgc()
struct os_prmgc_options { os_boolean flag_quiet; // -q, default is false os_boolean flag_read_only; // -r, default is false os_boolean flag_one_segment; // -n, default is false os_unsigned_int32 one_segment_number; // the N in -n N os_prmgc_type prmgc_type; //-t default is remove_whole_ranges };This is particularly useful for databases with discriminant unions.
Both the command-line and embedded versions of the utility use
static void rehost_all_links( const char *server_host, const char *old_host, const char *new_host );Changes the hosts of specified rawfs links. server_host specifies the host containing the links to be changed. All links pointing to old_host are changed to point to new_host. On some operating systems, you must have special privileges to use this function.
See oschhost in ObjectStore Management.
static void rehost_link( const char *pathname, const char *new_host );Changes the host to which a rawfs link points. pathname must specify a symbolic link, otherwise err_not_a_link is signaled. new_host specifies the new Server host.
See oschhost in ObjectStore Management.
static void remove(char const *path);Removes the database or rawfs link with the specified name. If path names a link, the link is removed but the target of the link is not. If path names a directory, it is not removed. Signals err_not_a_database if path exists in a rawfs but is not a database. Signals err_file_error when a problem is reported by the Server host's file system. Signals err_file_not_local if the file is not local to this Server.
See osrm in ObjectStore Management.
static void rename( const char *source, const char *target );Renames the rawfs database or directory. source is the old name and target is the new name. Signals err_cross_server_rename if source and target are on different Servers. Signals err_invalid_rename if the operation makes a directory its own descendent. Signals err_database_exists if a database named target already exists. Signals err_directory_exists if a directory named target already exists.
See osmv in ObjectStore Management.
static void rmdir(const char *path);Removes the rawfs directory with the specified pathname. Signals err_directory_not_empty if the directory still contains databases. Signals err_not_a_directory if the argument does not specify a directory path.
See osrmdir in ObjectStore Management.
static char *set_application_schema_path( const char *executable_pathname, const char *database_pathname );Finds or sets an executable's application schema database. executable_pathname specifies the executable. database_pathname is either the new schema's pathname or 0. If database_pathname is 0, the function returns new storage containing the current pathname. If database_pathname is nonzero, the function returns 0.
See ossetasp in ObjectStore Management.
static void set_client_name(const char *name);Sets the client name string for message printing.
static os_rawfs_entry *stat( const char *path, const os_boolean b_chase_links = 1 );Gets information about a rawfs pathname. If b_chase_links is false and the path is a link, the Server does not follow it. The Server still follows intrarawfs links for the intermediate parts of the path.
Returns a pointer to an os_rawfs_entry to be destroyed by the caller, or 0 on error.
See ostest and osls in ObjectStore Management.
static os_boolean svr_checkpoint( const char *hostname );Makes the specified Server take a checkpoint asynchronously. Returns nonzero when successful, 0 or an exception on failure.
See ossvrchkpt in ObjectStore Management.
static os_boolean svr_client_kill( const char *server_host, os_int32 client_pid, const char *client_name, const char *client_hostname, os_boolean all, os_int32 &status );Kills one or all clients of the specified Server. hostname is the name of the machine running the Server.
client_pid is the process ID of the client to kill. client_name is the name of the client to kill. client_hostname is the name of the machine running the client to kill.
If all is 1, the other arguments except server_host are ignored, and all clients on the specified Server are killed.
status is set to -2 if a client was killed, 0 if no clients matched the specifications, 2 if multiple clients matched the specification. Any other value means that access was denied.
Returns 0 for failure and nonzero for success.
See ossvrclntkill in ObjectStore Management.
static char *svr_ping( const char *server_host, os_svr_ping_state &state );Determines whether an ObjectStore Server is running on the machine named server_host. The referent of state is set to one of the following global enumerators:
See ossvrping in ObjectStore Management.
static os_boolean svr_shutdown( const char *server_host );Shuts down the Server on the machine named server_host. Returns nonzero for success, 0 otherwise. On some operating systems, you must have special privileges to use this function.
See ossvrshtd in ObjectStore Management.
static void svr_stat( const char *server_host, os_unsigned_int32 request_bits, os_svr_stat *svrstat_data );Gets statistics for a Server's clients on server_host.
request_bits specifies what information is desired. Supply this argument by forming the bit-wise disjunction of zero or more of the following enumerators:
For each of the classes described below, the constructor sets struct_version to the value of os_free_blocks_version in the dbutil.hh file included by your application. If this version is different from that used by the library, err_misc is signaled. The constructor initializes all other members to 0.
os_dbutil::svr_stat(db->get_host_name(), os_svr_stat::get_svr_meter_samples, &svrstat) n_sent = svrstat.svr_meter_samples->n_notifies_sent; n_received = svrstat.svr_meter_samples->n_notifies_ received;
Set the pointer-valued members to point to classes you allocate using zero-argument constructors.
os_svr_stat_svr_header public data members
os_svr_stat_svr_header has the following public data members:
os_unsigned_int32 | struct_version; |
char* | os_release_name; |
os_unsigned_int32 | server_major_version; |
os_unsigned_int32 | server_minor_version; |
char* | compilation; |
os_svr_stat_svr_parameters public data members
os_svr_stat_svr_parameters has the following public data members:
os_svr_stat_svr_rusage public data members
os_svr_stat_svr_rusage has the following public data members:
The classes os_svr_stat_svr_meters and os_svr_stat_client_meters each have data members named n_notifies_sent and n_notifies_received. All four are of type os_unsigned_int32. They give the total number of notifications that have been received by the Server, and the number that have been sent by the Server, giving the total for the Server as a whole, and the total for each client.
os_svr_stat_svr_meters public data members
os_svr_stat_svr_meters has the following public data members:
os_svr_stat_client_info public data members
os_svr_stat_client_info has the following public data members:
os_unsigned_int32 | struct_version; |
os_svr_stat_client_process* | process; |
os_svr_stat_client_state* | state; |
os_svr_stat_client_meters* | meters; |
Set the pointer-valued members to point to classes you allocate using zero-argument constructors.
os_svr_stat_client_process public data members
os_svr_stat_client_process has the following public data members:
os_unsigned_int32 | struct_version; |
char* | host_name; |
os_unsigned_int32 | process_id; |
char* | client_name; |
os_unsigned_int32 | client_id; |
os_svr_stat_client_state public data members
os_svr_stat_client_state has the following public data members:
Data in locking_start_sector and locking_for_n_sectors is valid only when lock_state is OSSVRSTAT_CLIENT_STATE_WAITING_RANGE_READ_LOCK or OSSVRSTAT_CLIENT_STATE_WAITING_RANGE_WRITE_LOCK.
os_svr_stat_client_meters public data members
os_svr_stat_client_meters has the following public data members:
See ossvrstat and ossvrmtr in ObjectStore Management.
Updated: 03/31/98 17:25:09