From 917684b4d5addee7fe15b6926063bfbd01a8121e Mon Sep 17 00:00:00 2001 From: koko2pp Date: Mon, 27 Nov 2023 19:45:57 +0800 Subject: [PATCH] fix the file --- src/kvstorageclient/etcd_client.h | 100 ++++++++++++++---------------- 1 file changed, 48 insertions(+), 52 deletions(-) diff --git a/src/kvstorageclient/etcd_client.h b/src/kvstorageclient/etcd_client.h index b9c2266d83..16aec44e6a 100644 --- a/src/kvstorageclient/etcd_client.h +++ b/src/kvstorageclient/etcd_client.h @@ -24,10 +24,9 @@ #define SRC_KVSTORAGECLIENT_ETCD_CLIENT_H_ #include - #include -#include #include +#include namespace curve { namespace kvstorage { @@ -44,7 +43,7 @@ class KVStorageClient { * * @return error code EtcdErrCode */ - virtual int Put(const std::string& key, const std::string& value) = 0; + virtual int Put(const std::string &key, const std::string &value) = 0; /** * @brief PutRewithRevision store key-value @@ -55,9 +54,8 @@ class KVStorageClient { * * @return error code EtcdErrCode */ - virtual int PutRewithRevision(const std::string& key, - const std::string& value, - int64_t* revision) = 0; + virtual int PutRewithRevision(const std::string &key, + const std::string &value, int64_t *revision) = 0; /** * @brief Get Get the value of the specified key @@ -67,7 +65,7 @@ class KVStorageClient { * * @return error code */ - virtual int Get(const std::string& key, std::string* out) = 0; + virtual int Get(const std::string &key, std::string *out) = 0; /** * @brief List Get all the values ​​between [startKey, endKey) @@ -78,16 +76,15 @@ class KVStorageClient { * * @return error code */ - virtual int List(const std::string& startKey, const std::string& endKey, - std::vector* values) = 0; + virtual int List(const std::string &startKey, const std::string &endKey, + std::vector *values) = 0; /** * @brief List all the key and values between [startKey, endKey) * * @param[in] startKey * @param[in] endKey - * @param[out] out store key/value pairs that key is between [startKey, - * endKey) + * @param[out] out store key/value pairs that key is between [startKey, endKey) * * @return error code */ @@ -101,7 +98,7 @@ class KVStorageClient { * * @return error code */ - virtual int Delete(const std::string& key) = 0; + virtual int Delete(const std::string &key) = 0; /** * @brief DeleteRewithRevision Delete the value of the specified key @@ -111,18 +108,17 @@ class KVStorageClient { * * @return error code */ - virtual int DeleteRewithRevision(const std::string& key, - int64_t* revision) = 0; + virtual int DeleteRewithRevision( + const std::string &key, int64_t *revision) = 0; /* - * @brief TxnN Operate transactions in the order of ops[0] ops[1] ..., - * currently 2 and 3 operations are supported //NOLINT - * - * @param[in] ops Operation set - * - * @return error code - */ - virtual int TxnN(const std::vector& ops) = 0; + * @brief TxnN Operate transactions in the order of ops[0] ops[1] ..., currently 2 and 3 operations are supported //NOLINT + * + * @param[in] ops Operation set + * + * @return error code + */ + virtual int TxnN(const std::vector &ops) = 0; /** * @brief CompareAndSwap Transaction, to achieve CAS @@ -133,15 +129,17 @@ class KVStorageClient { * * @return error code */ - virtual int CompareAndSwap(const std::string& key, const std::string& preV, - const std::string& target) = 0; + virtual int CompareAndSwap(const std::string &key, const std::string &preV, + const std::string &target) = 0; }; // encapsulate the c header file of etcd generated by go compilation class EtcdClientImp : public KVStorageClient { public: EtcdClientImp() {} - ~EtcdClientImp() { CloseClient(); } + ~EtcdClientImp() { + CloseClient(); + } /** * @brief Init init the etcdclient, a global var in go @@ -156,30 +154,30 @@ class EtcdClientImp : public KVStorageClient { void CloseClient(); - int Put(const std::string& key, const std::string& value) override; + int Put(const std::string &key, const std::string &value) override; - int PutRewithRevision(const std::string& key, const std::string& value, - int64_t* revision) override; + int PutRewithRevision(const std::string &key, const std::string &value, + int64_t *revision) override; - int Get(const std::string& key, std::string* out) override; + int Get(const std::string &key, std::string *out) override; - int List(const std::string& startKey, const std::string& endKey, - std::vector* values) override; + int List(const std::string &startKey, + const std::string &endKey, std::vector *values) override; int List(const std::string& startKey, const std::string& endKey, - std::vector>* out) override; + std::vector >* out) override; - int Delete(const std::string& key) override; + int Delete(const std::string &key) override; - int DeleteRewithRevision(const std::string& key, - int64_t* revision) override; + int DeleteRewithRevision( + const std::string &key, int64_t *revision) override; - int TxnN(const std::vector& ops) override; + int TxnN(const std::vector &ops) override; - int CompareAndSwap(const std::string& key, const std::string& preV, - const std::string& target) override; + int CompareAndSwap(const std::string &key, const std::string &preV, + const std::string &target) override; - virtual int GetCurrentRevision(int64_t* revision); + virtual int GetCurrentRevision(int64_t *revision); /** * @brief ListWithLimitAndRevision @@ -193,11 +191,9 @@ class EtcdClientImp : public KVStorageClient { * @param[out] values the value vector of all the key-value pairs * @param[out] lastKey the last key of the vector */ - virtual int ListWithLimitAndRevision(const std::string& startKey, - const std::string& endKey, - int64_t limit, int64_t revision, - std::vector* values, - std::string* lastKey); + virtual int ListWithLimitAndRevision(const std::string &startKey, + const std::string &endKey, int64_t limit, int64_t revision, + std::vector *values, std::string *lastKey); /** * @brief CampaignLeader Leader campaign through etcd, return directly if @@ -213,14 +209,14 @@ class EtcdClientImp : public KVStorageClient { * leader when the session expired after * client offline. * @param[in] electionTimeoutMs the timeout,0 will block always - * @param[out] leaderOid leader's objectId,recorded in objectManager + * @param[out] leaderOid leader的objectId,recorded in objectManager * * @return EtcdErrCode::EtcdCampaignLeaderSuccess success,others fail */ - virtual int CampaignLeader(const std::string& pfx, - const std::string& leaderName, - uint32_t sessionInterSec, - uint32_t electionTimeoutMs, uint64_t* leaderOid); + virtual int CampaignLeader( + const std::string &pfx, const std::string &leaderName, + uint32_t sessionInterSec, uint32_t electionTimeoutMs, + uint64_t *leaderOid); /** * @brief LeaderObserve @@ -232,8 +228,8 @@ class EtcdClientImp : public KVStorageClient { * * @return if returned, the session between mds and etcd expired */ - virtual int LeaderObserve(uint64_t leaderOid, - const std::string& leaderName); + virtual int LeaderObserve( + uint64_t leaderOid, const std::string &leaderName); /** * @brief LeaderResign the leader resigns initiatively, the other peers @@ -245,7 +241,7 @@ class EtcdClientImp : public KVStorageClient { * @return EtcdErrCode::EtcdLeaderResiginSuccess resign seccess * EtcdErrCode::EtcdLeaderResiginErr resign fail */ - virtual int LeaderResign(uint64_t leaderOid, uint64_t timeoutMs); + virtual int LeaderResign(uint64_t leaderOid, uint64_t timeoutMs); // for test void SetTimeout(int time);