Users' Guide to NetSolve V1.4: | ||
---|---|---|
Prev | Chapter 20. Distributed Storage Infrastructure (DSI) in NetSolve | Next |
The DSI APIs are modeled after the UNIX file manipulation commands (open, close etc.) with a few extra parameters that are specific to the concepts of DSI. This section provides the syntax and semantics of the different DSI APIs available to the NetSolve user.
DSI_FILE* ns_dsi_open
(char* host_name, int flag, int permissions, int size, dsi_type storage_system);
Name of the host where the IBP server resides.
This flag has the same meaning as the flag in open() calls in C. Specifically O_CREAT is used for creating a dsi file and so on.
While creating the file with O_CREAT flag, the user can specify the permissions for himself and others. The permissions are similar to the ones used in UNIX. Hence if the user wants to set read, write, execute permissions for himself and read and write permissions for others, he would call ns_dsi_open with 74 as the value for the permissions.
Represents the maximum length of the DSI file. Write or read operations over this size limit will return an error.
At present, IBP.
ns_dsi_open() is used for allocating a chunk of storage in the IBP storage. On success, ns_dsi_open returns a pinter to the DSI file. On failure, returns NULL. Following are the various error values set in case of failure.
If the file does not exist and if the file is opened without O_CREAT.
Error while allocating IBP storage.
If DSI is not enabled in the NetSolve configuration.
int ns_dsi_close
(DSI_FILE* dsi_file);
Pointer to the DSI file.
ns_dsi_close() is used for closing a DSI file.
On success returns 1. On failure, returns -1. Following are the various error values set in case of failure.
Error in IBP internals while closing.
If DSI is not enabled in the NetSolve configuration.
DSI_OBJECT* ns_dsi_write_vector
(DSI_FILE* dsi_file, void* data, int count, int data_type);
The name of the DSI file where the vector will be written.
Vector to write to the DSI storage.
Number of elements in the vector.
One of netsolve data types.
ns_dsi_write_vector() is used for writing a vector of a particular datatype to a DSI file.
On success, ns_dsi_write_vector() returns a pointer to the DSI object created for the vector. On failure, returns NULL. Following are the various error values set in case of failure.
Error while storing the vector in IBP.
Not enough permissions for writing to the DSI file.
If DSI is not enabled in the NetSolve configuration.
DSI_OBJECT* ns_dsi_write_matrix
(DSI_FILE* dsi_file, void* data, int rows, int cols, int data_type);
Same functionality and return values as ns_dsi_write_vector() except ns_dsi_write_matrix() is used to write matrix of rows rows and cols columns.
int ns_dsi_read_vector
(DSI_OBJECT* dsi_obj, void* data, int count, int data_type);
Pointer to the DSI object that contains the data to read.
Actual vector to read.
Number of elements of the vector to read.
One of NetSolve data types.
On success, returns the number of elements read. On failure, returns -1. Following are the various error values set in case of failure.
Error while loading the vector from IBP.
Not enough permissions for reading from the DSI file.
If DSI is not enabled in the NetSolve configuration.
int ns_dsi_read_matrix
(DSI_OBJECT* dsi_obj, void* data, int rows, int cols, int data_type);
Same functionality and return values as ns_dsi_read_vector() except ns_dsi_read_matrix() is used to read matrix of rows rows and cols columns.