Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some doc updates.
There are still a few completely undocumented classes -- some of which
should probably just be marked as DETAILS so they don't show up in the
docs, but it's good to at least get a bit captured.

Change-Id: I606595f6b7c66f5acc4348fe74688a8e9c2695d7
Reviewed-on: http://review.couchbase.org/13048
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
dustin authored and trondn committed Feb 7, 2012
1 parent 7135a13 commit 4d05a0c
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 5 deletions.
13 changes: 11 additions & 2 deletions checkpoint.hh
Expand Up @@ -24,16 +24,25 @@
#define DEFAULT_MAX_CHECKPOINTS 2 #define DEFAULT_MAX_CHECKPOINTS 2
#define MAX_CHECKPOINTS_UPPER_BOUND 5 #define MAX_CHECKPOINTS_UPPER_BOUND 5


/**
* The state of a given checkpoint.
*/
typedef enum { typedef enum {
opened, opened, //!< The checkpoint is open.
closed closed //!< The checkpoint is not open.
} checkpoint_state; } checkpoint_state;


/**
* A checkpoint index entry.
*/
struct index_entry { struct index_entry {
std::list<queued_item>::iterator position; std::list<queued_item>::iterator position;
uint64_t mutation_id; uint64_t mutation_id;
}; };


/**
* The checkpoint index maps a key to a checkpoint index_entry.
*/
typedef unordered_map<std::string, index_entry> checkpoint_index; typedef unordered_map<std::string, index_entry> checkpoint_index;


class Checkpoint; class Checkpoint;
Expand Down
3 changes: 3 additions & 0 deletions configuration.cc
Expand Up @@ -275,6 +275,9 @@ void Configuration::addStats(ADD_STAT add_stat, const void *c) const {
} }
} }


/**
* Internal container of an engine parameter.
*/
class ConfigItem: public config_item { class ConfigItem: public config_item {
public: public:
ConfigItem(const char *theKey, config_datatype theDatatype) { ConfigItem(const char *theKey, config_datatype theDatatype) {
Expand Down
16 changes: 16 additions & 0 deletions configuration.hh
Expand Up @@ -144,6 +144,10 @@ public:
virtual ~ValueChangedValidator() { } virtual ~ValueChangedValidator() { }
}; };


/**
* A configuration input validator that ensures a numeric (size_t)
* value falls between a specified upper and lower limit.
*/
class SizeRangeValidator : public ValueChangedValidator { class SizeRangeValidator : public ValueChangedValidator {
public: public:
SizeRangeValidator() : lower(0), upper(0) {} SizeRangeValidator() : lower(0), upper(0) {}
Expand All @@ -167,6 +171,10 @@ private:
size_t upper; size_t upper;
}; };


/**
* A configuration input validator that ensures that a numeric (float)
* value falls between a specified upper and lower limit.
*/
class FloatRangeValidator : public ValueChangedValidator { class FloatRangeValidator : public ValueChangedValidator {
public: public:
FloatRangeValidator() : lower(0), upper(0) {} FloatRangeValidator() : lower(0), upper(0) {}
Expand All @@ -190,6 +198,10 @@ private:
float upper; float upper;
}; };


/**
* A configuration input validator that ensures that a value is one
* from a predefined set of acceptable values.
*/
class EnumValidator : public ValueChangedValidator { class EnumValidator : public ValueChangedValidator {
public: public:
EnumValidator() {} EnumValidator() {}
Expand All @@ -208,6 +220,10 @@ private:
std::set<std::string> acceptable; std::set<std::string> acceptable;
}; };


/**
* The configuration class represents and provides access to the
* entire configuration of the server.
*/
class Configuration { class Configuration {
public: public:
Configuration(); Configuration();
Expand Down
5 changes: 5 additions & 0 deletions ep.cc
Expand Up @@ -106,6 +106,11 @@ class VBucketBatchCountCallback : public DispatcherCallback {
size_t batchCount; size_t batchCount;
}; };


/**
* A configuration value changed listener that responds to ep-engine
* parameter changes by invoking engine-specific methods on
* configuration change events.
*/
class EPStoreValueChangeListener : public ValueChangedListener { class EPStoreValueChangeListener : public ValueChangedListener {
public: public:
EPStoreValueChangeListener(EventuallyPersistentStore &st) : store(st) { EPStoreValueChangeListener(EventuallyPersistentStore &st) : store(st) {
Expand Down
4 changes: 1 addition & 3 deletions ep.hh
Expand Up @@ -470,17 +470,15 @@ public:
} }


/** /**
* Retrieve a value. * Retrieve a value from a vbucket in replica state.
* *
* @param key the key to fetch * @param key the key to fetch
* @param vbucket the vbucket from which to retrieve the key * @param vbucket the vbucket from which to retrieve the key
* @param cookie the connection cookie * @param cookie the connection cookie
* @param queueBG if true, automatically queue a background fetch if necessary * @param queueBG if true, automatically queue a background fetch if necessary
* @param requestState fetch a result iff the vbucket state == requestState
* *
* @return a GetValue representing the result of the request * @return a GetValue representing the result of the request
*/ */

GetValue getReplica(const std::string &key, uint16_t vbucket, GetValue getReplica(const std::string &key, uint16_t vbucket,
const void *cookie, bool queueBG) { const void *cookie, bool queueBG) {
return getInternal(key, vbucket, cookie, queueBG, true, return getInternal(key, vbucket, cookie, queueBG, true,
Expand Down
5 changes: 5 additions & 0 deletions ep_engine.cc
Expand Up @@ -1066,6 +1066,11 @@ EventuallyPersistentEngine::EventuallyPersistentEngine(GET_SERVER_API get_server
restore.manager = NULL; restore.manager = NULL;
} }


/**
* A configuration value changed listener that responds to ep-engine
* parameter changes by invoking engine-specific methods on
* configuration change events.
*/
class EpEngineValueChangeListener : public ValueChangedListener { class EpEngineValueChangeListener : public ValueChangedListener {
public: public:
EpEngineValueChangeListener(EventuallyPersistentEngine &e) : engine(e) { EpEngineValueChangeListener(EventuallyPersistentEngine &e) : engine(e) {
Expand Down
4 changes: 4 additions & 0 deletions kvstore.hh
Expand Up @@ -261,6 +261,10 @@ public:
virtual void destroyInvalidVBuckets(bool destroyOnlyOne = false) = 0; virtual void destroyInvalidVBuckets(bool destroyOnlyOne = false) = 0;
}; };


/**
* The KVStoreFactory creates the correct KVStore instance(s) when
* needed by EPStore.
*/
class KVStoreFactory { class KVStoreFactory {
public: public:


Expand Down
52 changes: 52 additions & 0 deletions mutation_log.hh
Expand Up @@ -38,6 +38,10 @@ const uint8_t FLUSH_FULL(FLUSH_COMMIT_1 | FLUSH_COMMIT_2);


const uint8_t DEFAULT_SYNC_CONF(FLUSH_COMMIT_2 | SYNC_COMMIT_2); const uint8_t DEFAULT_SYNC_CONF(FLUSH_COMMIT_2 | SYNC_COMMIT_2);


/**
* The header block representing the first 4k (or so) of a MutationLog
* file.
*/
class LogHeaderBlock { class LogHeaderBlock {
public: public:
LogHeaderBlock() : _version(htonl(LOG_VERSION)), _blockSize(0), _blockCount(0) { LogHeaderBlock() : _version(htonl(LOG_VERSION)), _blockSize(0), _blockCount(0) {
Expand Down Expand Up @@ -86,15 +90,32 @@ typedef enum {


extern const char *mutation_log_type_names[]; extern const char *mutation_log_type_names[];


/**
* An entry in the MutationLog.
*/
class MutationLogEntry { class MutationLogEntry {
public: public:


/**
* Initialize a new entry inside the given buffer.
*
* @param r the rowid
* @param t the type of log entry
* @param vb the vbucket
* @param k the key
*/
static MutationLogEntry* newEntry(uint8_t *buf, static MutationLogEntry* newEntry(uint8_t *buf,
uint64_t r, mutation_log_type_t t, uint64_t r, mutation_log_type_t t,
uint16_t vb, const std::string &k) { uint16_t vb, const std::string &k) {
return new (buf) MutationLogEntry(r, t, vb, k); return new (buf) MutationLogEntry(r, t, vb, k);
} }


/**
* Initialize a new entry using the contents of the given buffer.
*
* @param buf a chunk of memory thought to contain a valid MutationLogEntry
* @param buflen the length of said buf
*/
static MutationLogEntry* newEntry(uint8_t *buf, size_t buflen) { static MutationLogEntry* newEntry(uint8_t *buf, size_t buflen) {
assert(buflen >= len(0)); assert(buflen >= len(0));
MutationLogEntry *me = reinterpret_cast<MutationLogEntry*>(buf); MutationLogEntry *me = reinterpret_cast<MutationLogEntry*>(buf);
Expand All @@ -107,26 +128,46 @@ public:
// Statically buffered. There is no delete. // Statically buffered. There is no delete.
} }


/**
* The size of a MutationLogEntry, in bytes, containing a key of
* the specified length.
*/
static size_t len(size_t klen) { static size_t len(size_t klen) {
// 13 == the exact empty record size as will be packed into // 13 == the exact empty record size as will be packed into
// the layout // the layout
return 13 + klen; return 13 + klen;
} }


/**
* The number of bytes of the serialized form of this
* MutationLogEntry.
*/
size_t len() const { size_t len() const {
return MutationLogEntry::len(keylen); return MutationLogEntry::len(keylen);
} }


/**
* This entry's key.
*/
const std::string key() const { const std::string key() const {
return std::string(_key, keylen); return std::string(_key, keylen);
} }


/**
* This entry's rowid.
*/
uint64_t rowid() const; uint64_t rowid() const;


/**
* This entry's vbucket.
*/
uint16_t vbucket() const { uint16_t vbucket() const {
return ntohs(_vbucket); return ntohs(_vbucket);
} }


/**
* The type of this log entry.
*/
uint8_t type() const { uint8_t type() const {
return _type; return _type;
} }
Expand Down Expand Up @@ -157,6 +198,11 @@ private:


std::ostream& operator <<(std::ostream &out, const MutationLogEntry &mle); std::ostream& operator <<(std::ostream &out, const MutationLogEntry &mle);



/**
* The MutationLog records major key events to allow ep-engine to more
* quickly restore the server to its previous state upon restart.
*/
class MutationLog { class MutationLog {
public: public:


Expand Down Expand Up @@ -287,12 +333,18 @@ public:
bool isEnd; bool isEnd;
}; };


/**
* An iterator pointing to the beginning of the log file.
*/
iterator begin() { iterator begin() {
iterator it(iterator(this)); iterator it(iterator(this));
it.nextBlock(); it.nextBlock();
return it; return it;
} }


/**
* An iterator pointing at the end of the log file.
*/
iterator end() { iterator end() {
return iterator(this, true); return iterator(this, true);
} }
Expand Down
4 changes: 4 additions & 0 deletions objectregistry.cc
Expand Up @@ -19,6 +19,10 @@


static ThreadLocal<EventuallyPersistentEngine*> *th; static ThreadLocal<EventuallyPersistentEngine*> *th;


/**
* Object registry link hook for getting the registry thread local
* installed.
*/
class installer { class installer {
public: public:
installer() { installer() {
Expand Down

0 comments on commit 4d05a0c

Please sign in to comment.