Robust Distributed System Nucleus (rDSN)  ver 1.0.0
Classes | Typedefs | Enumerations | Functions
File Operations

Overview

Note developers can easily plugin their own implementation to replace the underneath implementation of these primitives.

Classes

struct  dsn_file_buffer_t
 

Typedefs

typedef enum dsn_ctrl_code_t dsn_ctrl_code_t
 

Enumerations

enum  dsn_ctrl_code_t { CTL_BATCH_INVALID = 0, CTL_BATCH_WRITE = 1, CTL_MAX_CON_READ_OP_COUNT = 2, CTL_MAX_CON_WRITE_OP_COUNT = 3 }
 

Functions

DSN_API dsn_handle_t dsn_file_open (const char *file_name, int flag, int pmode)
 
DSN_API dsn_error_t dsn_file_close (dsn_handle_t file)
 
DSN_API dsn_error_t dsn_file_flush (dsn_handle_t file)
 
DSN_API void * dsn_file_native_handle (dsn_handle_t file)
 
DSN_API dsn_task_t dsn_file_create_aio_task (dsn_task_code_t code, dsn_aio_handler_t cb, void *context, int hash DEFAULT(0), dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API dsn_task_t dsn_file_create_aio_task_ex (dsn_task_code_t code, dsn_aio_handler_t cb, dsn_task_cancelled_handler_t on_cancel, void *context, int hash DEFAULT(0), dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API void dsn_file_read (dsn_handle_t file, char *buffer, int count, uint64_t offset, dsn_task_t cb)
 
DSN_API void dsn_file_write (dsn_handle_t file, const char *buffer, int count, uint64_t offset, dsn_task_t cb)
 
DSN_API void dsn_file_write_vector (dsn_handle_t file, const dsn_file_buffer_t *buffers, int buffer_count, uint64_t offset, dsn_task_t cb)
 
DSN_API void dsn_file_copy_remote_directory (dsn_address_t remote, const char *source_dir, const char *dest_dir, bool overwrite, dsn_task_t cb)
 
DSN_API void dsn_file_copy_remote_files (dsn_address_t remote, const char *source_dir, const char **source_files, const char *dest_dir, bool overwrite, dsn_task_t cb)
 
DSN_API size_t dsn_file_get_io_size (dsn_task_t cb_task)
 
DSN_API void dsn_file_task_enqueue (dsn_task_t cb_task, dsn_error_t err, size_t size)
 

Typedef Documentation

the following ctrl code are used by dsn_file_ctrl.

Enumeration Type Documentation

the following ctrl code are used by dsn_file_ctrl.

Enumerator
CTL_BATCH_WRITE 

(batch) set write batch size

CTL_MAX_CON_READ_OP_COUNT 

(throttling) maximum concurrent read ops

CTL_MAX_CON_WRITE_OP_COUNT 

(throttling) maximum concurrent write ops

Function Documentation

DSN_API dsn_handle_t dsn_file_open ( const char *  file_name,
int  flag,
int  pmode 
)

open file

Parameters
file_namefilename of the file.
flagflags such as O_RDONLY | O_BINARY used by ::open
pmodepermission mode used by ::open
Returns
file handle
DSN_API dsn_task_t dsn_file_create_aio_task ( dsn_task_code_t  code,
dsn_aio_handler_t  cb,
void *  context,
int hash   DEFAULT0,
dsn_task_tracker_t tracker   DEFAULTnullptr 
)

create aio task which is executed on completion of the file operations

Parameters
codetask code
cbcallback to be executed
contextcontext used by cb
hashspecify which thread to execute cb if target pool is partitioned
trackertask tracker bound to this aio task
Returns
aio task handle, nullptr for failure
DSN_API dsn_task_t dsn_file_create_aio_task_ex ( dsn_task_code_t  code,
dsn_aio_handler_t  cb,
dsn_task_cancelled_handler_t  on_cancel,
void *  context,
int hash   DEFAULT0,
dsn_task_tracker_t tracker   DEFAULTnullptr 
)

create aio task which is executed on completion of the file operations

Parameters
codetask code
cbcallback to be executed on task completion
on_cancelcallback to be executed on task being-cancelled
contextcontext used by cb
hashspecify which thread to execute cb if target pool is partitioned
trackertask tracker bound to this aio task
Returns
aio task handle, nullptr for failure
DSN_API void dsn_file_read ( dsn_handle_t  file,
char *  buffer,
int  count,
uint64_t  offset,
dsn_task_t  cb 
)

read file asynchronously

Parameters
filefile handle
bufferread buffer
countbyte size of the read buffer
offsetoffset in the file to start reading
cbcallback aio task to be executed on completion
DSN_API void dsn_file_write ( dsn_handle_t  file,
const char *  buffer,
int  count,
uint64_t  offset,
dsn_task_t  cb 
)

write file asynchronously

Parameters
filefile handle
bufferwrite buffer
countbyte size of the to-be-written content
offsetoffset in the file to start write
cbcallback aio task to be executed on completion
DSN_API void dsn_file_write_vector ( dsn_handle_t  file,
const dsn_file_buffer_t buffers,
int  buffer_count,
uint64_t  offset,
dsn_task_t  cb 
)

write file asynchronously with vector buffers

Parameters
filefile handle
bufferswrite buffers
buffer_countnumber of write buffers
offsetoffset in the file to start write
cbcallback aio task to be executed on completion
DSN_API void dsn_file_copy_remote_directory ( dsn_address_t  remote,
const char *  source_dir,
const char *  dest_dir,
bool  overwrite,
dsn_task_t  cb 
)

copy remote directory to the local machine

Parameters
remoteaddress of the remote nfs server
source_dirsource dir on remote server
dest_dirdestination dir on local server
overwritetrue to overwrite, false to preserve.
cbcallback aio task to be executed on completion
DSN_API void dsn_file_copy_remote_files ( dsn_address_t  remote,
const char *  source_dir,
const char **  source_files,
const char *  dest_dir,
bool  overwrite,
dsn_task_t  cb 
)

copy remote files to the local machine

Parameters
remoteaddress of the remote nfs server
source_dirsource dir on remote server
source_fileszero-ended file string array within the source dir on remote server, when it contains no files, all files within source_dir are copied
dest_dirdestination dir on local server
overwritetrue to overwrite, false to preserve.
cbcallback aio task to be executed on completion