summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-12-20 12:30:20 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-12-20 12:30:20 +0000
commit199e224466a88fbe88bec7b897fe61dbabf9c5f5 (patch)
tree42864b11725116d7caa0df3bed6d3e7361d2d5f9 /config
parent2d82ff0d3a0f95a3b19c61e318a3cb3dfa6a2491 (diff)
- Hide private interfaces.
- Make const - Use steady_time
Diffstat (limited to 'config')
-rw-r--r--config/src/tests/frt/frt.cpp1
-rw-r--r--config/src/tests/frtconnectionpool/frtconnectionpool.cpp3
-rw-r--r--config/src/vespa/config/frt/connection.h1
-rw-r--r--config/src/vespa/config/frt/frtconnection.cpp18
-rw-r--r--config/src/vespa/config/frt/frtconnection.h40
-rw-r--r--config/src/vespa/config/frt/frtconnectionpool.cpp4
6 files changed, 30 insertions, 37 deletions
diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp
index 5cfa125051a..4e77b289f49 100644
--- a/config/src/tests/frt/frt.cpp
+++ b/config/src/tests/frt/frt.cpp
@@ -125,7 +125,6 @@ struct Response {
waiter->RequestDone(req);
}
const vespalib::string & getAddress() const override { return address; }
- void setTransientDelay(duration delay) override { (void) delay; }
};
ConnectionMock::ConnectionMock(std::unique_ptr<Response> answer)
diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
index 7cd385deb8e..7b3a22893ab 100644
--- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
+++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp
@@ -5,7 +5,6 @@
#include <vespa/fnet/frt/error.h>
#include <vespa/fnet/transport.h>
#include <vespa/fastos/thread.h>
-#include <vespa/vespalib/util/size_literals.h>
#include <sstream>
#include <set>
#include <unistd.h>
@@ -219,7 +218,7 @@ void Test::testSetErrorAllHashBased() {
void Test::testSuspensionTimeout() {
const ServerSpec spec(_sources);
FRTConnectionPool sourcePool(_transport, spec, timingValues);
- Connection* source = sourcePool.getCurrent();
+ FRTConnection* source = dynamic_cast<FRTConnection *>(sourcePool.getCurrent());
source->setTransientDelay(1s);
source->setError(FRTE_RPC_CONNECTION);
for (int i = 0; i < 9; i++) {
diff --git a/config/src/vespa/config/frt/connection.h b/config/src/vespa/config/frt/connection.h
index ea4863123fc..328e9ede67a 100644
--- a/config/src/vespa/config/frt/connection.h
+++ b/config/src/vespa/config/frt/connection.h
@@ -16,7 +16,6 @@ public:
virtual void setError(int errorCode) = 0;
virtual void invoke(FRT_RPCRequest * req, duration timeout, FRT_IRequestWait * waiter) = 0;
virtual const vespalib::string & getAddress() const = 0;
- virtual void setTransientDelay(duration delay) = 0;
virtual ~Connection() = default;
};
diff --git a/config/src/vespa/config/frt/frtconnection.cpp b/config/src/vespa/config/frt/frtconnection.cpp
index c7e21842851..31b2f25dae0 100644
--- a/config/src/vespa/config/frt/frtconnection.cpp
+++ b/config/src/vespa/config/frt/frtconnection.cpp
@@ -14,14 +14,14 @@ namespace config {
FRTConnection::FRTConnection(const vespalib::string& address, FRT_Supervisor& supervisor, const TimingValues & timingValues)
: _address(address),
+ _fatalDelay(timingValues.fatalDelay),
_supervisor(supervisor),
_target(0),
_suspendedUntil(),
_suspendWarned(),
_transientFailures(0),
_fatalFailures(0),
- _transientDelay(timingValues.transientDelay),
- _fatalDelay(timingValues.fatalDelay)
+ _transientDelay(timingValues.transientDelay)
{
}
@@ -80,7 +80,7 @@ void FRTConnection::setSuccess()
{
_transientFailures = 0;
_fatalFailures = 0;
- _suspendedUntil = system_time();
+ _suspendedUntil = steady_time();
}
void FRTConnection::calculateSuspension(ErrorType type)
@@ -103,16 +103,10 @@ void FRTConnection::calculateSuspension(ErrorType type)
}
break;
}
- system_time now = system_clock::now();
- /*
- * On Darwin, the std::chrono::steady_clock period (std::nano) is
- * not exactly divisible by the std::chrono::system_clock period
- * (std::micro). Thus we need to use std::chrono::duration_cast to
- * convert from steady_time::duration to system_time::duration.
- */
- _suspendedUntil = now + std::chrono::duration_cast<system_time::duration>(delay);
+ steady_time now = steady_clock::now();
+ _suspendedUntil = now + delay;
if (_suspendWarned < (now - 5s)) {
- LOG(warning, "FRT Connection %s suspended until %s", _address.c_str(), vespalib::to_string(_suspendedUntil).c_str());
+ LOG(warning, "FRT Connection %s suspended until %s", _address.c_str(), vespalib::to_string(to_utc(_suspendedUntil)).c_str());
_suspendWarned = now;
}
}
diff --git a/config/src/vespa/config/frt/frtconnection.h b/config/src/vespa/config/frt/frtconnection.h
index 0e491d61bbf..24dc9d657e0 100644
--- a/config/src/vespa/config/frt/frtconnection.h
+++ b/config/src/vespa/config/frt/frtconnection.h
@@ -12,19 +12,6 @@ class FRT_Target;
namespace config {
class FRTConnection : public Connection {
-private:
- const vespalib::string _address;
- FRT_Supervisor& _supervisor;
- FRT_Target* _target;
- vespalib::system_time _suspendedUntil;
- vespalib::system_time _suspendWarned;
- std::atomic<int> _transientFailures;
- std::atomic<int> _fatalFailures;
- duration _transientDelay;
- duration _fatalDelay;
-
- FRT_Target * getTarget();
-
public:
typedef std::shared_ptr<FRTConnection> SP;
enum ErrorType { TRANSIENT, FATAL };
@@ -37,15 +24,30 @@ public:
FRT_RPCRequest * allocRPCRequest() override;
void invoke(FRT_RPCRequest * req, duration timeout, FRT_IRequestWait * waiter) override;
const vespalib::string & getAddress() const override { return _address; }
- vespalib::system_time getSuspendedUntil() { return _suspendedUntil; }
+ vespalib::steady_time getSuspendedUntil() const { return _suspendedUntil; }
void setError(int errorCode) override;
void setSuccess();
+
+ /// Only used for testing
+ void setTransientDelay(duration delay) { _transientDelay = delay; }
+private:
+ FRT_Target * getTarget();
+
void calculateSuspension(ErrorType type);
- duration getTransientDelay() { return _transientDelay; }
- duration getMaxTransientDelay() { return getTransientDelay() * 6; }
- void setTransientDelay(duration delay) override { _transientDelay = delay; }
- duration getFatalDelay() { return _fatalDelay; }
- duration getMaxFatalDelay() { return getFatalDelay() * 6; }
+ duration getTransientDelay() const { return _transientDelay; }
+ duration getMaxTransientDelay() const { return getTransientDelay() * 6; }
+ duration getMaxFatalDelay() const { return getFatalDelay() * 6; }
+ duration getFatalDelay() const { return _fatalDelay; }
+
+ const vespalib::string _address;
+ const duration _fatalDelay;
+ FRT_Supervisor& _supervisor;
+ FRT_Target* _target;
+ vespalib::steady_time _suspendedUntil;
+ vespalib::steady_time _suspendWarned;
+ std::atomic<int> _transientFailures;
+ std::atomic<int> _fatalFailures;
+ duration _transientDelay;
};
} // namespace config
diff --git a/config/src/vespa/config/frt/frtconnectionpool.cpp b/config/src/vespa/config/frt/frtconnectionpool.cpp
index 916784896ab..21d6f0dbe90 100644
--- a/config/src/vespa/config/frt/frtconnectionpool.cpp
+++ b/config/src/vespa/config/frt/frtconnectionpool.cpp
@@ -132,9 +132,9 @@ std::vector<FRTConnection *>
FRTConnectionPool::getReadySources() const
{
std::vector<FRTConnection*> readySources;
+ auto timestamp = vespalib::steady_clock::now();
for (const auto & entry : _connections) {
FRTConnection* source = entry.second.get();
- vespalib::system_time timestamp = vespalib::system_clock::now();
if (source->getSuspendedUntil() < timestamp) {
readySources.push_back(source);
}
@@ -146,9 +146,9 @@ std::vector<FRTConnection *>
FRTConnectionPool::getSuspendedSources() const
{
std::vector<FRTConnection*> suspendedSources;
+ auto timestamp = vespalib::steady_clock::now();
for (const auto & entry : _connections) {
FRTConnection* source = entry.second.get();
- vespalib::system_time timestamp = vespalib::system_clock::now();
if (source->getSuspendedUntil() >= timestamp) {
suspendedSources.push_back(source);
}