1
0
Fork 0

Agent send logs to followers in packs of 250 max for now

This commit is contained in:
Kaveh Vahedipour 2017-06-05 21:37:08 +02:00
parent 0961cdc528
commit 8dc1e4a4f9
5 changed files with 30 additions and 7 deletions

View File

@ -50,6 +50,7 @@ AgencyFeature::AgencyFeature(application_features::ApplicationServer* server)
_supervisionFrequency(1.0), _supervisionFrequency(1.0),
_compactionStepSize(20000), _compactionStepSize(20000),
_compactionKeepSize(10000), _compactionKeepSize(10000),
_maxAppendSize(250),
_supervisionGracePeriod(10.0), _supervisionGracePeriod(10.0),
_cmdLineTimings(false) _cmdLineTimings(false)
{ {
@ -121,6 +122,11 @@ void AgencyFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
"wait for hard disk syncs on every persistence call " "wait for hard disk syncs on every persistence call "
"(required in production)", "(required in production)",
new BooleanParameter(&_waitForSync)); new BooleanParameter(&_waitForSync));
options->addHiddenOption("--agency.max-append-size",
"maximum size of appendEntries document (# log entries)",
new UInt64Parameter(&_maxAppendSize));
} }
void AgencyFeature::validateOptions(std::shared_ptr<ProgramOptions> options) { void AgencyFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
@ -253,7 +259,7 @@ void AgencyFeature::start() {
_size, _poolSize, _minElectionTimeout, _maxElectionTimeout, endpoint, _size, _poolSize, _minElectionTimeout, _maxElectionTimeout, endpoint,
_agencyEndpoints, _supervision, _waitForSync, _supervisionFrequency, _agencyEndpoints, _supervision, _waitForSync, _supervisionFrequency,
_compactionStepSize, _compactionKeepSize, _supervisionGracePeriod, _compactionStepSize, _compactionKeepSize, _supervisionGracePeriod,
_cmdLineTimings))); _cmdLineTimings, _maxAppendSize)));
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Starting agency personality"; LOG_TOPIC(DEBUG, Logger::AGENCY) << "Starting agency personality";
_agent->start(); _agent->start();

View File

@ -55,6 +55,7 @@ class AgencyFeature : virtual public application_features::ApplicationFeature {
double _supervisionFrequency; double _supervisionFrequency;
uint64_t _compactionStepSize; uint64_t _compactionStepSize;
uint64_t _compactionKeepSize; uint64_t _compactionKeepSize;
uint64_t _maxAppendSize;
double _supervisionGracePeriod; double _supervisionGracePeriod;
std::string _agencyMyAddress; std::string _agencyMyAddress;
std::vector<std::string> _agencyEndpoints; std::vector<std::string> _agencyEndpoints;

View File

@ -420,7 +420,8 @@ void Agent::sendAppendEntriesRPC() {
commitIndex = _commitIndex; commitIndex = _commitIndex;
} }
std::vector<log_t> unconfirmed = _state.get(lastConfirmed); std::vector<log_t> unconfirmed =
_state.get(lastConfirmed, lastConfirmed + _config.maxAppendSize());
// Note that dispite compaction this vector can never be empty, since // Note that dispite compaction this vector can never be empty, since
// any compaction keeps at least one active log entry! // any compaction keeps at least one active log entry!

View File

@ -43,13 +43,14 @@ config_t::config_t()
_cmdLineTimings(false), _cmdLineTimings(false),
_version(0), _version(0),
_startup("origin"), _startup("origin"),
_maxAppendSize(250),
_lock() _lock()
{} {}
config_t::config_t(size_t as, size_t ps, double minp, double maxp, config_t::config_t(size_t as, size_t ps, double minp, double maxp,
std::string const& e, std::vector<std::string> const& g, std::string const& e, std::vector<std::string> const& g,
bool s, bool w, double f, uint64_t c, uint64_t k, double p, bool s, bool w, double f, uint64_t c, uint64_t k, double p,
bool t) bool t, size_t a)
: _agencySize(as), : _agencySize(as),
_poolSize(ps), _poolSize(ps),
_minPing(minp), _minPing(minp),
@ -65,7 +66,9 @@ config_t::config_t(size_t as, size_t ps, double minp, double maxp,
_cmdLineTimings(t), _cmdLineTimings(t),
_version(0), _version(0),
_startup("origin"), _startup("origin"),
_lock() {} _maxAppendSize(a),
_lock()
{}
config_t::config_t(config_t const& other) { *this = other; } config_t::config_t(config_t const& other) { *this = other; }
@ -87,7 +90,8 @@ config_t::config_t(config_t&& other)
_supervisionGracePeriod(std::move(other._supervisionGracePeriod)), _supervisionGracePeriod(std::move(other._supervisionGracePeriod)),
_cmdLineTimings(std::move(other._cmdLineTimings)), _cmdLineTimings(std::move(other._cmdLineTimings)),
_version(std::move(other._version)), _version(std::move(other._version)),
_startup(std::move(other._startup)){} _startup(std::move(other._startup)),
_maxAppendSize(std::move(other._maxAppendSize)){}
config_t& config_t::operator=(config_t const& other) { config_t& config_t::operator=(config_t const& other) {
// must hold the lock of other to copy _pool, _minPing, _maxPing etc. // must hold the lock of other to copy _pool, _minPing, _maxPing etc.
@ -111,6 +115,7 @@ config_t& config_t::operator=(config_t const& other) {
_cmdLineTimings = other._cmdLineTimings; _cmdLineTimings = other._cmdLineTimings;
_version = other._version; _version = other._version;
_startup = other._startup; _startup = other._startup;
_maxAppendSize = other._maxAppendSize;
return *this; return *this;
} }
@ -133,6 +138,7 @@ config_t& config_t::operator=(config_t&& other) {
_cmdLineTimings = std::move(other._cmdLineTimings); _cmdLineTimings = std::move(other._cmdLineTimings);
_version = std::move(other._version); _version = std::move(other._version);
_startup = std::move(other._startup); _startup = std::move(other._startup);
_maxAppendSize = std::move(other._maxAppendSize);
return *this; return *this;
} }
@ -288,6 +294,11 @@ std::string config_t::nextAgentInLine() const {
return ""; // No one left return ""; // No one left
} }
size_t config_t::maxAppendSize() const {
READ_LOCKER(readLocker, _lock);
return _maxAppendSize;
}
size_t config_t::compactionStepSize() const { size_t config_t::compactionStepSize() const {
READ_LOCKER(readLocker, _lock); READ_LOCKER(readLocker, _lock);
return _compactionStepSize; return _compactionStepSize;

View File

@ -75,6 +75,7 @@ struct config_t {
bool _cmdLineTimings; bool _cmdLineTimings;
size_t _version; size_t _version;
std::string _startup; std::string _startup;
size_t _maxAppendSize;
mutable arangodb::basics::ReadWriteLock _lock; // guard member variables mutable arangodb::basics::ReadWriteLock _lock; // guard member variables
@ -84,7 +85,7 @@ struct config_t {
/// @brief ctor /// @brief ctor
config_t(size_t as, size_t ps, double minp, double maxp, std::string const& e, config_t(size_t as, size_t ps, double minp, double maxp, std::string const& e,
std::vector<std::string> const& g, bool s, bool w, double f, std::vector<std::string> const& g, bool s, bool w, double f,
uint64_t c, uint64_t k, double p, bool t); uint64_t c, uint64_t k, double p, bool t, size_t a);
/// @brief copy constructor /// @brief copy constructor
config_t(config_t const&); config_t(config_t const&);
@ -122,6 +123,9 @@ struct config_t {
/// @brief active agency size /// @brief active agency size
size_t size() const; size_t size() const;
/// @brief maximum appendEntries #logs
size_t maxAppendSize() const;
/// @brief active empty? /// @brief active empty?
bool activeEmpty() const; bool activeEmpty() const;