Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Follow the PBS Pro Design Document Guidelines.
Link to discussion on Developer Forum: <http://community.pbspro.org/t/design-for-refactoring-pbs-database-code/2009>
Link to issue: <issue link if available>
Link to pull request: <PR link if available>

For easy maintainability, current database-related code within the PBS server needs to be refactored into a separate pluggable dynamic library. And this design page discusses the APIs using which PBS server can talk to Libdb, the database dynamic library using which PBS can talk to the database. Another motivation behind this refactoring is the added advantage of moving to any database without having to do major code changes within PBS itself.

1.1. Files: List of files PBS will need to have database support.

PBS_EXEC/lib/libdb.so

Description: This dynamic library will have the functionality for the PBS server to access the database.

...

Code Block
struct pbs_db_attr_list {
	int attr_count;	     /* attribute count */
	pbs_list_head attrs; /* ptr to attr_info structure */
};
typedef struct pbs_db_attr_list pbs_db_attr_list_t;

1.2. APIs from libdb.so

1.2.1. PBS Objects: Libdb APIs can work with below mentioned PBS objects.

PBS_DB_JOB: To save and update PBS job objects

...

PBS_DB_MOMINFO_TIME: To save/update PBS mominfo_time

1.2.2. pbs_db_connect

Description: Setup a persistent database connection for further use by APIs which will work on PBS objects. On success return the connection information.

...

!0: On connection failure.

1.2.3. pbs_db_disconnect

Description: Disconnect the PBS server from a database connection.

...

0 - for successful database disconnect.

-1 - for failure

1.2.4. pbs_db_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

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
0 - 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.

...

0 - Success

Non zero - On Failure

1.2.9. pbs_start_db

Description: This API can be used to start the database instance.

...

0 - Success

Non zero - On Failure

1.2.10. pbs_stop_db

Description: This API can be used to stop the database instance.

...

0 - Success

Non zero - On Failure

1.2.11. pbs_status_db

Description: This API can be used to check if the database instance is running.

...

0 - Database is running on the localhost.

-1 - On Failure

1.2.12. pbs_db_password

Description: This API can be used to change the database user and password for the database instance.

...

0 - Success

Non zero - On Failure

1.2.12. pbs_db_get_errmsg

Description: This API can be used to get the error messages from the database library. When any of the above-listed APIs fail, this API can be used to get the error message from libdb.

...