1 #ifndef PERSIST_NO_LOG_IMPL_HPP 2 #define PERSIST_NO_LOG_IMPL_HPP 4 #define _NOLOG_OBJECT_DIR_ ((storageType == ST_MEM) ? getPersRamdiskPath().c_str() : getPersFilePath().c_str()) 5 #define _NOLOG_OBJECT_NAME_ ((object_name == nullptr) ? typeid(ObjectType).name() : object_name) 9 template <
typename ObjectType, StorageType storageType>
12 const char* object_name) noexcept(
false) {
14 char tmpfilepath[260];
20 sprintf(tmpfilepath,
"%s.tmp", filepath);
23 char* buf =
new char[size];
27 int fd = open(tmpfilepath, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH);
31 ssize_t nWrite = write(fd, buf, size);
33 if(nWrite != (ssize_t)size) {
38 if(rename(tmpfilepath, filepath) != 0) {
43 template <
typename ObjectType, StorageType storageType>
45 const char* object_name,
54 if(fs::exists(filepath)) {
55 if(!fs::remove(filepath)) {
65 return std::unique_ptr<ObjectType>{};
67 int fd = open(filepath, O_RDONLY);
69 if(fd == -1 || (fstat(fd, &stat_buf) != 0)) {
73 char* buf =
new char[stat_buf.st_size];
78 if(read(fd, buf, stat_buf.st_size) != stat_buf.st_size) {
85 std::unique_ptr<ObjectType> ret = mutils::from_bytes<ObjectType>(dm, buf);
92 #endif //PERSIST_NO_LOG_IMPL_HPP #define PERSIST_EXP_WRITE_FILE(x)
#define _NOLOG_OBJECT_NAME_
This file include all common types internal to derecho and not necessarily being known by a client pr...
bool checkRegularFile(const std::string &file) noexcept(false)
#define PERSIST_EXP_OPEN_FILE(x)
#define dbg_default_error(...)
auto bytes_size(const T &)
Just calls sizeof(T)
#define PERSIST_EXP_OOM(x)
The manager for any RemoteDeserializationContexts.
std::unique_ptr< ObjectType > loadNoLogObjectFromFile(const char *object_name, mutils::DeserializationManager *dm) noexcept(false)
load data from file
#define PERSIST_EXP_REMOVE_FILE(x)
#define _NOLOG_OBJECT_DIR_
#define PERSIST_EXP_READ_FILE(x)
const bool getConfBoolean(const std::string &key)
void saveNoLogObjectInFile(ObjectType &obj, const char *object_name) noexcept(false)
save object in file
void checkOrCreateDir(const std::string &dirPath) noexcept(false)
std::size_t to_bytes(const ByteRepresentable &b, char *v)
calls b.to_bytes(v) when b is a ByteRepresentable; calls std::memcpy() when b is POD.
#define PERSIST_EXP_RENAME_FILE(x)