Class RocksDBBackend

Inheritance Relationships

Base Type

Class Documentation

class gkfs::metadata::RocksDBBackend : public gkfs::metadata::MetadataBackend<RocksDBBackend>

Called when the daemon is started: Connects to the KV store

Param path

where KV store data is stored

Public Functions

explicit RocksDBBackend(const std::string &path)

Called when the daemon is started: Connects to the KV store

Parameters

path – where KV store data is stored

virtual ~RocksDBBackend()
void optimize_database_impl()

Used for setting KV store settings

std::string get_impl(const std::string &key) const

Gets a KV store value for a key

Parameters

key

Throws

DBException – on failure, NotFoundException if entry doesn’t exist

Returns

value

void put_impl(const std::string &key, const std::string &val)

Puts an entry into the KV store

Parameters
  • key

  • val

Throws

DBException – on failure

void put_no_exist_impl(const std::string &key, const std::string &val)

Puts an entry into the KV store if it doesn’t exist. This function does not use a mutex.

Parameters
  • key

  • val

Throws

DBException – on failure, ExistException if entry already exists

void remove_impl(const std::string &key)

Removes an entry from the KV store

Parameters

key

Throws

DBException – on failure, NotFoundException if entry doesn’t exist

bool exists_impl(const std::string &key)

checks for existence of an entry

Parameters

key

Throws

DBException – on failure

Returns

true if exists

void update_impl(const std::string &old_key, const std::string &new_key, const std::string &val)

Updates a metadentry atomically and also allows to change keys

Parameters
  • old_key

  • new_key

  • val

Throws

DBException – on failure, NotFoundException if entry doesn’t exist

off_t increase_size_impl(const std::string &key, size_t io_size, off_t offset, bool append)

Updates the size on the metadata Operation. E.g., called before a write() call

Updates the size on the metadata Operation. E.g., called before a write() call

A special case represents the append operation. Since multiple processes could want to append a file in parallel, the corresponding offsets where the write operation starts, needs to be reserved. This is an expensive operation as we need to force a RocksDB Merge operation to receive the starting offset for this write request.

Parameters
  • key

  • io_size

  • offset

  • append

  • key

  • io_size

  • offset

  • append

Returns

offset where the write operation should start. This is only used when append is set

Returns

offset where the write operation should start. This is only used when append is set

void decrease_size_impl(const std::string &key, size_t size)

Decreases the size on the metadata Operation E.g., called before a truncate() call

Parameters
  • key

  • size

Throws

DBException – on failure

std::vector<std::pair<std::string, bool>> get_dirents_impl(const std::string &dir) const
std::vector<std::tuple<std::string, bool, size_t, time_t>> get_dirents_extended_impl(const std::string &dir) const
void iterate_all_impl() const

Code example for iterating all entries in KV store. This is for debug only as it is too expensive

Public Static Functions

static inline void throw_status_excpt(const rdb::Status &s)

Exception wrapper on Status object. Throws NotFoundException if s.IsNotFound(), general DBException otherwise

Parameters

RocksDB – status

Throws

DBException

Private Members

std::unique_ptr<rdb::DB> db_
rdb::Options options_
rdb::WriteOptions write_opts_