NCCLOUD
0.1
|
Abstract base class for coding modules. More...
#include <coding.h>
Public Member Functions | |
virtual int | encode_file (std::string &dstdir, std::string &srcdir, std::string &filename)=0 |
Encode a file at srcdir/filename into chunks stored under dstdir. | |
virtual int | decode_file (std::string &dst, std::string &srcdir, std::string &filename, std::vector< int > &chunk_indices)=0 |
Reconstruct a file from chunks under srcdir into dst. | |
virtual int | repair_file_preprocess (std::string &srcdir, std::string &filename, std::vector< int > &erasures, std::vector< int > &chunks_to_retrieve)=0 |
Setup repair and inform the user which chunks to retrieve for use in repair. | |
virtual int | repair_file (std::string &dstdir, std::string &srcdir, std::string &filename)=0 |
Generate new chunks to replace failed chunks. | |
virtual int | getn (void)=0 |
Return the total number of nodes. | |
virtual int | getk (void)=0 |
Return the number of nodes required to reconstruct data. | |
virtual int | nodeid (int index)=0 |
Return ID of the node where a specified chunk resides. | |
virtual int | chunks_per_node (void)=0 |
Return the number of chunks per node. | |
virtual int | chunks_on_node (int node, std::vector< int > &chunk_indices)=0 |
Return the indices of all chunks on a specified node. | |
virtual void | reset (void)=0 |
Clear all cached parameters other than n, k and w. | |
Static Public Member Functions | |
static Coding * | use_coding (int type, int k, int n, int w) |
Return an instance of a coding scheme, based on user's choice. | |
Protected Member Functions | |
virtual void | read_metadata (std::string &path, size_t &chunksize) |
Read metadata from disk. | |
virtual void | write_metadata (std::string &path, size_t chunksize) |
Write metadata to disk. | |
virtual void | read_chunks (std::string &path, size_t chunksize, std::vector< int > &chunk_indices, char *chunks) |
Read chunks from disk to a single char buffer. | |
virtual void | write_chunks (std::string &path, size_t chunksize, std::vector< int > &chunk_indices, char *chunks) |
Write chunks to disk from a single char buffer. |
Abstract base class for coding modules.
virtual int Coding::chunks_on_node | ( | int | node, |
std::vector< int > & | chunk_indices | ||
) | [pure virtual] |
Return the indices of all chunks on a specified node.
[in] | node | node number |
[out] | chunk_indices | vector of chunk indices on node |
virtual int Coding::chunks_per_node | ( | void | ) | [pure virtual] |
Return the number of chunks per node.
virtual int Coding::decode_file | ( | std::string & | dst, |
std::string & | srcdir, | ||
std::string & | filename, | ||
std::vector< int > & | chunk_indices | ||
) | [pure virtual] |
Reconstruct a file from chunks under srcdir into dst.
[in] | dst | pathname of reconstructed file |
[in] | srcdir | directory where retrieved chunks used for decoding are stored |
[in] | filename | filename of file to reconstruct |
[in] | chunk_indices | Indices of chunks retrieved for use in decoding |
virtual int Coding::encode_file | ( | std::string & | dstdir, |
std::string & | srcdir, | ||
std::string & | filename | ||
) | [pure virtual] |
Encode a file at srcdir/filename into chunks stored under dstdir.
[in] | dstdir | destination directory where encoded chunks are stored |
[in] | srcdir | source directory of source file to be encoded |
[in] | filename | filename of source file to be encoded |
virtual int Coding::getk | ( | void | ) | [pure virtual] |
Return the number of nodes required to reconstruct data.
virtual int Coding::getn | ( | void | ) | [pure virtual] |
Return the total number of nodes.
virtual int Coding::nodeid | ( | int | index | ) | [pure virtual] |
Return ID of the node where a specified chunk resides.
[in] | index | chunk index |
void Coding::read_chunks | ( | std::string & | path, |
size_t | chunksize, | ||
std::vector< int > & | chunk_indices, | ||
char * | chunks | ||
) | [protected, virtual] |
Read chunks from disk to a single char buffer.
[in] | path | path to chunks without the ".chunk_" suffix |
[in] | chunksize | size of a chunk |
[in] | chunk_indices | list of chunk indices to read |
[out] | chunks | single char buffer holding chunks, following order in chunk_indices |
void Coding::read_metadata | ( | std::string & | path, |
size_t & | chunksize | ||
) | [protected, virtual] |
Read metadata from disk.
[in] | path | path to metadata without the ".meta" suffix |
[out] | chunksize | chunk size read from the metadata |
virtual int Coding::repair_file | ( | std::string & | dstdir, |
std::string & | srcdir, | ||
std::string & | filename | ||
) | [pure virtual] |
Generate new chunks to replace failed chunks.
[in] | dstdir | destination directory to store the new chunks |
[in] | srcdir | directory where retrieved chunks are at |
[in] | filename | filename of file to repair |
virtual int Coding::repair_file_preprocess | ( | std::string & | srcdir, |
std::string & | filename, | ||
std::vector< int > & | erasures, | ||
std::vector< int > & | chunks_to_retrieve | ||
) | [pure virtual] |
Setup repair and inform the user which chunks to retrieve for use in repair.
[in] | srcdir | directory where retrieved metadata is at |
[in] | filename | filename of file to repair |
[in] | erasures | list of failed nodes |
[out] | chunks_to_retrieve | Indices of chunks to be retrieved for use in repair |
virtual void Coding::reset | ( | void | ) | [pure virtual] |
Clear all cached parameters other than n, k and w.
Coding * Coding::use_coding | ( | int | type, |
int | k, | ||
int | n, | ||
int | w | ||
) | [static] |
Return an instance of a coding scheme, based on user's choice.
[in] | type | choice of coding scheme (0, 1 or 2) |
[in] | k | number of nodes required to reconstruct data |
[in] | n | total number of nodes |
[in] | w | field width, w=8 if we use GF(2^8) |
void Coding::write_chunks | ( | std::string & | path, |
size_t | chunksize, | ||
std::vector< int > & | chunk_indices, | ||
char * | chunks | ||
) | [protected, virtual] |
Write chunks to disk from a single char buffer.
[in] | path | path to chunks without the ".chunk_" suffix |
[in] | chunksize | size of a chunk |
[in] | chunk_indices | list of chunk indices to read |
[in] | chunks | single char buffer holding chunks, following order in chunk_indices |
void Coding::write_metadata | ( | std::string & | path, |
size_t | chunksize | ||
) | [protected, virtual] |
Write metadata to disk.
[in] | path | path to metadata without the ".meta" suffix |
[in] | chunksize | chunk size to write to the metadata |