From 6a4d87802bcc2ddfec4233a57589751db113d4d6 Mon Sep 17 00:00:00 2001 From: anoyes Date: Fri, 28 Dec 2018 10:49:26 -0800 Subject: [PATCH] Replace & operator with variadic function --- bindings/flow/FDBLoanerTypes.h | 8 +-- fdbclient/BackupAgent.h | 2 +- fdbclient/ClientDBInfo.h | 4 +- fdbclient/ClientLogEvents.h | 30 +++++----- fdbclient/ClientWorkerInterface.h | 6 +- fdbclient/ClusterInterface.h | 20 +++---- fdbclient/CommitTransaction.h | 4 +- fdbclient/CoordinationInterface.h | 4 +- fdbclient/DatabaseConfiguration.h | 8 +-- fdbclient/FDBTypes.h | 18 +++--- fdbclient/MasterProxyInterface.h | 22 ++++---- fdbclient/MutationList.h | 4 +- fdbclient/StorageServerInterface.h | 38 ++++++------- fdbrpc/EndpointGroup.h | 74 ------------------------- fdbrpc/FailureMonitor.h | 4 +- fdbrpc/LoadBalance.actor.h | 2 +- fdbrpc/Locality.h | 16 +++--- fdbrpc/PerfMetric.h | 4 +- fdbrpc/ReplicationPolicy.h | 8 +-- fdbrpc/dsltest.actor.cpp | 4 +- fdbrpc/fdbrpc.vcxproj | 1 - fdbrpc/fdbrpc.vcxproj.filters | 1 - fdbserver/ClusterRecruitmentInterface.h | 24 ++++---- fdbserver/CoordinatedState.actor.cpp | 4 +- fdbserver/Coordination.actor.cpp | 2 +- fdbserver/CoordinationInterface.h | 16 +++--- fdbserver/DBCoreState.h | 14 ++--- fdbserver/LogProtocolMessage.h | 4 +- fdbserver/LogSystemConfig.h | 10 ++-- fdbserver/MasterInterface.h | 20 +++---- fdbserver/MoveKeys.h | 4 +- fdbserver/NetworkTest.h | 6 +- fdbserver/OldTLogServer.actor.cpp | 6 +- fdbserver/ResolverInterface.h | 14 ++--- fdbserver/RestoreInterface.h | 6 +- fdbserver/ServerDBInfo.h | 2 +- fdbserver/TLogInterface.h | 28 +++++----- fdbserver/TLogServer.actor.cpp | 6 +- fdbserver/TesterInterface.h | 6 +- fdbserver/WorkerInterface.h | 32 +++++------ fdbserver/pubsub.h | 2 +- fdbserver/workloads/Ping.actor.cpp | 2 +- fdbserver/workloads/Sideband.actor.cpp | 4 +- flow/Arena.h | 2 +- flow/CompressedInt.h | 6 +- flow/Error.h | 2 +- flow/IRandom.h | 2 +- flow/Net2.actor.cpp | 2 +- flow/README.md | 2 +- flow/TDMetric.actor.h | 8 +-- flow/flow.h | 8 +-- flow/serialize.h | 15 +++-- 52 files changed, 235 insertions(+), 306 deletions(-) delete mode 100644 fdbrpc/EndpointGroup.h diff --git a/bindings/flow/FDBLoanerTypes.h b/bindings/flow/FDBLoanerTypes.h index 4797f863c5..a5be056b20 100755 --- a/bindings/flow/FDBLoanerTypes.h +++ b/bindings/flow/FDBLoanerTypes.h @@ -87,7 +87,7 @@ namespace FDB { template void serialize( Ar& ar ) { - ar & key & orEqual & offset; + serializer(ar, key, orEqual, offset); } }; inline bool operator == (const KeySelectorRef& lhs, const KeySelectorRef& rhs) { return lhs.key == rhs.key && lhs.orEqual==rhs.orEqual && lhs.offset==rhs.offset; } @@ -123,7 +123,7 @@ namespace FDB { int expectedSize() const { return key.expectedSize() + value.expectedSize(); } template - force_inline void serialize(Ar& ar) { ar & key & value; } + force_inline void serialize(Ar& ar) { serializer(ar, key, value); } struct OrderByKey { bool operator()(KeyValueRef const& a, KeyValueRef const& b) const { @@ -171,7 +171,7 @@ namespace FDB { template void serialize( Ar& ar ) { - ar & ((VectorRef&)*this) & more & readThrough & readToBegin & readThroughEnd; + serializer(ar, ((VectorRef&)*this), more, readThrough, readToBegin, readThroughEnd); } }; @@ -234,7 +234,7 @@ namespace FDB { template force_inline void serialize(Ar& ar) { - ar & const_cast(begin) & const_cast(end); + serializer(ar, const_cast(begin), const_cast(end)); if( begin > end ) { throw inverted_range(); }; diff --git a/fdbclient/BackupAgent.h b/fdbclient/BackupAgent.h index 674096e470..7d7e05ad82 100644 --- a/fdbclient/BackupAgent.h +++ b/fdbclient/BackupAgent.h @@ -415,7 +415,7 @@ struct RCGroup { template void serialize(Ar& ar) { - ar & items & version & groupKey; + serializer(ar, items, version, groupKey); } }; diff --git a/fdbclient/ClientDBInfo.h b/fdbclient/ClientDBInfo.h index a6bc7d20bb..7b6aa047f8 100644 --- a/fdbclient/ClientDBInfo.h +++ b/fdbclient/ClientDBInfo.h @@ -39,8 +39,8 @@ struct ClientDBInfo { template void serialize(Archive& ar) { ASSERT( ar.protocolVersion() >= 0x0FDB00A200040001LL ); - ar & proxies & id & clientTxnInfoSampleRate & clientTxnInfoSizeLimit; + serializer(ar, proxies, id, clientTxnInfoSampleRate, clientTxnInfoSizeLimit); } }; -#endif \ No newline at end of file +#endif diff --git a/fdbclient/ClientLogEvents.h b/fdbclient/ClientLogEvents.h index c54ead5cfe..09d1685e52 100644 --- a/fdbclient/ClientLogEvents.h +++ b/fdbclient/ClientLogEvents.h @@ -39,7 +39,7 @@ namespace FdbClientLogEvents { Event(EventType t, double ts) : type(t), startTs(ts) { } Event() { } - template Ar& serialize(Ar &ar) { return ar & type & startTs; } + template Ar& serialize(Ar &ar) { return serializer(ar, type, startTs); } EventType type{ EVENTTYPEEND }; double startTs{ 0 }; @@ -53,9 +53,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & latency; + return serializer(Event::serialize(ar), latency); else - return ar & latency; + return serializer(ar, latency); } double latency; @@ -71,9 +71,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & latency & valueSize & key; + return serializer(Event::serialize(ar), latency, valueSize, key); else - return ar & latency & valueSize & key; + return serializer(ar, latency, valueSize, key); } double latency; @@ -91,9 +91,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & latency & rangeSize & startKey & endKey; + return serializer(Event::serialize(ar), latency, rangeSize, startKey, endKey); else - return ar & latency & rangeSize & startKey & endKey; + return serializer(ar, latency, rangeSize, startKey, endKey); } double latency; @@ -112,9 +112,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & latency & numMutations & commitBytes & req.transaction & req.arena; + return serializer(Event::serialize(ar), latency, numMutations, commitBytes, req.transaction, req.arena); else - return ar & latency & numMutations & commitBytes & req.transaction & req.arena; + return serializer(ar, latency, numMutations, commitBytes, req.transaction, req.arena); } double latency; @@ -145,9 +145,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & errCode & key; + return serializer(Event::serialize(ar), errCode, key); else - return ar & errCode & key; + return serializer(ar, errCode, key); } int errCode; @@ -164,9 +164,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & errCode & startKey & endKey; + return serializer(Event::serialize(ar), errCode, startKey, endKey); else - return ar & errCode & startKey & endKey; + return serializer(ar, errCode, startKey, endKey); } int errCode; @@ -184,9 +184,9 @@ namespace FdbClientLogEvents { template Ar& serialize(Ar &ar) { if (!ar.isDeserializing) - return Event::serialize(ar) & errCode & req.transaction & req.arena; + return serializer(Event::serialize(ar), errCode, req.transaction, req.arena); else - return ar & errCode & req.transaction & req.arena; + return serializer(ar, errCode, req.transaction, req.arena); } int errCode; diff --git a/fdbclient/ClientWorkerInterface.h b/fdbclient/ClientWorkerInterface.h index 9b221c4755..9c75c31b24 100644 --- a/fdbclient/ClientWorkerInterface.h +++ b/fdbclient/ClientWorkerInterface.h @@ -40,7 +40,7 @@ struct ClientWorkerInterface { template void serialize( Ar& ar ) { - ar & reboot & profiler; + serializer(ar, reboot, profiler); } }; @@ -52,7 +52,7 @@ struct RebootRequest { template void serialize(Ar& ar) { - ar & deleteData & checkData; + serializer(ar, deleteData, checkData); } }; @@ -77,7 +77,7 @@ struct ProfilerRequest { template void serialize( Ar& ar ) { - ar & reply & type & action & duration & outputFile; + serializer(ar, reply, type, action, duration, outputFile); } }; BINARY_SERIALIZABLE( ProfilerRequest::Type ); diff --git a/fdbclient/ClusterInterface.h b/fdbclient/ClusterInterface.h index c55e4c08fb..f0a71f4bfc 100755 --- a/fdbclient/ClusterInterface.h +++ b/fdbclient/ClusterInterface.h @@ -52,7 +52,7 @@ struct ClusterInterface { template void serialize( Ar& ar ) { - ar & openDatabase & failureMonitoring & databaseStatus & ping & getClientWorkers & forceRecovery; + serializer(ar, openDatabase, failureMonitoring, databaseStatus, ping, getClientWorkers, forceRecovery); } }; @@ -93,7 +93,7 @@ struct ClientVersionRef { template void serialize(Ar& ar) { - ar & clientVersion & sourceVersion & protocolVersion; + serializer(ar, clientVersion, sourceVersion, protocolVersion); } size_t expectedSize() const { return clientVersion.size() + sourceVersion.size() + protocolVersion.size(); } @@ -125,7 +125,7 @@ struct OpenDatabaseRequest { template void serialize(Ar& ar) { ASSERT( ar.protocolVersion() >= 0x0FDB00A400040001LL ); - ar & issues & supportedVersions & traceLogGroup & knownClientInfoID & reply & arena; + serializer(ar, issues, supportedVersions, traceLogGroup, knownClientInfoID, reply, arena); } }; @@ -138,7 +138,7 @@ struct SystemFailureStatus { template void serialize(Ar& ar) { - ar & address & status; + serializer(ar, address, status); } }; @@ -159,7 +159,7 @@ struct FailureMonitoringRequest { template void serialize(Ar& ar) { - ar & senderStatus & failureInformationVersion & reply; + serializer(ar, senderStatus, failureInformationVersion, reply); } }; @@ -173,7 +173,7 @@ struct FailureMonitoringReply { template void serialize(Ar& ar) { - ar & changes & failureInformationVersion & allOthersFailed & clientRequestIntervalMS & considerServerFailedTimeoutMS & arena; + serializer(ar, changes, failureInformationVersion, allOthersFailed, clientRequestIntervalMS, considerServerFailedTimeoutMS, arena); } }; @@ -182,7 +182,7 @@ struct StatusRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -196,7 +196,7 @@ struct StatusReply { template void serialize(Ar& ar) { - ar & statusStr; + serializer(ar, statusStr); if( ar.isDeserializing ) { json_spirit::mValue mv; if(g_network->isSimulated()) { @@ -218,7 +218,7 @@ struct GetClientWorkersRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -229,7 +229,7 @@ struct ForceRecoveryRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; diff --git a/fdbclient/CommitTransaction.h b/fdbclient/CommitTransaction.h index 444078e180..440e0aa909 100644 --- a/fdbclient/CommitTransaction.h +++ b/fdbclient/CommitTransaction.h @@ -50,7 +50,7 @@ struct MutationRef { template void serialize( Ar& ar ) { - ar & type & param1 & param2; + serializer(ar, type, param1, param2); } // These masks define which mutation types have particular properties (they are used to implement isSingleKeyMutation() etc) @@ -101,7 +101,7 @@ struct CommitTransactionRef { template force_inline void serialize( Ar& ar ) { - ar & read_conflict_ranges & write_conflict_ranges & mutations & read_snapshot; + serializer(ar, read_conflict_ranges, write_conflict_ranges, mutations, read_snapshot); } // Convenience for internal code required to manipulate these without the Native API diff --git a/fdbclient/CoordinationInterface.h b/fdbclient/CoordinationInterface.h index f45eb37f00..dd1c73ef6e 100644 --- a/fdbclient/CoordinationInterface.h +++ b/fdbclient/CoordinationInterface.h @@ -122,7 +122,7 @@ struct LeaderInfo { template void serialize(Ar& ar) { - ar & changeID & serializedInfo & forward; + serializer(ar, changeID, serializedInfo, forward); } }; @@ -136,7 +136,7 @@ struct GetLeaderRequest { template void serialize(Ar& ar) { - ar & key & knownLeader & reply; + serializer(ar, key, knownLeader, reply); } }; diff --git a/fdbclient/DatabaseConfiguration.h b/fdbclient/DatabaseConfiguration.h index dc0b3d5832..740cd376f0 100644 --- a/fdbclient/DatabaseConfiguration.h +++ b/fdbclient/DatabaseConfiguration.h @@ -41,7 +41,7 @@ struct SatelliteInfo { template void serialize(Ar& ar) { - ar & dcId & priority; + serializer(ar, dcId, priority); } }; @@ -71,8 +71,8 @@ struct RegionInfo { template void serialize(Ar& ar) { - ar & dcId & priority & satelliteTLogPolicy & satelliteDesiredTLogCount & satelliteTLogReplicationFactor & satelliteTLogWriteAntiQuorum & satelliteTLogUsableDcs & - satelliteTLogPolicyFallback & satelliteTLogReplicationFactorFallback & satelliteTLogWriteAntiQuorumFallback & satelliteTLogUsableDcsFallback & satellites; + serializer(ar, dcId, priority, satelliteTLogPolicy, satelliteDesiredTLogCount, satelliteTLogReplicationFactor, satelliteTLogWriteAntiQuorum, satelliteTLogUsableDcs, + satelliteTLogPolicyFallback, satelliteTLogReplicationFactorFallback, satelliteTLogWriteAntiQuorumFallback, satelliteTLogUsableDcsFallback, satellites); } }; @@ -203,7 +203,7 @@ struct DatabaseConfiguration { template void serialize(Ar& ar) { if (!ar.isDeserializing) makeConfigurationImmutable(); - ar & rawConfiguration; + serializer(ar, rawConfiguration); if (ar.isDeserializing) { for(auto c=rawConfiguration.begin(); c!=rawConfiguration.end(); ++c) setInternal(c->key, c->value); diff --git a/fdbclient/FDBTypes.h b/fdbclient/FDBTypes.h index e468ee2fbb..5ac49fd58e 100644 --- a/fdbclient/FDBTypes.h +++ b/fdbclient/FDBTypes.h @@ -53,7 +53,7 @@ struct Tag { template force_inline void serialize_unversioned(Ar& ar) { - ar & locality & id; + serializer(ar, locality, id); } }; #pragma pack(pop) @@ -193,7 +193,7 @@ struct KeyRangeRef { template force_inline void serialize(Ar& ar) { - ar & const_cast(begin) & const_cast(end); + serializer(ar, const_cast(begin), const_cast(end)); if( begin > end ) { throw inverted_range(); }; @@ -227,7 +227,7 @@ struct KeyValueRef { int expectedSize() const { return key.expectedSize() + value.expectedSize(); } template - force_inline void serialize(Ar& ar) { ar & key & value; } + force_inline void serialize(Ar& ar) { serializer(ar, key, value); } struct OrderByKey { bool operator()(KeyValueRef const& a, KeyValueRef const& b) const { @@ -385,7 +385,7 @@ public: template void serialize( Ar& ar ) { - ar & key & orEqual & offset; + serializer(ar, key, orEqual, offset); } }; @@ -418,7 +418,7 @@ struct KeyRangeWith : KeyRange { template void serialize( Ar& ar ) { - ar & ((KeyRange&)*this) & value; + serializer(ar, ((KeyRange&)*this), value); } }; template @@ -470,7 +470,7 @@ struct RangeResultRef : VectorRef { template void serialize( Ar& ar ) { - ar & ((VectorRef&)*this) & more & readThrough & readToBegin & readThroughEnd; + serializer(ar, ((VectorRef&)*this), more, readThrough, readToBegin, readThroughEnd); } }; @@ -492,7 +492,7 @@ struct KeyValueStoreType { operator StoreType() const { return StoreType(type); } template - void serialize(Ar& ar) { ar & type; } + void serialize(Ar& ar) { serializer(ar, type); } std::string toString() const { switch( type ) { @@ -520,7 +520,7 @@ struct StorageBytes { template void serialize(Ar& ar) { - ar & free & total & used & available; + serializer(ar, free, total, used, available); } }; @@ -639,7 +639,7 @@ struct ClusterControllerPriorityInfo { template void serialize(Ar& ar) { - ar & processClassFitness & isExcluded & dcFitness; + serializer(ar, processClassFitness, isExcluded, dcFitness); } }; diff --git a/fdbclient/MasterProxyInterface.h b/fdbclient/MasterProxyInterface.h index 3208ac0661..4da1389881 100644 --- a/fdbclient/MasterProxyInterface.h +++ b/fdbclient/MasterProxyInterface.h @@ -50,7 +50,7 @@ struct MasterProxyInterface { template void serialize(Archive& ar) { - ar & locality & commit & getConsistentReadVersion & getKeyServersLocations & waitFailure & getStorageServerRejoinInfo & getRawCommittedVersion & txnState; + serializer(ar, locality, commit, getConsistentReadVersion, getKeyServersLocations, waitFailure, getStorageServerRejoinInfo, getRawCommittedVersion, txnState); } void initEndpoints() { @@ -67,7 +67,7 @@ struct CommitID { template void serialize(Ar& ar) { - ar & version & txnBatchId; + serializer(ar, version, txnBatchId); } CommitID() : version(invalidVersion), txnBatchId(0) {} @@ -93,7 +93,7 @@ struct CommitTransactionRequest { template void serialize(Ar& ar) { - ar & transaction & reply & arena & flags & debugID; + serializer(ar, transaction, reply, arena, flags, debugID); } }; @@ -116,7 +116,7 @@ struct GetReadVersionReply { template void serialize(Ar& ar) { - ar & version & locked; + serializer(ar, version, locked); } }; @@ -144,7 +144,7 @@ struct GetReadVersionRequest { template void serialize(Ar& ar) { - ar & transactionCount & flags & debugID & reply; + serializer(ar, transactionCount, flags, debugID, reply); } }; @@ -154,7 +154,7 @@ struct GetKeyServerLocationsReply { template void serialize(Ar& ar) { - ar & results & arena; + serializer(ar, results, arena); } }; @@ -171,7 +171,7 @@ struct GetKeyServerLocationsRequest { template void serialize(Ar& ar) { - ar & begin & end & limit & reverse & reply & arena; + serializer(ar, begin, end, limit, reverse, reply, arena); } }; @@ -183,7 +183,7 @@ struct GetRawCommittedVersionRequest { template void serialize( Ar& ar ) { - ar & debugID & reply; + serializer(ar, debugID, reply); } }; @@ -196,7 +196,7 @@ struct GetStorageServerRejoinInfoReply { template void serialize(Ar& ar) { - ar & version & tag & newTag & newLocality & history; + serializer(ar, version, tag, newTag, newLocality, history); } }; @@ -210,7 +210,7 @@ struct GetStorageServerRejoinInfoRequest { template void serialize( Ar& ar ) { - ar & id & dcId & reply; + serializer(ar, id, dcId, reply); } }; @@ -223,7 +223,7 @@ struct TxnStateRequest { template void serialize(Ar& ar) { - ar & data & sequence & last & reply & arena; + serializer(ar, data, sequence, last, reply, arena); } }; diff --git a/fdbclient/MutationList.h b/fdbclient/MutationList.h index 0caec14b18..47a564846f 100644 --- a/fdbclient/MutationList.h +++ b/fdbclient/MutationList.h @@ -132,7 +132,7 @@ public: template void serialize_load( Ar& ar ) { - ar & totalBytes; + serializer(ar, totalBytes); if(totalBytes > 0) { blob_begin = blob_end = new (ar.arena()) Blob; @@ -142,7 +142,7 @@ public: } template void serialize_save( Ar& ar ) const { - ar & totalBytes; + serializer(ar, totalBytes); for(auto b = blob_begin; b; b=b->next) ar.serializeBytes(b->data); } diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index a3d655644f..c0da36a6b6 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -68,11 +68,11 @@ struct StorageServerInterface { void serialize( Ar& ar ) { // StorageServerInterface is persisted in the database and in the tLog's data structures, so changes here have to be // versioned carefully! - ar & uniqueID & locality & getVersion & getValue & getKey & getKeyValues & getShardState & waitMetrics - & splitMetrics & getPhysicalMetrics & waitFailure & getQueuingMetrics & getKeyValueStoreType; + serializer(ar, uniqueID, locality, getVersion, getValue, getKey, getKeyValues, getShardState, waitMetrics, + splitMetrics, getPhysicalMetrics, waitFailure, getQueuingMetrics, getKeyValueStoreType); if( ar.protocolVersion() >= 0x0FDB00A200090001LL ) - ar & watchValue; + serializer(ar, watchValue); } bool operator == (StorageServerInterface const& s) const { return uniqueID == s.uniqueID; } bool operator < (StorageServerInterface const& s) const { return uniqueID < s.uniqueID; } @@ -103,7 +103,7 @@ struct GetValueReply : public LoadBalancedReply { template void serialize( Ar& ar ) { - ar & *(LoadBalancedReply*)this & value; + serializer(ar, *(LoadBalancedReply*)this, value); } }; @@ -118,7 +118,7 @@ struct GetValueRequest { template void serialize( Ar& ar ) { - ar & key & version & debugID & reply; + serializer(ar, key, version, debugID, reply); } }; @@ -134,7 +134,7 @@ struct WatchValueRequest { template void serialize( Ar& ar ) { - ar & key & value & version & debugID & reply; + serializer(ar, key, value, version, debugID, reply); } }; @@ -146,7 +146,7 @@ struct GetKeyValuesReply : public LoadBalancedReply { template void serialize( Ar& ar ) { - ar & *(LoadBalancedReply*)this & data & version & more & arena; + serializer(ar, *(LoadBalancedReply*)this, data, version, more, arena); } }; @@ -162,7 +162,7 @@ struct GetKeyValuesRequest { // GetKeyValuesRequest(const KeySelectorRef& begin, const KeySelectorRef& end, Version version, int limit, int limitBytes, Optional debugID) : begin(begin), end(end), version(version), limit(limit), limitBytes(limitBytes) {} template void serialize( Ar& ar ) { - ar & begin & end & version & limit & limitBytes & debugID & reply & arena; + serializer(ar, begin, end, version, limit, limitBytes, debugID, reply, arena); } }; @@ -174,7 +174,7 @@ struct GetKeyReply : public LoadBalancedReply { template void serialize( Ar& ar ) { - ar & *(LoadBalancedReply*)this & sel; + serializer(ar, *(LoadBalancedReply*)this, sel); } }; @@ -189,7 +189,7 @@ struct GetKeyRequest { template void serialize( Ar& ar ) { - ar & sel & version & reply & arena; + serializer(ar, sel, version, reply, arena); } }; @@ -208,7 +208,7 @@ struct GetShardStateRequest { template void serialize( Ar& ar ) { - ar & keys & mode & reply; + serializer(ar, keys, mode, reply); } }; @@ -244,7 +244,7 @@ struct StorageMetrics { template void serialize( Ar& ar ) { - ar & bytes & bytesPerKSecond & iosPerKSecond; + serializer(ar, bytes, bytesPerKSecond, iosPerKSecond); } void negate() { operator*=(-1.0); } @@ -278,7 +278,7 @@ struct WaitMetricsRequest { template void serialize( Ar& ar ) { - ar & keys & min & max & reply & arena; + serializer(ar, keys, min, max, reply, arena); } }; @@ -288,7 +288,7 @@ struct SplitMetricsReply { template void serialize( Ar& ar ) { - ar & splits & used; + serializer(ar, splits, used); } }; @@ -306,7 +306,7 @@ struct SplitMetricsRequest { template void serialize(Ar& ar) { - ar & keys & limits & used & estimated & isLastShard & reply & arena; + serializer(ar, keys, limits, used, estimated, isLastShard, reply, arena); } }; @@ -317,7 +317,7 @@ struct GetPhysicalMetricsReply { template void serialize(Ar& ar) { - ar & load & free & capacity; + serializer(ar, load, free, capacity); } }; @@ -326,7 +326,7 @@ struct GetPhysicalMetricsRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -336,7 +336,7 @@ struct StorageQueuingMetricsRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -349,7 +349,7 @@ struct StorageQueuingMetricsReply { template void serialize(Ar& ar) { - ar & localTime & instanceID & bytesDurable & bytesInput & v & storageBytes; + serializer(ar, localTime, instanceID, bytesDurable, bytesInput, v, storageBytes); } }; diff --git a/fdbrpc/EndpointGroup.h b/fdbrpc/EndpointGroup.h deleted file mode 100644 index 306aa35382..0000000000 --- a/fdbrpc/EndpointGroup.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * EndpointGroup.h - * - * This source file is part of the FoundationDB open source project - * - * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FLOW_ENDPOINT_GROUP_H -#define FLOW_ENDPOINT_GROUP_H -#pragma once - -#include "fdbrpc/flow.h" - -// EndpointGroup makes it easier to implement backward compatibility for interface serialization -// It also provides a central place to implement more compact serialization for a group of related endpoints in the future. - -/* Typical usage: - -template -void serialize(Ar& ar) { - auto endpoints = endpointGroup(ar); - endpoints.require( ar.protocolVersion() <= currentProtocolVersion ); - endpoints & apple & banana; - endpoints.require( ar.protocolVersion() >= 0xabc ); // Following endpoints added in this version - endpoints & cherry; - endpoints.require( ar.protocolVersion() >= 0xdef ); // .. and then some more were added - endpoints & date; -} - -*/ - - -template -struct EndpointGroup : NonCopyable { - Ar& ar; - bool enabled; - - explicit EndpointGroup( Ar& ar ) : ar(ar), enabled(true) { - ASSERT( ar.protocolVersion() != 0 ); - } - EndpointGroup( EndpointGroup&& g ) : ar(g.ar), enabled(g.enabled) {} - - EndpointGroup& require( bool condition ) { - enabled = enabled && condition; - return *this; - } - - template - EndpointGroup& operator & (PromiseStream& stream) { - if (enabled) - ar & stream; - else if (Ar::isDeserializing) - stream.sendError( incompatible_protocol_version() ); - return *this; - } -}; - -template -EndpointGroup endpointGroup( Ar& ar ) { return EndpointGroup(ar); } - -#endif \ No newline at end of file diff --git a/fdbrpc/FailureMonitor.h b/fdbrpc/FailureMonitor.h index 47ad74fffd..975e60762b 100644 --- a/fdbrpc/FailureMonitor.h +++ b/fdbrpc/FailureMonitor.h @@ -74,7 +74,7 @@ struct FailureStatus { bool operator != (FailureStatus const& r) const { return failed != r.failed; } template void serialize(Ar& ar) { - ar & failed; + serializer(ar, failed); } }; @@ -141,4 +141,4 @@ private: friend class OnStateChangedActorActor; }; -#endif \ No newline at end of file +#endif diff --git a/fdbrpc/LoadBalance.actor.h b/fdbrpc/LoadBalance.actor.h index 0096c3675b..32bb7ee908 100644 --- a/fdbrpc/LoadBalance.actor.h +++ b/fdbrpc/LoadBalance.actor.h @@ -71,7 +71,7 @@ struct LoadBalancedReply { template void serialize(Ar &ar) { - ar & penalty; + serializer(ar, penalty); } }; diff --git a/fdbrpc/Locality.h b/fdbrpc/Locality.h index ff6bad900a..bf5aabb9c4 100644 --- a/fdbrpc/Locality.h +++ b/fdbrpc/Locality.h @@ -110,7 +110,7 @@ public: template void serialize(Ar& ar) { - ar & _class & _source; + serializer(ar, _class, _source); } }; @@ -188,10 +188,10 @@ public: Standalone key; Optional> value; uint64_t mapSize = (uint64_t)_data.size(); - ar & mapSize; + serializer(ar, mapSize); if (ar.isDeserializing) { for (size_t i = 0; i < mapSize; i++) { - ar & key & value; + serializer(ar, key, value); _data[key] = value; } } @@ -199,24 +199,24 @@ public: for (auto it = _data.begin(); it != _data.end(); it++) { key = it->first; value = it->second; - ar & key & value; + serializer(ar, key, value); } } } else { ASSERT(ar.isDeserializing); UID zoneId, dcId, processId; - ar & zoneId & dcId; + serializer(ar, zoneId, dcId); set(keyZoneId, Standalone(zoneId.toString())); set(keyDcId, Standalone(dcId.toString())); if (ar.protocolVersion() >= 0x0FDB00A340000001LL) { - ar & processId; + serializer(ar, processId); set(keyProcessId, Standalone(processId.toString())); } else { int _machineClass = ProcessClass::UnsetClass; - ar & _machineClass; + serializer(ar, _machineClass); } } } @@ -258,7 +258,7 @@ struct ProcessData { template void serialize(Ar& ar) { - ar & locality & processClass & address; + serializer(ar, locality, processClass, address); } struct sort_by_address { diff --git a/fdbrpc/PerfMetric.h b/fdbrpc/PerfMetric.h index 8b342ecd7f..8beea3e1fd 100644 --- a/fdbrpc/PerfMetric.h +++ b/fdbrpc/PerfMetric.h @@ -43,7 +43,7 @@ struct PerfMetric { template void serialize( Ar& ar ) { - ar & m_name & m_format_code & m_value & m_averaged; + serializer(ar, m_name, m_format_code, m_value, m_averaged); } private: @@ -106,4 +106,4 @@ struct GlobalCounters { extern GlobalCounters g_counters; -#endif \ No newline at end of file +#endif diff --git a/fdbrpc/ReplicationPolicy.h b/fdbrpc/ReplicationPolicy.h index ddc33dd8d9..74bc0baa80 100644 --- a/fdbrpc/ReplicationPolicy.h +++ b/fdbrpc/ReplicationPolicy.h @@ -136,7 +136,7 @@ struct PolicyAcross : IReplicationPolicy, public ReferenceCounted template void serialize(Ar& ar) { - ar & _attribKey & _count; + serializer(ar, _attribKey, _count); serializeReplicationPolicy(ar, _policy); } @@ -207,7 +207,7 @@ struct PolicyAnd : IReplicationPolicy, public ReferenceCounted { template void serialize(Ar& ar) { int count = _policies.size(); - ar & count; + serializer(ar, count); _policies.resize(count); for(int i = 0; i < count; i++) { serializeReplicationPolicy(ar, _policies[i]); @@ -233,7 +233,7 @@ template void serializeReplicationPolicy(Ar& ar, IRepPolicyRef& policy) { if(Ar::isDeserializing) { StringRef name; - ar & name; + serializer(ar, name); if(name == LiteralStringRef("One")) { PolicyOne* pointer = new PolicyOne(); @@ -261,7 +261,7 @@ void serializeReplicationPolicy(Ar& ar, IRepPolicyRef& policy) { else { std::string name = policy ? policy->name() : "None"; Standalone nameRef = StringRef(name); - ar & nameRef; + serializer(ar, nameRef); if(name == "One") { ((PolicyOne*)policy.getPtr())->serialize(ar); } diff --git a/fdbrpc/dsltest.actor.cpp b/fdbrpc/dsltest.actor.cpp index 804caa1449..bfde5ccee9 100644 --- a/fdbrpc/dsltest.actor.cpp +++ b/fdbrpc/dsltest.actor.cpp @@ -925,7 +925,7 @@ struct AddReply { template void serialize(Ar& ar) { - ar & sum; + serializer(ar, sum); } }; @@ -938,7 +938,7 @@ struct AddRequest { template void serialize(Ar& ar) { - ar & a & b & reply; + serializer(ar, a, b, reply); } }; diff --git a/fdbrpc/fdbrpc.vcxproj b/fdbrpc/fdbrpc.vcxproj index 67a7eb9ff7..3231afcfbe 100644 --- a/fdbrpc/fdbrpc.vcxproj +++ b/fdbrpc/fdbrpc.vcxproj @@ -74,7 +74,6 @@ - false diff --git a/fdbrpc/fdbrpc.vcxproj.filters b/fdbrpc/fdbrpc.vcxproj.filters index 5590cd39c8..0aed89c29f 100644 --- a/fdbrpc/fdbrpc.vcxproj.filters +++ b/fdbrpc/fdbrpc.vcxproj.filters @@ -137,7 +137,6 @@ - diff --git a/fdbserver/ClusterRecruitmentInterface.h b/fdbserver/ClusterRecruitmentInterface.h index 3f891a19ec..f3d0860c29 100644 --- a/fdbserver/ClusterRecruitmentInterface.h +++ b/fdbserver/ClusterRecruitmentInterface.h @@ -61,7 +61,7 @@ struct ClusterControllerFullInterface { template void serialize( Ar& ar ) { ASSERT( ar.protocolVersion() >= 0x0FDB00A200040001LL ); - ar & clientInterface & recruitFromConfiguration & recruitRemoteFromConfiguration & recruitStorage & registerWorker & getWorkers & registerMaster & getServerDBInfo; + serializer(ar, clientInterface, recruitFromConfiguration, recruitRemoteFromConfiguration, recruitStorage, registerWorker, getWorkers, registerMaster, getServerDBInfo); } }; @@ -77,7 +77,7 @@ struct RecruitFromConfigurationRequest { template void serialize( Ar& ar ) { - ar & configuration & recruitSeedServers & maxOldLogRouters & reply; + serializer(ar, configuration, recruitSeedServers, maxOldLogRouters, reply); } }; @@ -95,7 +95,7 @@ struct RecruitFromConfigurationReply { template void serialize( Ar& ar ) { - ar & tLogs & satelliteTLogs & proxies & resolvers & storageServers & oldLogRouters & dcId & satelliteFallback; + serializer(ar, tLogs, satelliteTLogs, proxies, resolvers, storageServers, oldLogRouters, dcId, satelliteFallback); } }; @@ -110,7 +110,7 @@ struct RecruitRemoteFromConfigurationRequest { template void serialize( Ar& ar ) { - ar & configuration & dcId & logRouterCount & reply; + serializer(ar, configuration, dcId, logRouterCount, reply); } }; @@ -120,7 +120,7 @@ struct RecruitRemoteFromConfigurationReply { template void serialize( Ar& ar ) { - ar & remoteTLogs & logRouters; + serializer(ar, remoteTLogs, logRouters); } }; @@ -130,7 +130,7 @@ struct RecruitStorageReply { template void serialize( Ar& ar ) { - ar & worker & processClass; + serializer(ar, worker, processClass); } }; @@ -143,7 +143,7 @@ struct RecruitStorageRequest { template void serialize( Ar& ar ) { - ar & excludeMachines & excludeAddresses & includeDCs & criticalRecruitment & reply; + serializer(ar, excludeMachines, excludeAddresses, includeDCs, criticalRecruitment, reply); } }; @@ -156,7 +156,7 @@ struct RegisterWorkerReply { template void serialize( Ar& ar ) { - ar & processClass & priorityInfo; + serializer(ar, processClass, priorityInfo); } }; @@ -174,7 +174,7 @@ struct RegisterWorkerRequest { template void serialize( Ar& ar ) { - ar & wi & initialClass & processClass & priorityInfo & generation & reply; + serializer(ar, wi, initialClass, processClass, priorityInfo, generation, reply); } }; @@ -189,7 +189,7 @@ struct GetWorkersRequest { template void serialize(Ar& ar) { - ar & flags & reply; + serializer(ar, flags, reply); } }; @@ -213,7 +213,7 @@ struct RegisterMasterRequest { template void serialize( Ar& ar ) { ASSERT( ar.protocolVersion() >= 0x0FDB00A200040001LL ); - ar & id & mi & logSystemConfig & proxies & resolvers & recoveryCount & registrationCount & configuration & priorCommittedLogServers & recoveryState & recoveryStalled & reply; + serializer(ar, id, mi, logSystemConfig, proxies, resolvers, recoveryCount, registrationCount, configuration, priorCommittedLogServers, recoveryState, recoveryStalled, reply); } }; @@ -225,7 +225,7 @@ struct GetServerDBInfoRequest { template void serialize(Ar& ar) { - ar & knownServerInfoID & issues & incompatiblePeers & reply; + serializer(ar, knownServerInfoID, issues, incompatiblePeers, reply); } }; diff --git a/fdbserver/CoordinatedState.actor.cpp b/fdbserver/CoordinatedState.actor.cpp index 0bc7b8495a..018bd97c8d 100644 --- a/fdbserver/CoordinatedState.actor.cpp +++ b/fdbserver/CoordinatedState.actor.cpp @@ -208,7 +208,7 @@ struct MovableValue { template void serialize(Ar& ar) { ASSERT( ar.protocolVersion() >= 0x0FDB00A2000D0001LL ); - ar & value & mode & other; + serializer(ar, value, mode, other); } }; @@ -316,4 +316,4 @@ MovableCoordinatedState::~MovableCoordinatedState() { Future MovableCoordinatedState::read() { return MovableCoordinatedStateImpl::read(impl); } Future MovableCoordinatedState::onConflict() { return impl->onConflict(); } Future MovableCoordinatedState::setExclusive(Value v) { return impl->setExclusive(v); } -Future MovableCoordinatedState::move( ClusterConnectionString const& nc ) { return MovableCoordinatedStateImpl::move(impl, nc); } \ No newline at end of file +Future MovableCoordinatedState::move( ClusterConnectionString const& nc ) { return MovableCoordinatedStateImpl::move(impl, nc); } diff --git a/fdbserver/Coordination.actor.cpp b/fdbserver/Coordination.actor.cpp index a8d878b717..c111baf3fb 100644 --- a/fdbserver/Coordination.actor.cpp +++ b/fdbserver/Coordination.actor.cpp @@ -33,7 +33,7 @@ struct GenerationRegVal { Optional val; template void serialize(Ar& ar) { - ar & readGen & writeGen & val; + serializer(ar, readGen, writeGen, val); } }; diff --git a/fdbserver/CoordinationInterface.h b/fdbserver/CoordinationInterface.h index b7044f5c9c..931fec5500 100644 --- a/fdbserver/CoordinationInterface.h +++ b/fdbserver/CoordinationInterface.h @@ -66,7 +66,7 @@ struct UniqueGeneration { } template void serialize(Ar& ar) { - ar & generation & uid; + serializer(ar, generation, uid); } }; @@ -78,7 +78,7 @@ struct GenerationRegReadRequest { GenerationRegReadRequest( Key key, UniqueGeneration gen ) : key(key), gen(gen) {} template void serialize(Ar& ar) { - ar & key & gen & reply; + serializer(ar, key, gen, reply); } }; @@ -89,7 +89,7 @@ struct GenerationRegReadReply { GenerationRegReadReply( Optional value, UniqueGeneration gen, UniqueGeneration rgen ) : value(value), gen(gen), rgen(rgen) {} template void serialize(Ar& ar) { - ar & value & gen & rgen; + serializer(ar, value, gen, rgen); } }; @@ -101,7 +101,7 @@ struct GenerationRegWriteRequest { GenerationRegWriteRequest(KeyValue kv, UniqueGeneration gen) : kv(kv), gen(gen) {} template void serialize(Ar& ar) { - ar & kv & gen & reply; + serializer(ar, kv, gen, reply); } }; @@ -126,7 +126,7 @@ struct CandidacyRequest { template void serialize(Ar& ar) { - ar & key & myInfo & knownLeader & prevChangeID & reply; + serializer(ar, key, myInfo, knownLeader, prevChangeID, reply); } }; @@ -141,7 +141,7 @@ struct LeaderHeartbeatRequest { template void serialize(Ar& ar) { - ar & key & myInfo & prevChangeID & reply; + serializer(ar, key, myInfo, prevChangeID, reply); } }; @@ -155,7 +155,7 @@ struct ForwardRequest { template void serialize(Ar& ar) { - ar & key & conn & reply; + serializer(ar, key, conn, reply); } }; @@ -169,4 +169,4 @@ public: Future coordinationServer( std::string const& dataFolder ); -#endif \ No newline at end of file +#endif diff --git a/fdbserver/DBCoreState.h b/fdbserver/DBCoreState.h index ef2814b539..56e8503ba6 100644 --- a/fdbserver/DBCoreState.h +++ b/fdbserver/DBCoreState.h @@ -54,7 +54,7 @@ struct CoreTLogSet { template void serialize(Archive& ar) { - ar & tLogs & tLogWriteAntiQuorum & tLogReplicationFactor & tLogPolicy & tLogLocalities & isLocal & locality & startVersion & satelliteTagLocations; + serializer(ar, tLogs, tLogWriteAntiQuorum, tLogReplicationFactor, tLogPolicy, tLogLocalities, isLocal, locality, startVersion, satelliteTagLocations); } }; @@ -72,11 +72,11 @@ struct OldTLogCoreData { template void serialize(Archive& ar) { if( ar.protocolVersion() >= 0x0FDB00A560010001LL) { - ar & tLogs & logRouterTags & epochEnd; + serializer(ar, tLogs, logRouterTags, epochEnd); } else if(ar.isDeserializing) { tLogs.push_back(CoreTLogSet()); - ar & tLogs[0].tLogs & tLogs[0].tLogWriteAntiQuorum & tLogs[0].tLogReplicationFactor & tLogs[0].tLogPolicy & epochEnd & tLogs[0].tLogLocalities; + serializer(ar, tLogs[0].tLogs, tLogs[0].tLogWriteAntiQuorum, tLogs[0].tLogReplicationFactor, tLogs[0].tLogPolicy, epochEnd, tLogs[0].tLogLocalities); } } }; @@ -122,18 +122,18 @@ struct DBCoreState { ASSERT(ar.protocolVersion() >= 0x0FDB00A460010001LL); if(ar.protocolVersion() >= 0x0FDB00A560010001LL) { - ar & tLogs & logRouterTags & oldTLogData & recoveryCount & logSystemType; + serializer(ar, tLogs, logRouterTags, oldTLogData, recoveryCount, logSystemType); } else if(ar.isDeserializing) { tLogs.push_back(CoreTLogSet()); - ar & tLogs[0].tLogs & tLogs[0].tLogWriteAntiQuorum & recoveryCount & tLogs[0].tLogReplicationFactor & logSystemType; + serializer(ar, tLogs[0].tLogs, tLogs[0].tLogWriteAntiQuorum, recoveryCount, tLogs[0].tLogReplicationFactor, logSystemType); uint64_t tLocalitySize = (uint64_t)tLogs[0].tLogLocalities.size(); - ar & oldTLogData & tLogs[0].tLogPolicy & tLocalitySize; + serializer(ar, oldTLogData, tLogs[0].tLogPolicy, tLocalitySize); if (ar.isDeserializing) { tLogs[0].tLogLocalities.reserve(tLocalitySize); for (size_t i = 0; i < tLocalitySize; i++) { LocalityData locality; - ar & locality; + serializer(ar, locality); tLogs[0].tLogLocalities.push_back(locality); } diff --git a/fdbserver/LogProtocolMessage.h b/fdbserver/LogProtocolMessage.h index 76672c87e3..60cd886682 100644 --- a/fdbserver/LogProtocolMessage.h +++ b/fdbserver/LogProtocolMessage.h @@ -60,7 +60,7 @@ struct LogProtocolMessage { template void serialize(Ar& ar) { uint8_t poly = MutationRef::Reserved_For_LogProtocolMessage; - ar & poly; + serializer(ar, poly); applyVersionStartingHere(ar, IncludeVersion()); } @@ -70,4 +70,4 @@ struct LogProtocolMessage { template static bool isNextIn(Ar& ar) { return startsLogProtocolMessage(*(const uint8_t*)ar.peekBytes(1)); } }; -#endif \ No newline at end of file +#endif diff --git a/fdbserver/LogSystemConfig.h b/fdbserver/LogSystemConfig.h index 83a90aa9de..1839c59dde 100644 --- a/fdbserver/LogSystemConfig.h +++ b/fdbserver/LogSystemConfig.h @@ -45,8 +45,8 @@ struct OptionalInterface { template void serialize( Ar& ar ) { - ar & iface; - if( !iface.present() ) ar & ident; + serializer(ar, iface); + if( !iface.present() ) serializer(ar, ident); else ident = iface.get().id(); } @@ -111,7 +111,7 @@ struct TLogSet { template void serialize( Ar& ar ) { - ar & tLogs & logRouters & tLogWriteAntiQuorum & tLogReplicationFactor & tLogPolicy & tLogLocalities & isLocal & locality & startVersion & satelliteTagLocations; + serializer(ar, tLogs, logRouters, tLogWriteAntiQuorum, tLogReplicationFactor, tLogPolicy, tLogLocalities, isLocal, locality, startVersion, satelliteTagLocations); } }; @@ -144,7 +144,7 @@ struct OldTLogConf { template void serialize( Ar& ar ) { - ar & tLogs & epochEnd & logRouterTags; + serializer(ar, tLogs, epochEnd, logRouterTags); } }; @@ -304,7 +304,7 @@ struct LogSystemConfig { template void serialize( Ar& ar ) { - ar & logSystemType & tLogs & logRouterTags & oldTLogs & expectedLogSets & recruitmentID & stopped & recoveredAt; + serializer(ar, logSystemType, tLogs, logRouterTags, oldTLogs, expectedLogSets, recruitmentID, stopped, recoveredAt); } }; diff --git a/fdbserver/MasterInterface.h b/fdbserver/MasterInterface.h index 22f1dbbdde..d4b5f396ab 100644 --- a/fdbserver/MasterInterface.h +++ b/fdbserver/MasterInterface.h @@ -43,7 +43,7 @@ struct MasterInterface { template void serialize(Archive& ar) { ASSERT( ar.protocolVersion() >= 0x0FDB00A200040001LL ); - ar & locality & waitFailure & getRateInfo & tlogRejoin & changeCoordinators & getCommitVersion; + serializer(ar, locality, waitFailure, getRateInfo, tlogRejoin, changeCoordinators, getCommitVersion); } void initEndpoints() { @@ -61,7 +61,7 @@ struct GetRateInfoRequest { template void serialize(Ar& ar) { - ar & requesterID & totalReleasedTransactions & reply; + serializer(ar, requesterID, totalReleasedTransactions, reply); } }; @@ -71,7 +71,7 @@ struct GetRateInfoReply { template void serialize(Ar& ar) { - ar & transactionRate & leaseDuration; + serializer(ar, transactionRate, leaseDuration); } }; @@ -83,7 +83,7 @@ struct TLogRejoinRequest { explicit TLogRejoinRequest(const TLogInterface &interf) : myInterface(interf) { } template void serialize(Ar& ar) { - ar & myInterface & reply; + serializer(ar, myInterface, reply); } }; @@ -96,7 +96,7 @@ struct ChangeCoordinatorsRequest { template void serialize(Ar& ar) { - ar & newConnectionString & reply; + serializer(ar, newConnectionString, reply); } }; @@ -121,7 +121,7 @@ struct ResolverMoveRef { template void serialize( Ar& ar ) { - ar & range & dest; + serializer(ar, range, dest); } }; @@ -137,7 +137,7 @@ struct GetCommitVersionReply { template void serialize(Ar& ar) { - ar & resolverChanges & resolverChangesVersion & version & prevVersion & requestNum; + serializer(ar, resolverChanges, resolverChangesVersion, version, prevVersion, requestNum); } }; @@ -153,7 +153,7 @@ struct GetCommitVersionRequest { template void serialize(Ar& ar) { - ar & requestNum & mostRecentProcessedRequestNum & requestingProxy & reply; + serializer(ar, requestNum, mostRecentProcessedRequestNum, requestingProxy, reply); } }; @@ -175,8 +175,8 @@ struct LifetimeToken { template void serialize(Ar& ar) { - ar & ccID & count; + serializer(ar, ccID, count); } }; -#endif \ No newline at end of file +#endif diff --git a/fdbserver/MoveKeys.h b/fdbserver/MoveKeys.h index a54dcc7529..7f6a4f5f5a 100644 --- a/fdbserver/MoveKeys.h +++ b/fdbserver/MoveKeys.h @@ -30,7 +30,7 @@ struct MoveKeysLock { UID prevOwner, myOwner, prevWrite; template - void serialize(Ar& ar) { ar & prevOwner & myOwner & prevWrite; } + void serialize(Ar& ar) { serializer(ar, prevOwner, myOwner, prevWrite); } }; Future takeMoveKeysLock( Database const& cx, UID const& masterId ); @@ -86,4 +86,4 @@ Future canRemoveStorageServer( Transaction* const& tr, UID const& serverID // Returns true if the given storage server has no keys assigned to it and may be safely removed // Obviously that could change later! -#endif \ No newline at end of file +#endif diff --git a/fdbserver/NetworkTest.h b/fdbserver/NetworkTest.h index d1ffec063b..37057bf3a1 100644 --- a/fdbserver/NetworkTest.h +++ b/fdbserver/NetworkTest.h @@ -40,7 +40,7 @@ struct NetworkTestRequest { NetworkTestRequest( Key key, uint32_t replySize ) : key(key), replySize(replySize) {} template void serialize(Ar& ar) { - ar & key & replySize & reply; + serializer(ar, key, replySize, reply); } }; @@ -50,7 +50,7 @@ struct NetworkTestReply { NetworkTestReply( Value value ) : value(value) {} template void serialize(Ar& ar) { - ar & value; + serializer(ar, value); } }; @@ -58,4 +58,4 @@ Future networkTestServer(); Future networkTestClient( std:: string const& testServers ); -#endif \ No newline at end of file +#endif diff --git a/fdbserver/OldTLogServer.actor.cpp b/fdbserver/OldTLogServer.actor.cpp index 937d7d8f1e..b0d92885b7 100644 --- a/fdbserver/OldTLogServer.actor.cpp +++ b/fdbserver/OldTLogServer.actor.cpp @@ -74,7 +74,7 @@ namespace oldTLog { template void serialize(Ar& ar) { - ar & tag & messageOffsets; + serializer(ar, tag, messageOffsets); } }; @@ -93,9 +93,9 @@ namespace oldTLog { template void serialize(Ar& ar) { if( ar.protocolVersion() >= 0x0FDB00A460010001) { - ar & version & messages & tags & knownCommittedVersion & id; + serializer(ar, version, messages, tags, knownCommittedVersion, id); } else if(ar.isDeserializing) { - ar & version & messages & tags; + serializer(ar, version, messages, tags); knownCommittedVersion = 0; id = UID(); } diff --git a/fdbserver/ResolverInterface.h b/fdbserver/ResolverInterface.h index 3b3a72898c..97d6c33b95 100644 --- a/fdbserver/ResolverInterface.h +++ b/fdbserver/ResolverInterface.h @@ -49,7 +49,7 @@ struct ResolverInterface { template void serialize( Ar& ar ) { - ar & uniqueID & locality & resolve & metrics & split & waitFailure; + serializer(ar, uniqueID, locality, resolve, metrics, split, waitFailure); } }; @@ -65,7 +65,7 @@ struct StateTransactionRef { template void serialize(Archive& ar) { - ar & committed & mutations; + serializer(ar, committed, mutations); } }; @@ -77,7 +77,7 @@ struct ResolveTransactionBatchReply { template void serialize(Archive& ar) { - ar & committed & stateMutations & arena & debugID; + serializer(ar, committed, stateMutations, arena, debugID); } }; @@ -95,7 +95,7 @@ struct ResolveTransactionBatchRequest { template void serialize(Archive& ar) { - ar & prevVersion & version & lastReceivedVersion & transactions & txnStateTransactions & reply & arena & debugID; + serializer(ar, prevVersion, version, lastReceivedVersion, transactions, txnStateTransactions, reply, arena, debugID); } }; @@ -104,7 +104,7 @@ struct ResolutionMetricsRequest { template void serialize(Archive& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -113,7 +113,7 @@ struct ResolutionSplitReply { int64_t used; template void serialize(Archive& ar) { - ar & key & used; + serializer(ar, key, used); } }; @@ -126,7 +126,7 @@ struct ResolutionSplitRequest { template void serialize(Archive& ar) { - ar & range & offset & front & reply; + serializer(ar, range, offset, front, reply); } }; diff --git a/fdbserver/RestoreInterface.h b/fdbserver/RestoreInterface.h index 8529fff255..a6f546e58d 100644 --- a/fdbserver/RestoreInterface.h +++ b/fdbserver/RestoreInterface.h @@ -41,7 +41,7 @@ struct RestoreInterface { template void serialize( Ar& ar ) { - ar & test; + serializer(ar, test); } }; @@ -54,7 +54,7 @@ struct TestRequest { template void serialize(Ar& ar) { - ar & testData & reply; + serializer(ar, testData, reply); } }; @@ -66,7 +66,7 @@ struct TestReply { template void serialize(Ar& ar) { - ar & replyData; + serializer(ar, replyData); } }; diff --git a/fdbserver/ServerDBInfo.h b/fdbserver/ServerDBInfo.h index 8d8e8c188a..cd2f327a71 100644 --- a/fdbserver/ServerDBInfo.h +++ b/fdbserver/ServerDBInfo.h @@ -51,7 +51,7 @@ struct ServerDBInfo { template void serialize( Ar& ar ) { - ar & id & clusterInterface & client & master & resolvers & recoveryCount & masterLifetime & logSystemConfig & priorCommittedLogServers & recoveryState; + serializer(ar, id, clusterInterface, client, master, resolvers, recoveryCount, masterLifetime, logSystemConfig, priorCommittedLogServers, recoveryState); } }; diff --git a/fdbserver/TLogInterface.h b/fdbserver/TLogInterface.h index 7ea5ce5861..3acebb4c7b 100644 --- a/fdbserver/TLogInterface.h +++ b/fdbserver/TLogInterface.h @@ -65,8 +65,8 @@ struct TLogInterface { template void serialize( Ar& ar ) { ASSERT(ar.isDeserializing || uniqueID != UID()); - ar & uniqueID & sharedTLogID & locality & peekMessages & popMessages - & commit & lock & getQueuingMetrics & confirmRunning & waitFailure & recoveryFinished; + serializer(ar, uniqueID, sharedTLogID, locality, peekMessages, popMessages + , commit, lock, getQueuingMetrics, confirmRunning, waitFailure, recoveryFinished); } }; @@ -77,7 +77,7 @@ struct TLogRecoveryFinishedRequest { template void serialize( Ar& ar ) { - ar & reply; + serializer(ar, reply); } }; @@ -87,7 +87,7 @@ struct TLogLockResult { template void serialize( Ar& ar ) { - ar & end & knownCommittedVersion; + serializer(ar, end, knownCommittedVersion); } }; @@ -100,7 +100,7 @@ struct TLogConfirmRunningRequest { template void serialize( Ar& ar ) { - ar & debugID & reply; + serializer(ar, debugID, reply); } }; @@ -116,7 +116,7 @@ struct VersionUpdateRef { template void serialize( Ar& ar ) { - ar & version & mutations & isPrivateData; + serializer(ar, version, mutations, isPrivateData); } }; @@ -131,7 +131,7 @@ struct VerUpdateRef { template void serialize( Ar& ar ) { - ar & version & mutations & isPrivateData; + serializer(ar, version, mutations, isPrivateData); } }; @@ -146,7 +146,7 @@ struct TLogPeekReply { template void serialize(Ar& ar) { - ar & arena & messages & end & popped & maxKnownVersion & minKnownCommittedVersion & begin; + serializer(ar, arena, messages, end, popped, maxKnownVersion, minKnownCommittedVersion, begin); } }; @@ -163,7 +163,7 @@ struct TLogPeekRequest { template void serialize(Ar& ar) { - ar & arena & begin & tag & returnIfBlocked & sequence & reply; + serializer(ar, arena, begin, tag, returnIfBlocked, sequence, reply); } }; @@ -179,7 +179,7 @@ struct TLogPopRequest { template void serialize(Ar& ar) { - ar & arena & to & durableKnownCommittedVersion & tag & reply; + serializer(ar, arena, to, durableKnownCommittedVersion, tag, reply); } }; @@ -196,7 +196,7 @@ struct TagMessagesRef { template void serialize(Ar& ar) { - ar & tag & messageOffsets; + serializer(ar, tag, messageOffsets); } }; @@ -214,7 +214,7 @@ struct TLogCommitRequest { : arena(a), prevVersion(prevVersion), version(version), knownCommittedVersion(knownCommittedVersion), minKnownCommittedVersion(minKnownCommittedVersion), messages(messages), debugID(debugID) {} template void serialize( Ar& ar ) { - ar & prevVersion & version & knownCommittedVersion & minKnownCommittedVersion & messages & reply & arena & debugID; + serializer(ar, prevVersion, version, knownCommittedVersion, minKnownCommittedVersion, messages, reply, arena, debugID); } }; @@ -223,7 +223,7 @@ struct TLogQueuingMetricsRequest { template void serialize(Ar& ar) { - ar & reply; + serializer(ar, reply); } }; @@ -236,7 +236,7 @@ struct TLogQueuingMetricsReply { template void serialize(Ar& ar) { - ar & localTime & instanceID & bytesDurable & bytesInput & storageBytes & v; + serializer(ar, localTime, instanceID, bytesDurable, bytesInput, storageBytes, v); } }; diff --git a/fdbserver/TLogServer.actor.cpp b/fdbserver/TLogServer.actor.cpp index ef355022fc..90132bc48a 100644 --- a/fdbserver/TLogServer.actor.cpp +++ b/fdbserver/TLogServer.actor.cpp @@ -57,7 +57,7 @@ struct TLogQueueEntryRef { template void serialize(Ar& ar) { - ar & version & messages & knownCommittedVersion & id; + serializer(ar, version, messages, knownCommittedVersion, id); } size_t expectedSize() const { return messages.expectedSize(); @@ -76,11 +76,11 @@ struct AlternativeTLogQueueEntryRef { void serialize(Ar& ar) { ASSERT(!ar.isDeserializing && alternativeMessages); uint32_t msgSize = expectedSize(); - ar & version & msgSize; + serializer(ar, version, msgSize); for(auto& msg : *alternativeMessages) { ar.serializeBytes( msg.message ); } - ar & knownCommittedVersion & id; + serializer(ar, knownCommittedVersion, id); } uint32_t expectedSize() const { diff --git a/fdbserver/TesterInterface.h b/fdbserver/TesterInterface.h index 3485851152..4394746826 100644 --- a/fdbserver/TesterInterface.h +++ b/fdbserver/TesterInterface.h @@ -37,7 +37,7 @@ struct WorkloadInterface { template void serialize( Ar& ar ) { - ar & setup & start & check & metrics & stop; + serializer(ar, setup, start, check, metrics, stop); } }; @@ -68,7 +68,7 @@ struct WorkloadRequest { template void serialize( Ar& ar ) { - ar & title & timeout & databasePingDelay & sharedRandomNumber & useDatabase & options & clientId & clientCount & reply & arena; + serializer(ar, title, timeout, databasePingDelay, sharedRandomNumber, useDatabase, options, clientId, clientCount, reply, arena); } }; @@ -79,7 +79,7 @@ struct TesterInterface { template void serialize(Ar& ar) { - ar & recruitments; + serializer(ar, recruitments); } }; diff --git a/fdbserver/WorkerInterface.h b/fdbserver/WorkerInterface.h index 7c9925288e..b9de0c4484 100644 --- a/fdbserver/WorkerInterface.h +++ b/fdbserver/WorkerInterface.h @@ -62,7 +62,7 @@ struct WorkerInterface { template void serialize(Ar& ar) { - ar & clientInterface & locality & tLog & master & masterProxy & resolver & storage & logRouter & debugPing & coordinationPing & waitFailure & setMetricsRate & eventLogRequest & traceBatchDumpRequest & testerInterface & diskStoreRequest; + serializer(ar, clientInterface, locality, tLog, master, masterProxy, resolver, storage, logRouter, debugPing, coordinationPing, waitFailure, setMetricsRate, eventLogRequest, traceBatchDumpRequest, testerInterface, diskStoreRequest); } }; @@ -87,7 +87,7 @@ struct InitializeTLogRequest { template void serialize( Ar& ar ) { - ar & recruitmentID & recoverFrom & recoverAt & knownCommittedVersion & epoch & recoverTags & allTags & storeType & remoteTag & locality & isPrimary & startVersion & logRouterTags & reply; + serializer(ar, recruitmentID, recoverFrom, recoverAt, knownCommittedVersion, epoch, recoverTags, allTags, storeType, remoteTag, locality, isPrimary, startVersion, logRouterTags, reply); } }; @@ -102,7 +102,7 @@ struct InitializeLogRouterRequest { template void serialize(Ar& ar) { - ar & recoveryCount & routerTag & startVersion & tLogLocalities & tLogPolicy & locality & reply; + serializer(ar, recoveryCount, routerTag, startVersion, tLogLocalities, tLogPolicy, locality, reply); } }; @@ -116,7 +116,7 @@ struct RecruitMasterRequest { template void serialize(Ar& ar) { ASSERT( ar.protocolVersion() >= 0x0FDB00A200040001LL ); - ar & lifetime & forceRecovery & reply & arena; + serializer(ar, lifetime, forceRecovery, reply, arena); } }; @@ -129,7 +129,7 @@ struct InitializeMasterProxyRequest { template void serialize(Ar& ar) { - ar & master & recoveryCount & recoveryTransactionVersion & firstProxy & reply; + serializer(ar, master, recoveryCount, recoveryTransactionVersion, firstProxy, reply); } }; @@ -141,7 +141,7 @@ struct InitializeResolverRequest { template void serialize(Ar& ar) { - ar & recoveryCount & proxyCount & resolverCount & reply; + serializer(ar, recoveryCount, proxyCount, resolverCount, reply); } }; @@ -151,7 +151,7 @@ struct InitializeStorageReply { template void serialize(Ar& ar) { - ar & interf & addedVersion; + serializer(ar, interf, addedVersion); } }; @@ -164,7 +164,7 @@ struct InitializeStorageRequest { template void serialize( Ar& ar ) { - ar & seedTag & reqId & interfaceId & storeType & reply; + serializer(ar, seedTag, reqId, interfaceId, storeType, reply); } }; @@ -173,7 +173,7 @@ struct TraceBatchDumpRequest { template void serialize( Ar& ar ) { - ar & reply; + serializer(ar, reply); } }; @@ -183,7 +183,7 @@ struct LoadedReply { template void serialize(Ar& ar) { - ar & payload & id; + serializer(ar, payload, id); } }; @@ -195,7 +195,7 @@ struct LoadedPingRequest { template void serialize(Ar& ar) { - ar & id & loadReply & payload & reply; + serializer(ar, id, loadReply, payload, reply); } }; @@ -208,7 +208,7 @@ struct CoordinationPingMessage { template void serialize(Ar& ar) { - ar & clusterControllerId & timeStep; + serializer(ar, clusterControllerId, timeStep); } }; @@ -220,7 +220,7 @@ struct SetMetricsLogRateRequest { template void serialize(Ar& ar) { - ar & metricsLogsPerSecond; + serializer(ar, metricsLogsPerSecond); } }; @@ -234,7 +234,7 @@ struct EventLogRequest { template void serialize(Ar& ar) { - ar & getLastError & eventName & reply; + serializer(ar, getLastError, eventName, reply); } }; @@ -254,7 +254,7 @@ struct DebugEntryRef { template void serialize(Ar& ar) { - ar & time & address & context & version & mutation; + serializer(ar, time, address, context, version, mutation); } }; @@ -266,7 +266,7 @@ struct DiskStoreRequest { template void serialize(Ar& ar) { - ar & includePartialStores & reply; + serializer(ar, includePartialStores, reply); } }; diff --git a/fdbserver/pubsub.h b/fdbserver/pubsub.h index cd0cf70bc1..970774e9de 100644 --- a/fdbserver/pubsub.h +++ b/fdbserver/pubsub.h @@ -69,7 +69,7 @@ public: template void serialize( Ar& ar ) { - ar & originatorFeed & messageId & data & data.arena(); + serializer(ar, originatorFeed, messageId, data, data.arena()); } }; diff --git a/fdbserver/workloads/Ping.actor.cpp b/fdbserver/workloads/Ping.actor.cpp index 8a65fb4c1c..f61f8b1aec 100644 --- a/fdbserver/workloads/Ping.actor.cpp +++ b/fdbserver/workloads/Ping.actor.cpp @@ -34,7 +34,7 @@ struct PingWorkloadInterface { template void serialize( Ar& ar ) { - ar & payloadPing; + serializer(ar, payloadPing); } }; diff --git a/fdbserver/workloads/Sideband.actor.cpp b/fdbserver/workloads/Sideband.actor.cpp index 461d66f664..87b8d278cb 100644 --- a/fdbserver/workloads/Sideband.actor.cpp +++ b/fdbserver/workloads/Sideband.actor.cpp @@ -32,7 +32,7 @@ struct SidebandMessage { template void serialize( Ar& ar ) { - ar & key & commitVersion; + serializer(ar, key, commitVersion); } }; @@ -43,7 +43,7 @@ struct SidebandInterface { template void serialize( Ar& ar ) { - ar & updates; + serializer(ar, updates); } }; diff --git a/flow/Arena.h b/flow/Arena.h index 1b72fc088c..65399f6acb 100644 --- a/flow/Arena.h +++ b/flow/Arena.h @@ -375,7 +375,7 @@ public: //T tmp; //ar >> tmp; //*this = tmp; - ar & (*(T*)this) & arena(); + serializer(ar, (*(T*)this), arena()); } /*static Standalone fakeStandalone( const T& t ) { diff --git a/flow/CompressedInt.h b/flow/CompressedInt.h index 97cfc0d486..e473f0bf80 100644 --- a/flow/CompressedInt.h +++ b/flow/CompressedInt.h @@ -51,7 +51,7 @@ struct CompressedInt { template void serialize(Ar &ar) { if(ar.isDeserializing) { uint8_t b; - ar & b; + serializer(ar, b); int bytesToRead = 0; // Additional bytes to read after the required first byte bool positive = (b & 0x80) != 0; // Sign bit if(!positive) @@ -62,7 +62,7 @@ struct CompressedInt { // Scan the unary len bits across multiple bytes if needed while(1) { if(hb == 0) { // Go to next byte if needed - ar & b; // Read byte + serializer(ar, b); // Read byte if(!positive) b = ~b; // Negative, so invert bytes read @@ -78,7 +78,7 @@ struct CompressedInt { value = b; // b contains the highest byte of value while(bytesToRead-- != 0) { - ar & b; // Read byte + serializer(ar, b); // Read byte if(!positive) b = ~b; // Negative, so invert bytes read value <<= 8; // Shift value up to make room for new byte diff --git a/flow/Error.h b/flow/Error.h index 2f0bd0851d..545fccb78a 100644 --- a/flow/Error.h +++ b/flow/Error.h @@ -48,7 +48,7 @@ public: template void serialize( Ar& ar ) { - ar & error_code; + serializer(ar, error_code); } Error() : error_code(invalid_error_code), flags(0) {} diff --git a/flow/IRandom.h b/flow/IRandom.h index e4a6c65a6f..c8362e23ef 100644 --- a/flow/IRandom.h +++ b/flow/IRandom.h @@ -51,7 +51,7 @@ public: template void serialize_unversioned(Ar& ar) { // Changing this serialization format will affect key definitions, so can't simply be versioned! - ar & part[0] & part[1]; + serializer(ar, part[0], part[1]); } }; diff --git a/flow/Net2.actor.cpp b/flow/Net2.actor.cpp index a5fa40da0b..29136e7c0e 100644 --- a/flow/Net2.actor.cpp +++ b/flow/Net2.actor.cpp @@ -1023,7 +1023,7 @@ struct TestGVR { template void serialize( Ar& ar ) { - ar & key & version & debugID & reply; + serializer(ar, key, version, debugID, reply); } }; diff --git a/flow/README.md b/flow/README.md index b42b137c85..50677ab0ed 100644 --- a/flow/README.md +++ b/flow/README.md @@ -240,7 +240,7 @@ struct CountingServerInterface { // serialization code required for use on a network template void serialize( Ar& ar ) { - ar & addCount & subtractCount & getCount; + serializer(ar, addCount, subtractCount, getCount); } }; ``` diff --git a/flow/TDMetric.actor.h b/flow/TDMetric.actor.h index 98d1922382..a359aa6a46 100755 --- a/flow/TDMetric.actor.h +++ b/flow/TDMetric.actor.h @@ -338,9 +338,9 @@ struct FieldHeader { sum += v; } template void serialize(Ar &ar) { - ar & version; + serializer(ar, version); ASSERT(version == 1); - ar & count & sum; + serializer(ar, count, sum); } }; @@ -1126,9 +1126,9 @@ struct FieldHeader> { previous_time = v.time; } template void serialize(Ar &ar) { - ar & version; + serializer(ar, version); ASSERT(version == 1); - ar & count & area; + serializer(ar, count, area); } }; diff --git a/flow/flow.h b/flow/flow.h index 3118a52eeb..45de10a141 100644 --- a/flow/flow.h +++ b/flow/flow.h @@ -170,10 +170,10 @@ public: // SOMEDAY: specialize for space efficiency? if (valid && Ar::isDeserializing) (*(T *)&value).~T(); - ar & valid; + serializer(ar, valid); if (valid) { if (Ar::isDeserializing) new (&value) T(); - ar & *(T*)&value; + serializer(ar, *(T*)&value); } } @@ -247,10 +247,10 @@ public: template void serialize(Ar& ar) { // SOMEDAY: specialize for space efficiency? - ar & error; + serializer(ar, error); if (present()) { if (Ar::isDeserializing) new (&value) T(); - ar & *(T*)&value; + serializer(ar, *(T*)&value); } } diff --git a/flow/serialize.h b/flow/serialize.h index 9b382d6296..89cb011676 100644 --- a/flow/serialize.h +++ b/flow/serialize.h @@ -62,15 +62,20 @@ inline typename Archive::READER& operator >> (Archive& ar, Item& item ) { return ar; } -template -inline typename Archive::WRITER& operator & (Archive& ar, Item& item ) { +template +void serializer(Archive& ar) {} + +template +typename Archive::WRITER& serializer(Archive& ar, const Item& item, const Items&... items) { save(ar, item); + serializer(ar, items...); return ar; } -template -inline typename Archive::READER& operator & (Archive& ar, Item& item ) { +template +typename Archive::READER& serializer(Archive& ar, Item& item, Items&... items) { load(ar, item); + serializer(ar, items...); return ar; } @@ -121,7 +126,7 @@ template class Serializer< Archive, std::pair, void > { public: static void serialize( Archive& ar, std::pair& p ) { - ar & p.first & p.second; + serializer(ar, p.first, p.second); } };