Various improveents, nothing substantial

This commit is contained in:
Francesco Mazzoli
2023-02-14 17:51:50 +00:00
parent 7393282160
commit 51860fac3a
33 changed files with 633 additions and 309 deletions

View File

@@ -614,7 +614,21 @@ void runCDC(const std::string& dbDir, const CDCOptions& options) {
}
logOut = &fileOut;
}
Logger logger(options.level, *logOut);
Logger logger(options.logLevel, *logOut);
{
Env env(logger, "startup");
LOG_INFO(env, "Running CDC with options:");
LOG_INFO(env, " level = %s", options.logLevel);
LOG_INFO(env, " logFile = '%s'", options.logFile);
LOG_INFO(env, " port = %s", options.port);
LOG_INFO(env, " shuckleHost = '%s'", options.shuckleHost);
LOG_INFO(env, " shucklePort = %s", options.shucklePort);
{
char ip[INET_ADDRSTRLEN];
LOG_INFO(env, " ownIp = %s", inet_ntop(AF_INET, &options.ownIp, ip, INET_ADDRSTRLEN));
}
}
CDCDB db(logger, dbDir);
auto shared = std::make_unique<CDCShared>(db);

View File

@@ -3,7 +3,7 @@
#include "Env.hpp"
struct CDCOptions {
LogLevel level = LogLevel::LOG_INFO;
LogLevel logLevel = LogLevel::LOG_INFO;
std::string logFile = ""; // if empty, stdout
uint16_t port = 0; // chosen randomly and recorded in shuckle
std::string shuckleHost = "";

View File

@@ -7,7 +7,7 @@
#include "Assert.hpp"
#include "Bincode.hpp"
#include "Exception.hpp"
#include "MsgsGen.hpp"
#include "Msgs.hpp"
#include "RocksDBUtils.hpp"
#include "Msgs.hpp"
#include "Time.hpp"
@@ -211,5 +211,6 @@ struct TxnState {
default:
throw EGGS_EXCEPTION("bad cdc message kind %s", reqKind());
}
memset(_data+MIN_SIZE, 0, size()-MIN_SIZE);
}
};

View File

@@ -76,17 +76,17 @@ int main(int argc, char** argv) {
if (arg == "-h" || arg == "-help") {
dieWithUsage();
} else if (arg == "-verbose") {
options.level = std::min<LogLevel>(LogLevel::LOG_DEBUG, options.level);
options.logLevel = std::min<LogLevel>(LogLevel::LOG_DEBUG, options.logLevel);
} else if (arg == "-log-level") {
std::string logLevel = getNextArg();
if (logLevel == "trace") {
options.level = LogLevel::LOG_TRACE;
options.logLevel = LogLevel::LOG_TRACE;
} else if (logLevel == "debug") {
options.level = LogLevel::LOG_DEBUG;
options.logLevel = LogLevel::LOG_DEBUG;
} else if (logLevel == "info") {
options.level = LogLevel::LOG_INFO;
options.logLevel = LogLevel::LOG_INFO;
} else if (logLevel == "error") {
options.level = LogLevel::LOG_ERROR;
options.logLevel = LogLevel::LOG_ERROR;
} else {
die("Bad log level `%s'", logLevel.c_str());
}
@@ -109,7 +109,7 @@ int main(int argc, char** argv) {
}
#ifndef EGGS_DEBUG
if (options.level <= LogLevel::LOG_TRACE) {
if (options.logLevel <= LogLevel::LOG_TRACE) {
die("Cannot use log level trace trace for non-debug builds (it won't work).");
}
#endif

View File

@@ -705,6 +705,28 @@ std::ostream& operator<<(std::ostream& out, const ShardInfo& x) {
return out;
}
void RegisterShardInfo::pack(BincodeBuf& buf) const {
buf.packFixedBytes<4>(ip);
buf.packScalar<uint16_t>(port);
}
void RegisterShardInfo::unpack(BincodeBuf& buf) {
buf.unpackFixedBytes<4>(ip);
port = buf.unpackScalar<uint16_t>();
}
void RegisterShardInfo::clear() {
ip.clear();
port = uint16_t(0);
}
bool RegisterShardInfo::operator==(const RegisterShardInfo& rhs) const {
if (ip != rhs.ip) { return false; };
if ((uint16_t)this->port != (uint16_t)rhs.port) { return false; };
return true;
}
std::ostream& operator<<(std::ostream& out, const RegisterShardInfo& x) {
out << "RegisterShardInfo(" << "Ip=" << x.ip << ", " << "Port=" << x.port << ")";
return out;
}
void LookupReq::pack(BincodeBuf& buf) const {
dirId.pack(buf);
buf.packBytes(name);

View File

@@ -510,6 +510,27 @@ struct ShardInfo {
std::ostream& operator<<(std::ostream& out, const ShardInfo& x);
struct RegisterShardInfo {
BincodeFixedBytes<4> ip;
uint16_t port;
static constexpr uint16_t STATIC_SIZE = BincodeFixedBytes<4>::STATIC_SIZE + 2; // ip + port
RegisterShardInfo() { clear(); }
uint16_t packedSize() const {
uint16_t _size = 0;
_size += BincodeFixedBytes<4>::STATIC_SIZE; // ip
_size += 2; // port
return _size;
}
void pack(BincodeBuf& buf) const;
void unpack(BincodeBuf& buf);
void clear();
bool operator==(const RegisterShardInfo&rhs) const;
};
std::ostream& operator<<(std::ostream& out, const RegisterShardInfo& x);
struct LookupReq {
InodeId dirId;
BincodeBytes name;
@@ -2304,9 +2325,9 @@ std::ostream& operator<<(std::ostream& out, const ShardsResp& x);
struct RegisterShardReq {
ShardId id;
ShardInfo info;
RegisterShardInfo info;
static constexpr uint16_t STATIC_SIZE = 1 + ShardInfo::STATIC_SIZE; // id + info
static constexpr uint16_t STATIC_SIZE = 1 + RegisterShardInfo::STATIC_SIZE; // id + info
RegisterShardReq() { clear(); }
uint16_t packedSize() const {

View File

@@ -410,7 +410,23 @@ void runShard(ShardId shid, const std::string& dbDir, const ShardOptions& option
}
logOut = &fileOut;
}
Logger logger(options.level, *logOut);
Logger logger(options.logLevel, *logOut);
{
Env env(logger, "startup");
LOG_INFO(env, "Running shard %s with options:", shid);
LOG_INFO(env, " level = %s", options.logLevel);
LOG_INFO(env, " logFile = '%s'", options.logFile);
LOG_INFO(env, " port = %s", options.port);
LOG_INFO(env, " shuckleHost = '%s'", options.shuckleHost);
LOG_INFO(env, " shucklePort = %s", options.shucklePort);
{
char ip[INET_ADDRSTRLEN];
LOG_INFO(env, " ownIp = %s", inet_ntop(AF_INET, &options.ownIp, ip, INET_ADDRSTRLEN));
}
LOG_INFO(env, " simulateIncomingPacketDrop = %s", options.simulateIncomingPacketDrop);
LOG_INFO(env, " simulateOutgoingPacketDrop = %s", options.simulateOutgoingPacketDrop);
}
ShardDB db(logger, shid, dbDir);

View File

@@ -4,7 +4,7 @@
#include "Env.hpp"
struct ShardOptions {
LogLevel level = LogLevel::LOG_INFO;
LogLevel logLevel = LogLevel::LOG_INFO;
std::string logFile = ""; // if empty, stdout
uint16_t port = 0; // automatically assigned, stored in shuckle
std::string shuckleHost = "";

View File

@@ -5,6 +5,7 @@
#include <rocksdb/db.h>
#include <rocksdb/options.h>
#include <rocksdb/write_batch.h>
#include <rocksdb/table.h>
#include <system_error>
#include <xxhash.h>
@@ -251,6 +252,7 @@ struct ShardDBImpl {
options.create_missing_column_families = true;
options.compression = rocksdb::kLZ4Compression;
options.bottommost_compression = rocksdb::kZSTD;
rocksdb::ColumnFamilyOptions blockServicesToFilesOptions;
blockServicesToFilesOptions.merge_operator = CreateInt64AddOperator();
std::vector<rocksdb::ColumnFamilyDescriptor> familiesDescriptors{

View File

@@ -100,17 +100,17 @@ int main(int argc, char** argv) {
if (arg == "-h" || arg == "-help") {
dieWithUsage();
} else if (arg == "-verbose") {
options.level = std::min<LogLevel>(LogLevel::LOG_DEBUG, options.level);
options.logLevel = std::min<LogLevel>(LogLevel::LOG_DEBUG, options.logLevel);
} else if (arg == "-log-level") {
std::string logLevel = getNextArg();
if (logLevel == "trace") {
options.level = LogLevel::LOG_TRACE;
options.logLevel = LogLevel::LOG_TRACE;
} else if (logLevel == "debug") {
options.level = LogLevel::LOG_DEBUG;
options.logLevel = LogLevel::LOG_DEBUG;
} else if (logLevel == "info") {
options.level = LogLevel::LOG_INFO;
options.logLevel = LogLevel::LOG_INFO;
} else if (logLevel == "error") {
options.level = LogLevel::LOG_ERROR;
options.logLevel = LogLevel::LOG_ERROR;
} else {
die("Bad log level `%s'", logLevel.c_str());
}
@@ -137,7 +137,7 @@ int main(int argc, char** argv) {
}
#ifndef EGGS_DEBUG
if (options.level <= LogLevel::LOG_TRACE) {
if (options.logLevel <= LogLevel::LOG_TRACE) {
die("Cannot use trace for non-debug builds (it won't work).");
}
#endif