fixed compilation issues after rebase
This commit is contained in:
parent
43a7703a1e
commit
69fa3d3903
|
@ -52,7 +52,7 @@ if(WIN32)
|
|||
# see: https://docs.microsoft.com/en-us/windows/desktop/WinProg/using-the-windows-headers
|
||||
# this sets the windows target version to Windows 7
|
||||
set(WINDOWS_TARGET 0x0601)
|
||||
add_compile_options(/W3 /EHsc /std:c++14 /bigobj $<$<CONFIG:Release>:/Zi> /MP)
|
||||
add_compile_options(/W3 /EHsc /std:c++17 /bigobj $<$<CONFIG:Release>:/Zi> /MP)
|
||||
add_compile_definitions(_WIN32_WINNT=${WINDOWS_TARGET} BOOST_ALL_NO_LIB)
|
||||
else()
|
||||
if(USE_GOLD_LINKER)
|
||||
|
|
|
@ -745,25 +745,6 @@ struct AddressExclusion {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct scalar_traits<AddressExclusion> : std::true_type {
|
||||
using ip_traits = scalar_traits<uint32_t>;
|
||||
using port_traits = scalar_traits<int>;
|
||||
constexpr static size_t size = ip_traits::size + port_traits::size;
|
||||
static void save(uint8_t* buf, const AddressExclusion& value) {
|
||||
ip_traits::save(buf, value.ip);
|
||||
port_traits::save(buf + ip_traits::size, value.port);
|
||||
}
|
||||
|
||||
// Context is an arbitrary type that is plumbed by reference throughout the
|
||||
// load call tree.
|
||||
template <class Context>
|
||||
static void load(const uint8_t* buf, AddressExclusion& value, Context& context) {
|
||||
ip_traits::load<Context>(buf, value.ip, context);
|
||||
port_traits::load<Context>(buf + ip_traits::size, value.port, context);
|
||||
}
|
||||
};
|
||||
|
||||
static bool addressExcluded( std::set<AddressExclusion> const& exclusions, NetworkAddress const& addr ) {
|
||||
return exclusions.count( AddressExclusion(addr.ip, addr.port) ) || exclusions.count( AddressExclusion(addr.ip) );
|
||||
}
|
||||
|
|
|
@ -252,6 +252,7 @@ struct TxnStateRequest {
|
|||
|
||||
struct GetHealthMetricsRequest
|
||||
{
|
||||
constexpr static FileIdentifier file_identifier = 11403900;
|
||||
ReplyPromise<struct GetHealthMetricsReply> reply;
|
||||
bool detailed;
|
||||
|
||||
|
@ -266,6 +267,7 @@ struct GetHealthMetricsRequest
|
|||
|
||||
struct GetHealthMetricsReply
|
||||
{
|
||||
constexpr static FileIdentifier file_identifier = 11544290;
|
||||
Standalone<StringRef> serialized;
|
||||
HealthMetrics healthMetrics;
|
||||
|
||||
|
|
|
@ -1020,13 +1020,13 @@ static PacketID sendPacket( TransportData* self, ISerializeSource const& what, c
|
|||
what.serializeBinaryWriter(wr);
|
||||
copy = wr.toStringRef();
|
||||
} else {
|
||||
BinaryWriter wr( AssumeVersion(currentProtocolVersion) );
|
||||
// we don't need to send using an object writer here. This is a loopback delivery
|
||||
// and therefore it is guaranteed that both versions will have exactly the
|
||||
// same structures - so the backwards compatability capabilities are never needed
|
||||
// here.
|
||||
what.serializeBinaryWriter(wr);
|
||||
copy = wr.toStringRef();
|
||||
BinaryWriter wr( AssumeVersion(currentProtocolVersion) );
|
||||
// we don't need to send using an object writer here. This is a loopback delivery
|
||||
// and therefore it is guaranteed that both versions will have exactly the
|
||||
// same structures - so the backwards compatability capabilities are never needed
|
||||
// here.
|
||||
what.serializeBinaryWriter(wr);
|
||||
copy = wr.toValue();
|
||||
}
|
||||
#if VALGRIND
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(copy.begin(), copy.size());
|
||||
|
|
|
@ -81,8 +81,8 @@ public:
|
|||
}
|
||||
} else {
|
||||
if (ar.isDeserializing && ar.protocolVersion() < 0x0FDB00B061020001LL) {
|
||||
addresses.resize(1);
|
||||
serializer(ar, addresses[0], token);
|
||||
addresses.secondaryAddress = Optional<NetworkAddress>();
|
||||
serializer(ar, addresses.address, token);
|
||||
} else {
|
||||
serializer(ar, addresses, token);
|
||||
if (ar.isDeserializing) {
|
||||
|
@ -170,8 +170,6 @@ public:
|
|||
|
||||
Endpoint loadedEndpoint(const UID& token);
|
||||
|
||||
void loadedEndpoint(Endpoint&);
|
||||
|
||||
private:
|
||||
class TransportData* self;
|
||||
};
|
||||
|
|
|
@ -29,111 +29,99 @@ template <class Ar>
|
|||
void serializeReplicationPolicy(Ar& ar, Reference<IReplicationPolicy>& policy);
|
||||
extern void testReplicationPolicy(int nTests);
|
||||
|
||||
|
||||
struct IReplicationPolicy : public ReferenceCounted<IReplicationPolicy> {
|
||||
IReplicationPolicy() {}
|
||||
virtual ~IReplicationPolicy() {}
|
||||
virtual std::string name() const = 0;
|
||||
virtual std::string info() const = 0;
|
||||
virtual void addref() { ReferenceCounted<IReplicationPolicy>::addref(); }
|
||||
virtual void delref() { ReferenceCounted<IReplicationPolicy>::delref(); }
|
||||
virtual int maxResults() const = 0;
|
||||
virtual int depth() const = 0;
|
||||
virtual bool selectReplicas(
|
||||
Reference<LocalitySet> & fromServers,
|
||||
std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry> & results ) = 0;
|
||||
virtual void traceLocalityRecords(Reference<LocalitySet> const& fromServers);
|
||||
virtual void traceOneLocalityRecord(Reference<LocalityRecord> record, Reference<LocalitySet> const& fromServers);
|
||||
virtual bool validate(
|
||||
std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers ) const = 0;
|
||||
IReplicationPolicy() {}
|
||||
virtual ~IReplicationPolicy() {}
|
||||
virtual std::string name() const = 0;
|
||||
virtual std::string info() const = 0;
|
||||
virtual void addref() { ReferenceCounted<IReplicationPolicy>::addref(); }
|
||||
virtual void delref() { ReferenceCounted<IReplicationPolicy>::delref(); }
|
||||
virtual int maxResults() const = 0;
|
||||
virtual int depth() const = 0;
|
||||
virtual bool selectReplicas(Reference<LocalitySet>& fromServers, std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry>& results) = 0;
|
||||
virtual void traceLocalityRecords(Reference<LocalitySet> const& fromServers);
|
||||
virtual void traceOneLocalityRecord(Reference<LocalityRecord> record, Reference<LocalitySet> const& fromServers);
|
||||
virtual bool validate(std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers) const = 0;
|
||||
|
||||
bool operator == ( const IReplicationPolicy& r ) const { return info() == r.info(); }
|
||||
bool operator != ( const IReplicationPolicy& r ) const { return info() != r.info(); }
|
||||
bool operator==(const IReplicationPolicy& r) const { return info() == r.info(); }
|
||||
bool operator!=(const IReplicationPolicy& r) const { return info() != r.info(); }
|
||||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
Reference<IReplicationPolicy> refThis(this);
|
||||
serializeReplicationPolicy(ar, refThis);
|
||||
refThis->delref_no_destroy();
|
||||
}
|
||||
virtual void deserializationDone() = 0;
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
Reference<IReplicationPolicy> refThis(this);
|
||||
serializeReplicationPolicy(ar, refThis);
|
||||
refThis->delref_no_destroy();
|
||||
}
|
||||
virtual void deserializationDone() = 0;
|
||||
|
||||
// Utility functions
|
||||
bool selectReplicas(
|
||||
Reference<LocalitySet> & fromServers,
|
||||
std::vector<LocalityEntry> & results );
|
||||
bool validate(
|
||||
Reference<LocalitySet> const& solutionSet ) const;
|
||||
bool validateFull(
|
||||
bool solved,
|
||||
std::vector<LocalityEntry> const& solutionSet,
|
||||
std::vector<LocalityEntry> const& alsoServers,
|
||||
Reference<LocalitySet> const& fromServers );
|
||||
// Utility functions
|
||||
bool selectReplicas(Reference<LocalitySet>& fromServers, std::vector<LocalityEntry>& results);
|
||||
bool validate(Reference<LocalitySet> const& solutionSet) const;
|
||||
bool validateFull(bool solved, std::vector<LocalityEntry> const& solutionSet,
|
||||
std::vector<LocalityEntry> const& alsoServers, Reference<LocalitySet> const& fromServers);
|
||||
|
||||
// Returns a set of the attributes that this policy uses in selection and validation.
|
||||
std::set<std::string> attributeKeys() const
|
||||
{ std::set<std::string> keys; this->attributeKeys(&keys); return keys; }
|
||||
virtual void attributeKeys(std::set<std::string>*) const = 0;
|
||||
// Returns a set of the attributes that this policy uses in selection and validation.
|
||||
std::set<std::string> attributeKeys() const {
|
||||
std::set<std::string> keys;
|
||||
this->attributeKeys(&keys);
|
||||
return keys;
|
||||
}
|
||||
virtual void attributeKeys(std::set<std::string>*) const = 0;
|
||||
};
|
||||
|
||||
template <class Archive>
|
||||
inline void load( Archive& ar, Reference<IReplicationPolicy>& value ) {
|
||||
inline void load(Archive& ar, Reference<IReplicationPolicy>& value) {
|
||||
bool present;
|
||||
ar >> present;
|
||||
if (present) {
|
||||
serializeReplicationPolicy(ar, value);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
value.clear();
|
||||
}
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void save( Archive& ar, const Reference<IReplicationPolicy>& value ) {
|
||||
inline void save(Archive& ar, const Reference<IReplicationPolicy>& value) {
|
||||
bool present = (value.getPtr() != nullptr);
|
||||
ar << present;
|
||||
if (present) {
|
||||
serializeReplicationPolicy(ar, (Reference<IReplicationPolicy>&) value);
|
||||
serializeReplicationPolicy(ar, (Reference<IReplicationPolicy>&)value);
|
||||
}
|
||||
}
|
||||
|
||||
struct PolicyOne : IReplicationPolicy, public ReferenceCounted<PolicyOne> {
|
||||
PolicyOne() {};
|
||||
PolicyOne(){};
|
||||
explicit PolicyOne(const PolicyOne& o) {}
|
||||
virtual ~PolicyOne() {};
|
||||
virtual ~PolicyOne(){};
|
||||
virtual std::string name() const { return "One"; }
|
||||
virtual std::string info() const { return "1"; }
|
||||
virtual int maxResults() const { return 1; }
|
||||
virtual int depth() const { return 1; }
|
||||
virtual bool validate(
|
||||
std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers ) const;
|
||||
virtual bool selectReplicas(
|
||||
Reference<LocalitySet> & fromServers,
|
||||
std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry> & results );
|
||||
virtual bool validate(std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers) const;
|
||||
virtual bool selectReplicas(Reference<LocalitySet>& fromServers, std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry>& results);
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
}
|
||||
void serialize(Ar& ar) {}
|
||||
virtual void deserializationDone() {}
|
||||
virtual void attributeKeys(std::set<std::string>* set) const override { return; }
|
||||
};
|
||||
|
||||
struct PolicyAcross : IReplicationPolicy, public ReferenceCounted<PolicyAcross> {
|
||||
friend struct serializable_traits<PolicyAcross*>;
|
||||
PolicyAcross(int count, std::string const& attribKey, IRepPolicyRef const policy);
|
||||
PolicyAcross(int count, std::string const& attribKey, Reference<IReplicationPolicy> const policy);
|
||||
explicit PolicyAcross();
|
||||
explicit PolicyAcross(const PolicyAcross& other) : PolicyAcross(other._count, other._attribKey, other._policy) {}
|
||||
virtual ~PolicyAcross();
|
||||
virtual std::string name() const { return "Across"; }
|
||||
virtual std::string info() const { return format("%s^%d x ", _attribKey.c_str(), _count) + _policy->info(); }
|
||||
virtual int maxResults() const { return _count * _policy->maxResults(); }
|
||||
virtual int depth() const { return 1 + _policy->depth(); }
|
||||
virtual bool validate(std::vector<LocalityEntry> const& solutionSet, LocalitySetRef const& fromServers) const;
|
||||
virtual bool selectReplicas(LocalitySetRef& fromServers, std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry> & results );
|
||||
virtual int depth() const { return 1 + _policy->depth(); }
|
||||
virtual bool validate(std::vector<LocalityEntry> const& solutionSet, Reference<LocalitySet> const& fromServers) const;
|
||||
virtual bool selectReplicas(Reference<LocalitySet>& fromServers, std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry>& results);
|
||||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
|
@ -153,22 +141,21 @@ struct PolicyAcross : IReplicationPolicy, public ReferenceCounted<PolicyAcross>
|
|||
}
|
||||
|
||||
protected:
|
||||
int _count;
|
||||
std::string _attribKey;
|
||||
IRepPolicyRef _policy;
|
||||
int _count;
|
||||
std::string _attribKey;
|
||||
Reference<IReplicationPolicy> _policy;
|
||||
|
||||
// Cache temporary members
|
||||
std::vector<AttribValue> _usedValues;
|
||||
std::vector<LocalityEntry> _newResults;
|
||||
LocalitySetRef _selected;
|
||||
VectorRef<std::pair<int,int>> _addedResults;
|
||||
Arena _arena;
|
||||
std::vector<AttribValue> _usedValues;
|
||||
std::vector<LocalityEntry> _newResults;
|
||||
Reference<LocalitySet> _selected;
|
||||
VectorRef<std::pair<int, int>> _addedResults;
|
||||
Arena _arena;
|
||||
};
|
||||
|
||||
struct PolicyAnd : IReplicationPolicy, public ReferenceCounted<PolicyAnd> {
|
||||
friend struct serializable_traits<PolicyAnd*>;
|
||||
PolicyAnd(std::vector<IRepPolicyRef> policies): _policies(policies), _sortedPolicies(policies)
|
||||
{
|
||||
PolicyAnd(std::vector<Reference<IReplicationPolicy>> policies) : _policies(policies), _sortedPolicies(policies) {
|
||||
// Sort the policy array
|
||||
std::sort(_sortedPolicies.begin(), _sortedPolicies.end(), PolicyAnd::comparePolicy);
|
||||
}
|
||||
|
@ -177,9 +164,9 @@ struct PolicyAnd : IReplicationPolicy, public ReferenceCounted<PolicyAnd> {
|
|||
virtual ~PolicyAnd() {}
|
||||
virtual std::string name() const { return "And"; }
|
||||
virtual std::string info() const {
|
||||
std::string infoText;
|
||||
std::string infoText;
|
||||
for (auto& policy : _policies) {
|
||||
infoText += ((infoText.length()) ? " & (" : "(") + policy->info() + ")";
|
||||
infoText += ((infoText.length()) ? " & (" : "(") + policy->info() + ")";
|
||||
}
|
||||
if (_policies.size()) infoText = "(" + infoText + ")";
|
||||
return infoText;
|
||||
|
@ -201,27 +188,26 @@ struct PolicyAnd : IReplicationPolicy, public ReferenceCounted<PolicyAnd> {
|
|||
}
|
||||
return depthMax;
|
||||
}
|
||||
virtual bool validate(
|
||||
std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers ) const;
|
||||
virtual bool validate(std::vector<LocalityEntry> const& solutionSet,
|
||||
Reference<LocalitySet> const& fromServers) const;
|
||||
|
||||
virtual bool selectReplicas(
|
||||
Reference<LocalitySet> & fromServers,
|
||||
std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry> & results );
|
||||
virtual bool selectReplicas(Reference<LocalitySet>& fromServers, std::vector<LocalityEntry> const& alsoServers,
|
||||
std::vector<LocalityEntry>& results);
|
||||
|
||||
static bool comparePolicy(const Reference<IReplicationPolicy>& rhs, const Reference<IReplicationPolicy>& lhs)
|
||||
{ return (lhs->maxResults() < rhs->maxResults()) || (!(rhs->maxResults() < lhs->maxResults()) && (lhs->depth() < rhs->depth())); }
|
||||
static bool comparePolicy(const Reference<IReplicationPolicy>& rhs, const Reference<IReplicationPolicy>& lhs) {
|
||||
return (lhs->maxResults() < rhs->maxResults()) ||
|
||||
(!(rhs->maxResults() < lhs->maxResults()) && (lhs->depth() < rhs->depth()));
|
||||
}
|
||||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
int count = _policies.size();
|
||||
serializer(ar, count);
|
||||
_policies.resize(count);
|
||||
for(int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
serializeReplicationPolicy(ar, _policies[i]);
|
||||
}
|
||||
if(Ar::isDeserializing) {
|
||||
if (Ar::isDeserializing) {
|
||||
_sortedPolicies = _policies;
|
||||
std::sort(_sortedPolicies.begin(), _sortedPolicies.end(), PolicyAnd::comparePolicy);
|
||||
}
|
||||
|
@ -232,12 +218,15 @@ struct PolicyAnd : IReplicationPolicy, public ReferenceCounted<PolicyAnd> {
|
|||
std::sort(_sortedPolicies.begin(), _sortedPolicies.end(), PolicyAnd::comparePolicy);
|
||||
}
|
||||
|
||||
virtual void attributeKeys(std::set<std::string> *set) const override
|
||||
{ for (const Reference<IReplicationPolicy>& r : _policies) { r->attributeKeys(set); } }
|
||||
virtual void attributeKeys(std::set<std::string>* set) const override {
|
||||
for (const Reference<IReplicationPolicy>& r : _policies) {
|
||||
r->attributeKeys(set);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<Reference<IReplicationPolicy>> _policies;
|
||||
std::vector<Reference<IReplicationPolicy>> _sortedPolicies;
|
||||
std::vector<Reference<IReplicationPolicy>> _policies;
|
||||
std::vector<Reference<IReplicationPolicy>> _sortedPolicies;
|
||||
};
|
||||
|
||||
extern int testReplication();
|
||||
|
@ -279,8 +268,8 @@ extern int testReplication();
|
|||
};
|
||||
|
||||
template <>
|
||||
struct object_construction<IRepPolicyRef> {
|
||||
using type = IRepPolicyRef;
|
||||
struct object_construction<Reference<IReplicationPolicy>> {
|
||||
using type = Reference<IReplicationPolicy>;
|
||||
type _impl;
|
||||
|
||||
object_construction() : _impl(new PolicyOne()){};
|
||||
|
@ -296,7 +285,7 @@ POLICY_CONSTRUCTION_WRAPPER(PolicyAcross);
|
|||
POLICY_CONSTRUCTION_WRAPPER(PolicyAnd);
|
||||
|
||||
template <>
|
||||
struct FileIdentifierFor<IRepPolicyRef> {
|
||||
struct FileIdentifierFor<Reference<IReplicationPolicy>> {
|
||||
static constexpr FileIdentifier value = 14695621;
|
||||
};
|
||||
|
||||
|
@ -323,9 +312,9 @@ struct serializable_traits<PolicyAnd*> : std::true_type {
|
|||
};
|
||||
|
||||
template <>
|
||||
struct serializable_traits<IRepPolicyRef> : std::true_type {
|
||||
struct serializable_traits<Reference<IReplicationPolicy>> : std::true_type {
|
||||
template <class Archiver>
|
||||
static void serialize(Archiver& ar, IRepPolicyRef& policy) {
|
||||
static void serialize(Archiver& ar, Reference<IReplicationPolicy>& policy) {
|
||||
::serializer(ar, policy.changePtrUnsafe());
|
||||
}
|
||||
};
|
||||
|
@ -374,53 +363,42 @@ struct union_like_traits<IReplicationPolicy*> : std::true_type {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Ar>
|
||||
void serializeReplicationPolicy(Ar& ar, Reference<IReplicationPolicy>& policy) {
|
||||
if(Ar::isDeserializing) {
|
||||
if (Ar::isDeserializing) {
|
||||
StringRef name;
|
||||
serializer(ar, name);
|
||||
|
||||
if(name == LiteralStringRef("One")) {
|
||||
if (name == LiteralStringRef("One")) {
|
||||
PolicyOne* pointer = new PolicyOne();
|
||||
pointer->serialize(ar);
|
||||
policy = Reference<IReplicationPolicy>(pointer);
|
||||
}
|
||||
else if(name == LiteralStringRef("Across")) {
|
||||
} else if (name == LiteralStringRef("Across")) {
|
||||
PolicyAcross* pointer = new PolicyAcross(0, "", Reference<IReplicationPolicy>());
|
||||
pointer->serialize(ar);
|
||||
policy = Reference<IReplicationPolicy>(pointer);
|
||||
}
|
||||
else if(name == LiteralStringRef("And")) {
|
||||
} else if (name == LiteralStringRef("And")) {
|
||||
PolicyAnd* pointer = new PolicyAnd{};
|
||||
pointer->serialize(ar);
|
||||
policy = Reference<IReplicationPolicy>(pointer);
|
||||
}
|
||||
else if(name == LiteralStringRef("None")) {
|
||||
} else if (name == LiteralStringRef("None")) {
|
||||
policy = Reference<IReplicationPolicy>();
|
||||
} else {
|
||||
TraceEvent(SevError, "SerializingInvalidPolicyType").detailext("PolicyName", name);
|
||||
}
|
||||
else {
|
||||
TraceEvent(SevError, "SerializingInvalidPolicyType")
|
||||
.detail("PolicyName", name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
std::string name = policy ? policy->name() : "None";
|
||||
Standalone<StringRef> nameRef = StringRef(name);
|
||||
serializer(ar, nameRef);
|
||||
if(name == "One") {
|
||||
if (name == "One") {
|
||||
((PolicyOne*)policy.getPtr())->serialize(ar);
|
||||
}
|
||||
else if(name == "Across") {
|
||||
} else if (name == "Across") {
|
||||
((PolicyAcross*)policy.getPtr())->serialize(ar);
|
||||
}
|
||||
else if(name == "And") {
|
||||
} else if (name == "And") {
|
||||
((PolicyAnd*)policy.getPtr())->serialize(ar);
|
||||
}
|
||||
else if(name == "None") {}
|
||||
else {
|
||||
TraceEvent(SevError, "SerializingInvalidPolicyType")
|
||||
.detail("PolicyName", name);
|
||||
} else if (name == "None") {
|
||||
} else {
|
||||
TraceEvent(SevError, "SerializingInvalidPolicyType").detail("PolicyName", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,14 +181,14 @@ struct serializable_traits<ReplyPromise<T>> : std::true_type {
|
|||
template<class Archiver>
|
||||
static void serialize(Archiver& ar, ReplyPromise<T>& p) {
|
||||
if constexpr (Archiver::isDeserializing) {
|
||||
Endpoint endpoint;
|
||||
serializer(ar, endpoint);
|
||||
UID token;
|
||||
serializer(ar, token);
|
||||
auto endpoint = FlowTransport::transport().loadedEndpoint(token);
|
||||
p = ReplyPromise<T>(endpoint);
|
||||
networkSender(p.getFuture(), endpoint);
|
||||
} else {
|
||||
const auto& ep = p.getEndpoint();
|
||||
const auto& ep = p.getEndpoint().token;
|
||||
serializer(ar, ep);
|
||||
ASSERT(!ep.getPrimaryAddress().isValid() || ep.getPrimaryAddress().isPublic()); // No re-serializing non-public addresses (the reply connection won't be available to any other process)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -422,7 +422,6 @@ struct serializable_traits<RequestStream<T>> : std::true_type {
|
|||
if constexpr (Archiver::isDeserializing) {
|
||||
Endpoint endpoint;
|
||||
serializer(ar, endpoint);
|
||||
FlowTransport::transport().loadedEndpoint(endpoint);
|
||||
stream = RequestStream<T>(endpoint);
|
||||
} else {
|
||||
const auto& ep = stream.getEndpoint();
|
||||
|
|
|
@ -69,12 +69,12 @@ public:
|
|||
double fault_injection_p1, fault_injection_p2;
|
||||
|
||||
ProcessInfo(const char* name, LocalityData locality, ProcessClass startingClass, NetworkAddressList addresses,
|
||||
INetworkConnections *net, const char* dataFolder, const char* coordinationFolder )
|
||||
: name(name), locality(locality), startingClass(startingClass), useObjectSerializer(useObjectSerializer),
|
||||
addresses(addresses), address(addresses.address), dataFolder(dataFolder),
|
||||
network(net), coordinationFolder(coordinationFolder), failed(false), excluded(false), cpuTicks(0),
|
||||
rebooting(false), fault_injection_p1(0), fault_injection_p2(0),
|
||||
fault_injection_r(0), machine(0), cleared(false) {}
|
||||
INetworkConnections *net, const char* dataFolder, const char* coordinationFolder, bool useObjectSerializer )
|
||||
: name(name), locality(locality), startingClass(startingClass), useObjectSerializer(useObjectSerializer),
|
||||
addresses(addresses), address(addresses.address), dataFolder(dataFolder),
|
||||
network(net), coordinationFolder(coordinationFolder), failed(false), excluded(false), cpuTicks(0),
|
||||
rebooting(false), fault_injection_p1(0), fault_injection_p2(0),
|
||||
fault_injection_r(0), machine(0), cleared(false) {}
|
||||
|
||||
Future<KillType> onShutdown() { return shutdownSignal.getFuture(); }
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ struct serializable_traits<OptionalInterface<Interface>> : std::true_type {
|
|||
|
||||
|
||||
struct TLogSet {
|
||||
constexpr static FileIdentifier file_identifier = 6302317;
|
||||
std::vector<OptionalInterface<TLogInterface>> tLogs;
|
||||
std::vector<OptionalInterface<TLogInterface>> logRouters;
|
||||
int32_t tLogWriteAntiQuorum, tLogReplicationFactor;
|
||||
|
@ -136,17 +137,23 @@ struct TLogSet {
|
|||
|
||||
template <class Ar>
|
||||
void serialize( Ar& ar ) {
|
||||
serializer(ar, tLogs, logRouters, tLogWriteAntiQuorum, tLogReplicationFactor, tLogPolicy, tLogLocalities, isLocal, locality, startVersion, satelliteTagLocations);
|
||||
if (ar.isDeserializing && ar.protocolVersion() < 0x0FDB00B061030001LL) {
|
||||
tLogVersion = TLogVersion::V2;
|
||||
if constexpr (is_fb_function<Ar>) {
|
||||
serializer(ar, tLogs, logRouters, tLogWriteAntiQuorum, tLogReplicationFactor, tLogPolicy, tLogLocalities,
|
||||
isLocal, locality, startVersion, satelliteTagLocations, tLogVersion);
|
||||
} else {
|
||||
serializer(ar, tLogVersion);
|
||||
serializer(ar, tLogs, logRouters, tLogWriteAntiQuorum, tLogReplicationFactor, tLogPolicy, tLogLocalities, isLocal, locality, startVersion, satelliteTagLocations);
|
||||
if (ar.isDeserializing && ar.protocolVersion() < 0x0FDB00B061030001LL) {
|
||||
tLogVersion = TLogVersion::V2;
|
||||
} else {
|
||||
serializer(ar, tLogVersion);
|
||||
}
|
||||
ASSERT(tLogPolicy.getPtr() == nullptr || tLogVersion != TLogVersion::UNSET);
|
||||
}
|
||||
ASSERT(tLogPolicy.getPtr() == nullptr || tLogVersion != TLogVersion::UNSET);
|
||||
}
|
||||
};
|
||||
|
||||
struct OldTLogConf {
|
||||
constexpr static FileIdentifier file_identifier = 16233772;
|
||||
std::vector<TLogSet> tLogs;
|
||||
Version epochEnd;
|
||||
int32_t logRouterTags;
|
||||
|
@ -188,6 +195,7 @@ enum class LogSystemType {
|
|||
BINARY_SERIALIZABLE(LogSystemType);
|
||||
|
||||
struct LogSystemConfig {
|
||||
constexpr static FileIdentifier file_identifier = 16360847;
|
||||
LogSystemType logSystemType;
|
||||
std::vector<TLogSet> tLogs;
|
||||
int32_t logRouterTags;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "fdbrpc/Locality.h"
|
||||
|
||||
struct RatekeeperInterface {
|
||||
constexpr static FileIdentifier file_identifier = 5983305;
|
||||
RequestStream<ReplyPromise<Void>> waitFailure;
|
||||
RequestStream<struct GetRateInfoRequest> getRateInfo;
|
||||
RequestStream<struct HaltRatekeeperRequest> haltRatekeeper;
|
||||
|
@ -52,6 +53,7 @@ struct RatekeeperInterface {
|
|||
};
|
||||
|
||||
struct GetRateInfoRequest {
|
||||
constexpr static FileIdentifier file_identifier = 9068521;
|
||||
UID requesterID;
|
||||
int64_t totalReleasedTransactions;
|
||||
int64_t batchReleasedTransactions;
|
||||
|
@ -69,6 +71,7 @@ struct GetRateInfoRequest {
|
|||
};
|
||||
|
||||
struct GetRateInfoReply {
|
||||
constexpr static FileIdentifier file_identifier = 7845006;
|
||||
double transactionRate;
|
||||
double batchTransactionRate;
|
||||
double leaseDuration;
|
||||
|
@ -81,6 +84,7 @@ struct GetRateInfoReply {
|
|||
};
|
||||
|
||||
struct HaltRatekeeperRequest {
|
||||
constexpr static FileIdentifier file_identifier = 6997218;
|
||||
UID requesterID;
|
||||
ReplyPromise<Void> reply;
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ struct WorkerInterface {
|
|||
};
|
||||
|
||||
struct WorkerDetails {
|
||||
constexpr static FileIdentifier file_identifier = 9973980;
|
||||
WorkerInterface interf;
|
||||
ProcessClass processClass;
|
||||
bool degraded;
|
||||
|
@ -178,6 +179,7 @@ struct InitializeDataDistributorRequest {
|
|||
};
|
||||
|
||||
struct InitializeRatekeeperRequest {
|
||||
constexpr static FileIdentifier file_identifier = 6416816;
|
||||
UID reqId;
|
||||
ReplyPromise<RatekeeperInterface> reply;
|
||||
|
||||
|
|
19
flow/Arena.h
19
flow/Arena.h
|
@ -349,6 +349,7 @@ inline void save( Archive& ar, const Arena& p ) {
|
|||
template <class T>
|
||||
class Optional {
|
||||
public:
|
||||
static constexpr FileIdentifier file_identifier = (0x10 << 24) | FileIdentifierFor<T>::value;
|
||||
Optional() : valid(false) {}
|
||||
Optional(const Optional<T>& o) : valid(o.valid) {
|
||||
if (valid) new (&value) T(o.get());
|
||||
|
@ -440,6 +441,24 @@ template<class T>
|
|||
struct Traceable<Optional<T>> : std::conditional<Traceable<T>::value, std::true_type, std::false_type>::type {
|
||||
static std::string toString(const Optional<T>& value) {
|
||||
return value.present() ? Traceable<T>::toString(value.get()) : "[not set]";
|
||||
}
|
||||
};
|
||||
|
||||
struct union_like_traits<Optional<T>> : std::true_type {
|
||||
using Member = Optional<T>;
|
||||
using alternatives = pack<T>;
|
||||
static uint8_t index(const Member& variant) { return 0; }
|
||||
static bool empty(const Member& variant) { return !variant.present(); }
|
||||
|
||||
template <int i>
|
||||
static const T& get(const Member& variant) {
|
||||
static_assert(i == 0);
|
||||
return variant.get();
|
||||
}
|
||||
|
||||
template <size_t i>
|
||||
static const void assign(Member& member, const T& t) {
|
||||
member = t;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <memory>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <variant>
|
||||
|
||||
template <class T, typename = void>
|
||||
struct is_fb_function_t : std::false_type {};
|
||||
|
@ -176,4 +177,23 @@ struct struct_like_traits : std::false_type {
|
|||
static void done(Member&, Context&);
|
||||
};
|
||||
|
||||
template <class... Alternatives>
|
||||
struct union_like_traits<std::variant<Alternatives...>> : std::true_type {
|
||||
using Member = std::variant<Alternatives...>;
|
||||
using alternatives = pack<Alternatives...>;
|
||||
static uint8_t index(const Member& variant) { return variant.index(); }
|
||||
static bool empty(const Member& variant) { return false; }
|
||||
|
||||
template <int i>
|
||||
static const index_t<i, alternatives>& get(const Member& variant) {
|
||||
return std::get<index_t<i, alternatives>>(variant);
|
||||
}
|
||||
|
||||
template <size_t i, class Alternative>
|
||||
static const void assign(Member& member, const Alternative& a) {
|
||||
static_assert(std::is_same_v<index_t<i, alternatives>, Alternative>);
|
||||
member = a;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,20 +24,8 @@
|
|||
#include "flow/flow.h"
|
||||
#include "flow/UnitTest.h"
|
||||
|
||||
IPAddress::IPAddress() : isV6addr(false) {
|
||||
addr.v4 = 0;
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(const IPAddressStore& v6addr) : isV6addr(true) {
|
||||
addr.v6 = v6addr;
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(uint32_t v4addr) : isV6addr(false) {
|
||||
addr.v4 = v4addr;
|
||||
}
|
||||
|
||||
bool IPAddress::operator==(const IPAddress& rhs) const {
|
||||
return isV6addr == rhs.isV6addr && (isV6addr ? addr.v6 == rhs.addr.v6 : addr.v4 == rhs.addr.v4);
|
||||
return addr == rhs.addr;
|
||||
}
|
||||
|
||||
bool IPAddress::operator!=(const IPAddress& addr) const {
|
||||
|
@ -45,20 +33,15 @@ bool IPAddress::operator!=(const IPAddress& addr) const {
|
|||
}
|
||||
|
||||
bool IPAddress::operator<(const IPAddress& rhs) const {
|
||||
if(isV6addr != rhs.isV6addr) {
|
||||
return isV6addr < rhs.isV6addr;
|
||||
}
|
||||
if(isV6addr) {
|
||||
return addr.v6 < rhs.addr.v6;
|
||||
}
|
||||
return addr.v4 < rhs.addr.v4;
|
||||
return addr < rhs.addr;
|
||||
}
|
||||
|
||||
std::string IPAddress::toString() const {
|
||||
if (isV6addr) {
|
||||
return boost::asio::ip::address_v6(addr.v6).to_string();
|
||||
if (isV6()) {
|
||||
return boost::asio::ip::address_v6(std::get<IPAddressStore>(addr)).to_string();
|
||||
} else {
|
||||
return format("%d.%d.%d.%d", (addr.v4 >> 24) & 0xff, (addr.v4 >> 16) & 0xff, (addr.v4 >> 8) & 0xff, addr.v4 & 0xff);
|
||||
auto ip = std::get<uint32_t>(addr);
|
||||
return format("%d.%d.%d.%d", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,10 +55,11 @@ Optional<IPAddress> IPAddress::parse(std::string str) {
|
|||
}
|
||||
|
||||
bool IPAddress::isValid() const {
|
||||
if (isV6addr) {
|
||||
return std::any_of(addr.v6.begin(), addr.v6.end(), [](uint8_t part) { return part != 0; });
|
||||
if (isV6()) {
|
||||
const auto& ip = std::get<IPAddressStore>(addr);
|
||||
return std::any_of(ip.begin(), ip.end(), [](uint8_t part) { return part != 0; });
|
||||
}
|
||||
return addr.v4 != 0;
|
||||
return std::get<uint32_t>(addr) != 0;
|
||||
}
|
||||
|
||||
NetworkAddress NetworkAddress::parse( std::string const& s ) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <array>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
#include "boost/asio.hpp"
|
||||
#include "flow/serialize.h"
|
||||
#include "flow/IRandom.h"
|
||||
|
@ -91,36 +92,18 @@ struct IPAddress {
|
|||
static_assert(std::is_same<IPAddressStore, std::array<uint8_t, 16>>::value,
|
||||
"IPAddressStore must be std::array<uint8_t, 16>");
|
||||
|
||||
IPAddress();
|
||||
explicit IPAddress(const IPAddressStore& v6addr);
|
||||
explicit IPAddress(uint32_t v4addr);
|
||||
IPAddress() : addr(uint32_t(0)) {}
|
||||
explicit IPAddress(const IPAddressStore& v6addr) : addr(v6addr) {}
|
||||
explicit IPAddress(uint32_t v4addr) : addr(v4addr) {}
|
||||
|
||||
bool isV6() const { return isV6addr; }
|
||||
bool isV4() const { return !isV6addr; }
|
||||
bool isV6() const { return std::holds_alternative<IPAddressStore>(addr); }
|
||||
bool isV4() const { return !isV6(); }
|
||||
bool isValid() const;
|
||||
|
||||
IPAddress(const IPAddress& rhs) : isV6addr(rhs.isV6addr) {
|
||||
if(isV6addr) {
|
||||
addr.v6 = rhs.addr.v6;
|
||||
} else {
|
||||
addr.v4 = rhs.addr.v4;
|
||||
}
|
||||
}
|
||||
|
||||
IPAddress& operator=(const IPAddress& rhs) {
|
||||
isV6addr = rhs.isV6addr;
|
||||
if(isV6addr) {
|
||||
addr.v6 = rhs.addr.v6;
|
||||
} else {
|
||||
addr.v4 = rhs.addr.v4;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Returns raw v4/v6 representation of address. Caller is responsible
|
||||
// to call these functions safely.
|
||||
uint32_t toV4() const { return addr.v4; }
|
||||
const IPAddressStore& toV6() const { return addr.v6; }
|
||||
uint32_t toV4() const { return std::get<uint32_t>(addr); }
|
||||
const IPAddressStore& toV6() const { return std::get<IPAddressStore>(addr); }
|
||||
|
||||
std::string toString() const;
|
||||
static Optional<IPAddress> parse(std::string str);
|
||||
|
@ -131,20 +114,35 @@ struct IPAddress {
|
|||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
serializer(ar, isV6addr);
|
||||
if(isV6addr) {
|
||||
serializer(ar, addr.v6);
|
||||
if constexpr (is_fb_function<Ar>) {
|
||||
serializer(ar, addr);
|
||||
} else {
|
||||
serializer(ar, addr.v4);
|
||||
bool v6 = isV6();
|
||||
serializer(ar, v6);
|
||||
if (v6) {
|
||||
serializer(ar, std::get<IPAddressStore>(addr));
|
||||
} else {
|
||||
serializer(ar, std::get<uint32_t>(addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool isV6addr;
|
||||
union {
|
||||
uint32_t v4;
|
||||
IPAddressStore v6;
|
||||
} addr;
|
||||
std::variant<uint32_t, IPAddressStore> addr;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct vector_like_traits<IPAddress::IPAddressStore> : std::true_type {
|
||||
using type = IPAddress::IPAddressStore;
|
||||
using value_type = uint8_t;
|
||||
using iterator = typename type::const_iterator;
|
||||
using insert_iterator = typename type::iterator;
|
||||
|
||||
static size_t num_entries(const type&) { return 16; }
|
||||
template <class Context>
|
||||
static void reserve(type&, size_t, Context&) {}
|
||||
static insert_iterator insert(type& value) { return value.begin(); }
|
||||
static iterator begin(const type& value) { return value.begin(); }
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -155,6 +153,7 @@ struct Traceable<IPAddress> : std::true_type {
|
|||
};
|
||||
|
||||
struct NetworkAddress {
|
||||
constexpr static FileIdentifier file_identifier = 14155727;
|
||||
// A NetworkAddress identifies a particular running server (i.e. a TCP endpoint).
|
||||
IPAddress ip;
|
||||
uint16_t port;
|
||||
|
@ -192,12 +191,16 @@ struct NetworkAddress {
|
|||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
if (ar.isDeserializing && ar.protocolVersion() < 0x0FDB00B061030001LL) {
|
||||
uint32_t ipV4;
|
||||
serializer(ar, ipV4, port, flags);
|
||||
ip = IPAddress(ipV4);
|
||||
} else {
|
||||
if constexpr (is_fb_function<Ar>) {
|
||||
serializer(ar, ip, port, flags);
|
||||
} else {
|
||||
if (ar.isDeserializing && ar.protocolVersion() < 0x0FDB00B061030001LL) {
|
||||
uint32_t ipV4;
|
||||
serializer(ar, ipV4, port, flags);
|
||||
ip = IPAddress(ipV4);
|
||||
} else {
|
||||
serializer(ar, ip, port, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue