...
pbs_db_conn_t: Structure used to maintain the database connection information. All elements of this structure are generic and are not bound to any particular database.
struct pbs_db_connection {
void conn_db_handle; / opaque database handle */
char conn_info; / database connect string */
char conn_host; / host */
char conn_port; / port number /
int conn_timeout; / connection timeout (async connects) /
int conn_state; / connected? /
int conn_internal_state; / internal connection state (async connects) /
int conn_db_state; / db up? down? starting? (async connects) /
time_t conn_connect_time; / when was connection initiated /
int conn_trx_nest; / incr/decr with each begin/end trx /
int conn_trx_rollback; / rollback flag in case of nested trx /
int conn_result_format; / 0 - text, 1 - binary /
int conn_trx_async; / 1 - async, 0 - sync, one-shot reset */
void conn_db_err; / opaque database error store */
void conn_data; / any other db specific data */
void conn_resultset; / point to any results data /
char conn_sql[MAX_SQL_LENGTH]; / sql buffer */
};
typedef struct pbs_db_connection pbs_db_conn_t;
pbs_db_obj_info_t: Wrapper object structure. It contains a pointer to one of the several database structures. Most of the database manipulation/query functions take this structure as a parameter. Depending on the contained structure type, an appropriate internal database manipulation/query function is eventually called. This allows keeping the interface simpler and generic.
struct pbs_db_obj_info {
int pbs_db_obj_type; /* identifies the contained object type */
union {
pbs_db_job_info_t *pbs_db_job;
pbs_db_jobscr_info_t *pbs_db_jobscr;
pbs_db_resv_info_t *pbs_db_resv;
pbs_db_svr_info_t *pbs_db_svr;
pbs_db_que_info_t *pbs_db_que;
pbs_db_node_info_t *pbs_db_node;
pbs_db_sched_info_t *pbs_db_sched;
pbs_db_mominfo_time_t *pbs_db_mominfo_tm;
} pbs_db_un;
};
typedef struct pbs_db_obj_info pbs_db_obj_info_t;
Code Block |
---|
struct pbs_db_job_info { char ji_jobid[PBS_MAXSVRJOBID + 1]; /* job identifier */ INTEGER ji_state; /* INTEGERernal copy of state */ INTEGER ji_substate; /* job sub-state */ INTEGER ji_svrflags; /* server flags */ INTEGER ji_numattr; /* not used */ INTEGER ji_ordering; /* special scheduling ordering */ INTEGER ji_priority; /* INTEGERernal priority */ BIGINT ji_stime; /* time job started execution */ BIGINT ji_endtBdry; /* estimate upper bound on end time */ char ji_queue[PBS_MAXQUEUENAME + 1]; /* name of current queue */ char ji_destin[PBS_MAXROUTEDEST + 1]; /* dest from qmove/route */ INTEGER ji_un_type; INTEGER ji_momaddr; /* host addr of Server */ INTEGER ji_momport; /* port # */ INTEGER ji_exitstat; /* job exit status from MOM */ BIGINT ji_quetime; /* time entered queue */ BIGINT ji_rteretry; /* route retry time */ INTEGER ji_fromsock; /* socket job coming over */ BIGINT ji_fromaddr; /* host job coming from */ char ji_4jid[8]; char ji_4ash[8]; INTEGER ji_credtype; INTEGER ji_qrank; BIGINT ji_savetm; BIGINT ji_creattm; pbs_db_attr_list_t attr_list; /* list of attributes */ }; typedef struct pbs_db_job_info pbs_db_job_info_t; |
pbs_db_query_options_t: Structure used to pass database query options to database functions. Flags field can be used to pass any flags to a query function. Timestamp field can be used to pass a timestamp, to return rows that have a modification timestamp newer (more recent) than the timestamp passed. (Basically to return rows that have been modified since a point of time)
...
(pbs_db_conn_t *) pbs_db_connect(char *pbs_datads_service_host, int pbs_data_serviceds_port, int timeout, int char *failcode, char *err_msg)
Parameters:
pbs_data_service_host[in]: Hostname information where the database is running.
...
timeout[in]: Timeout in seconds before the API will return if it is taking too long to connect.failcode[out]: Output failure code if any. Used to fetch database error messages using get_db_errmsg().
err_msg[out]: Connection/system messages generated by libdb. On connection failure out error messages.
...
1.2.3. pbs_db_disconnect
Description: Disconnect PBS server from a database connection and stop the database instance.
Signature:
int pbs_db_disconnect(pbs_db_conn_t *conn, int failcode, char **dberr_msg)
Parameters:
conn[in]: Connection structure with connection handler to the database which was created by pbs_db_connection.
failcode[out]: Output failure code if any.
dberr_msg[out] : Connection logs/messages generated by libdb. On connecttion failure out error messages.
...
0 for successful database disconnect.
1 for failure.
1.2.4
...
Description: Translate the database error code to an error message.
Signature:
void get_db_errmsg(int err_code, char **err_msg)
Parameters:
...
.
...
err_msg[out]: The translated error message.
...
pbs
...
_db
...
Description: Checks whether the database is down, and if so starts up the database in asynchronous mode.
Signature:
...
_
...
Parameters:
pbs_data_service_host[in]: Hostname information where the database will be running.
pbs_data_service_port[in]: Port number information where the database will be running.
err_msg[out]: Connection/system messages generated during database startup.
Returns: Failure/Status code
1 - Failed to start the data service
1 - Database is down
2 - Database is starting
3 - Database is up
1.2.6. pbs_stop_db
Description: Stop the database if up whether the database is down. Try to stop till not successful with incremental delay.
Signature:
int pbs_stop_db(char *pbs_data_service_host, int pbs_data_service_port, int retry_attempt, int delay, char **err_msg)
Parameters:
pbs_data_service_host[in]: Hostname information where the database will be running.
pbs_data_service_port[in]: Port number information where the database will be running.
retry_attempt[in]: Number of retires to stop the database before returning.
delay[int]: Delay between retry attempts to stop the database.
err_msg[out]: Connection/system messages generated during database stop.
Returns: Failure/Status code
1 - Failed to stop the data service.
0 - Success
1.2.7. pbs_status_db
Description: Checks whether the database is running.
Signature:
int pbs_status_db(char *pbs_data_service_host, int pbs_data_service_port, char **err_msg)
Parameters:
pbs_data_service_host[in] : Hostname information where the database is running.
pbs_data_service_port[in]: Port number information where the database is running.
err_msg[out]: Connection/system messages generated during database status check.
Returns: Failure/Status code
1 - Failed to check the data service status.
1 - Data service is down.
2 - Data service is starting.
3 - Data service is up.
4 - Data service is running on a different host.
...
save_obj
Description: PBS can use this API to save any of the PBS Objects listed above to the database. Save operation can be an insert or update.
...
1 - Execution succeeded but the statement did not affect any rows.
1.2.
...
5. pbs_db_delete_obj
Description: This API lets PBS delete PBS objects PBS_DB_JOB, PBS_DB_RESV, PBS_DB_NODE, PBS_DB_QUE and PBS_DB_SCHED from the database.
...
1 - Success but no rows deleted
1.2.
...
6. pbs_db_load_obj
Description: This API lets PBS load objects data from the database. This API can work with any of the PBS objects.
Signature:
...
0 - Success
1 - Success but no rows loaded
1.2.
...
7. pbs_db_find_obj
Description: This API can be used to find/search PBS objects PBS_DB_JOB, PBS_DB_RESV, PBS_DB_NODE, PBS_DB_QUE and PBS_DB_SCHED in the database. This API takes a pointer to the callback function as an argument that will work on the records returned from the database based on the query specified by the PBS.
...
0 - Success
1 - Success but no rows found
1.2.
...
8. pbs_db_del_attr_obj
Description: This API can be used to delete attributes of a PBS object.
...