Namespace faabric::state

namespace state

WARNING - key-value objects are shared between threads, BUT hiredis is not thread-safe, so make sure you always retrieve the reference to Redis inline rather than sharing a reference within the class.

Enums

enum InMemoryStateKeyStatus

Values:

enumerator NOT_MAIN
enumerator MAIN
enum StateCalls

Values:

enumerator NoStateCall
enumerator Pull
enumerator Push
enumerator Size
enumerator Append
enumerator ClearAppended
enumerator PullAppended
enumerator Delete

Functions

InMemoryStateRegistry &getInMemoryStateRegistry()
State &getGlobalState()
static std::string getMasterKey(const std::string &user, const std::string &key)
class AppendedInMemoryState

Public Functions

inline AppendedInMemoryState(size_t lengthIn, std::unique_ptr<uint8_t[]> &&dataIn)

Public Members

size_t length
std::unique_ptr<uint8_t[]> data
class InMemoryStateKeyValue : public faabric::state::StateKeyValue

Public Functions

InMemoryStateKeyValue(const std::string &userIn, const std::string &keyIn, size_t sizeIn, const std::string &thisIPIn)
InMemoryStateKeyValue(const std::string &userIn, const std::string &keyIn, const std::string &thisIPIn)
bool isMaster()
AppendedInMemoryState &getAppendedValue(uint idx)

Public Static Functions

static size_t getStateSizeFromRemote(const std::string &userIn, const std::string &keyIn, const std::string &thisIPIn)
static void deleteFromRemote(const std::string &userIn, const std::string &keyIn, const std::string &thisIPIn)
static void clearAll(bool global)
class InMemoryStateRegistry

Public Functions

InMemoryStateRegistry() = default
std::string getMasterIP(const std::string &user, const std::string &key, const std::string &thisIP, bool claim)
std::string getMasterIPForOtherMaster(const std::string &userIn, const std::string &keyIn, const std::string &thisIP)
void clear()
class RedisStateKeyValue : public faabric::state::StateKeyValue

Public Functions

RedisStateKeyValue(const std::string &userIn, const std::string &keyIn, size_t sizeIn)
RedisStateKeyValue(const std::string &userIn, const std::string &keyIn)

Public Static Functions

static size_t getStateSizeFromRemote(const std::string &userIn, const std::string &keyIn)
static void deleteFromRemote(const std::string &userIn, const std::string &keyIn)
static void clearAll(bool global)
class State

Public Functions

explicit State(std::string thisIPIn)
size_t getStateSize(const std::string &user, const std::string &keyIn)
std::shared_ptr<StateKeyValue> getKV(const std::string &user, const std::string &key, size_t size)
std::shared_ptr<StateKeyValue> getKV(const std::string &user, const std::string &key)
void forceClearAll(bool global)
void deleteKV(const std::string &userIn, const std::string &keyIn)
void deleteKVLocally(const std::string &userIn, const std::string &keyIn)
size_t getKVCount()
std::string getThisIP()
class StateChunk

Public Functions

inline StateChunk(long offsetIn, size_t lengthIn, uint8_t *dataIn)
inline StateChunk(long offsetIn, std::vector<uint8_t> &data)

Public Members

long offset
size_t length
uint8_t *data
class StateClient : public faabric::transport::MessageEndpointClient

Public Functions

explicit StateClient(const std::string &userIn, const std::string &keyIn, const std::string &hostIn)
void pushChunks(const std::vector<StateChunk> &chunks)
void pullChunks(const std::vector<StateChunk> &chunks, uint8_t *bufferStart)
void append(const uint8_t *data, size_t length)
void pullAppended(uint8_t *buffer, size_t length, long nValues)
void clearAppended()
size_t stateSize()
void deleteState()
void lock()
void unlock()

Public Members

const std::string user
const std::string key
class StateKeyValue

Subclassed by faabric::state::InMemoryStateKeyValue, faabric::state::RedisStateKeyValue

Public Functions

StateKeyValue(const std::string &userIn, const std::string &keyIn, size_t sizeIn)
StateKeyValue(const std::string &userIn, const std::string &keyIn)
void get(uint8_t *buffer)
uint8_t *get()
void getChunk(long offset, uint8_t *buffer, size_t length)
uint8_t *getChunk(long offset, long len)
std::vector<StateChunk> getAllChunks()
void set(const uint8_t *buffer)
void setChunk(long offset, const uint8_t *buffer, size_t length)
void append(const uint8_t *buffer, size_t length)
void getAppended(uint8_t *buffer, size_t length, long nValues)
void clearAppended()
void mapSharedMemory(void *destination, long pagesOffset, long nPages)
void unmapSharedMemory(void *mappedAddr)
void pull()
void pushPartial()
void pushPartialMask(const std::shared_ptr<StateKeyValue> &maskKv)
void lockRead()
void unlockRead()
void lockWrite()
void unlockWrite()
void flagDirty()
void flagChunkDirty(long offset, long len)
size_t size() const
size_t getSharedMemorySize() const
void pushFull()

Public Members

const std::string user
const std::string key

Public Static Functions

static uint32_t waitOnRedisRemoteLock(const std::string &redisKey)
class StateKeyValueException : public runtime_error

Public Functions

inline explicit StateKeyValueException(const std::string &message)
class StateServer : public faabric::transport::MessageEndpointServer

Public Functions

explicit StateServer(State &stateIn)