Skip to content

Commit

Permalink
openr (161713802433391999)
Browse files Browse the repository at this point in the history
Reviewed By: xiangxu1121

Differential Revision: D53509702

fbshipit-source-id: fa638f3b60c7215b051a38f5018151e436f5486b
  • Loading branch information
generatedunixname89002005287564 authored and facebook-github-bot committed Feb 7, 2024
1 parent 512e96d commit a7347ee
Show file tree
Hide file tree
Showing 35 changed files with 76 additions and 93 deletions.
2 changes: 1 addition & 1 deletion examples/KvStorePoller.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class KvStorePoller {
public:
/* implicit */ KvStorePoller(std::vector<folly::SocketAddress>& sockAddrs);

~KvStorePoller() {}
~KvStorePoller() = default;

std::pair<
std::optional<std::unordered_map<std::string, thrift::AdjacencyDatabase>>,
Expand Down
3 changes: 1 addition & 2 deletions examples/KvStorePollerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ main(int argc, char** argv) {

// Create Open/R client connected through thrift port
std::vector<folly::SocketAddress> sockAddrs;
sockAddrs.emplace_back(
folly::SocketAddress{FLAGS_host, static_cast<uint16_t>(FLAGS_port)});
sockAddrs.emplace_back(FLAGS_host, static_cast<uint16_t>(FLAGS_port));
auto poller = std::make_unique<openr::KvStorePoller>(sockAddrs);

LOG(INFO) << "KvStorePoller initialized. Periodic dump will follow";
Expand Down
2 changes: 1 addition & 1 deletion openr/ctrl-server/OpenrCtrlHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ class OpenrCtrlHandler final : public thrift::OpenrCtrlCppSvIf,
void closeKvStorePublishers();
void closeFibPublishers();

const std::string nodeName_{""};
const std::string nodeName_;
const std::unordered_set<std::string> acceptablePeerCommonNames_;

// Pointers to Open/R modules
Expand Down
2 changes: 1 addition & 1 deletion openr/ctrl-server/tests/OpenrCtrlHandlerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class OpenrCtrlFixture : public ::testing::Test {
};

TEST_F(OpenrCtrlFixture, GetMyNodeName) {
std::string res{""};
std::string res;
handler_->getMyNodeName(res);
EXPECT_EQ(nodeName_, res);
}
Expand Down
1 change: 0 additions & 1 deletion openr/decision/Decision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ Decision::readRibPolicy() {
"{} seconds",
FLAGS_rib_policy_file,
ttlDurationSec);
return;
}

void
Expand Down
2 changes: 1 addition & 1 deletion openr/decision/LinkState.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ class DijkstraQSpfNode {
return result.metric();
}

const std::string nodeName{""};
const std::string nodeName;
LinkState::NodeSpfResult result;
};

Expand Down
5 changes: 2 additions & 3 deletions openr/decision/RibEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <folly/IPAddress.h>
#include <openr/common/NetworkUtil.h>
#include <openr/if/gen-cpp2/Network_types.h>
#include <openr/if/gen-cpp2/OpenrCtrl.h>
#include <openr/if/gen-cpp2/Types_types.h>

Expand Down Expand Up @@ -53,7 +52,7 @@ struct RibUnicastEntry : RibEntry {
bool localRouteConsidered{false};

// constructor
explicit RibUnicastEntry() {}
explicit RibUnicastEntry() = default;
explicit RibUnicastEntry(const folly::CIDRNetwork& prefix) : prefix(prefix) {}

RibUnicastEntry(
Expand Down Expand Up @@ -119,7 +118,7 @@ struct RibMplsEntry : RibEntry {
explicit RibMplsEntry(int32_t label) : label(label) {}

// constructor
explicit RibMplsEntry() {}
explicit RibMplsEntry() = default;
RibMplsEntry(
int32_t label, std::unordered_set<thrift::NextHopThrift> nexthops)
: RibEntry(std::move(nexthops)), label(label) {}
Expand Down
2 changes: 1 addition & 1 deletion openr/decision/RibPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ RibPolicy::RibPolicy(thrift::RibPolicy const& policy)

// Populate policy statements
for (auto const& statement : *policy.statements()) {
policyStatements_.emplace_back(RibPolicyStatement(statement));
policyStatements_.emplace_back(statement);
}
}

Expand Down
7 changes: 4 additions & 3 deletions openr/decision/tests/DecisionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include <stdio.h>
#include <cstdio>

#include <fb303/ServiceData.h>
#include <folly/IPAddress.h>
Expand Down Expand Up @@ -2979,7 +2979,7 @@ TEST_P(SimpleRingTopologyFixture, OverloadLinkTest) {
class ParallelAdjRingTopologyFixture
: public ::testing::TestWithParam<std::optional<thrift::PrefixType>> {
public:
ParallelAdjRingTopologyFixture() {}
ParallelAdjRingTopologyFixture() = default;

protected:
void
Expand Down Expand Up @@ -5779,8 +5779,9 @@ TEST_F(DecisionTestFixture, DecisionSubReliability) {
// Create adjDb value
vector<thrift::Adjacency> adjs;
for (int j = std::max(1, i - 3); j <= std::min(1000, i + 3); j++) {
if (i == j)
if (i == j) {
continue;
}
const std::string dst = folly::to<std::string>(j);
auto adj = createAdjacency(
dst,
Expand Down
7 changes: 4 additions & 3 deletions openr/decision/tests/PrefixStateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ class PrefixStateTestFixture : public ::testing::Test {
for (const auto& [key, innerMap1] : map1) {
const auto& iter = map2.find(key);
EXPECT_TRUE(iter != map2.end());
if (iter == map2.end())
if (iter == map2.end()) {
continue;
}
const auto& innerMap2 = iter->second;
EXPECT_EQ(innerMap1.size(), innerMap2.size());
for (const auto& [k, v] : innerMap1) {
const auto& innerIter = innerMap2.find(k);
EXPECT_TRUE(innerIter != innerMap2.end());
if (innerIter == innerMap2.end())
if (innerIter == innerMap2.end()) {
continue;
}
EXPECT_EQ(*innerIter->second, *v);
}
}
return;
}
};

Expand Down
2 changes: 1 addition & 1 deletion openr/decision/tests/RoutingBenchmarkUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ createGrid(
prefixGenerator.ipv6PrefixGenerator(numPrefixes, kBitMaskLen);

// prefixes
for (auto prefix : prefixes) {
for (const auto& prefix : prefixes) {
auto [key, db] = createPrefixKeyAndDb(
nodeName,
createPrefixEntry(
Expand Down
2 changes: 1 addition & 1 deletion openr/dispatcher/DispatcherQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace openr {

DispatcherQueue::DispatcherQueue() {}
DispatcherQueue::DispatcherQueue() = default;

DispatcherQueue::~DispatcherQueue() {
close();
Expand Down
2 changes: 1 addition & 1 deletion openr/kvstore/KvStorePublisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class KvStorePublisher {
std::chrono::steady_clock::now(),
int64_t total_messages = 0);

~KvStorePublisher() {}
~KvStorePublisher() = default;

// Invoked whenever there is change. Apply filter and publish changes
void publish(const thrift::Publication& pub);
Expand Down
2 changes: 1 addition & 1 deletion openr/kvstore/KvStoreUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct SelfOriginatedValue {
// Backoff for advertising ttl updates for this key-val
ExponentialBackoff<std::chrono::milliseconds> ttlBackoff;

SelfOriginatedValue() {}
SelfOriginatedValue() = default;
explicit SelfOriginatedValue(const thrift::Value& val) : value(val) {}
};

Expand Down
1 change: 0 additions & 1 deletion openr/kvstore/tests/DualTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ class DualTestNode final : public DualNode {
std::string newNhStr = newNh.has_value() ? *newNh : "none";
VLOG(1) << "node: " << nodeId << " at root: " << rootId << " nexthop"
<< " change " << oldNhStr << " -> " << newNhStr;
return;
}

// event base loop
Expand Down
3 changes: 2 additions & 1 deletion openr/kvstore/tests/KvStoreBenchmarkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,9 @@ BM_KvStoreDumpHashWithFilters(
auto keyVal =
genRandomKvStoreKeyVal(kKeyLen, kValLen, 1, std::to_string(deviceId));
keyVals[keyVal.first] = keyVal.second;
if (prefixSet.size() <= numOfKeysToFilter)
if (prefixSet.size() <= numOfKeysToFilter) {
prefixSet.emplace(keyVal.first);
}
}

keyPrefixList.insert(
Expand Down
6 changes: 2 additions & 4 deletions openr/kvstore/tests/KvStoreUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@ TEST_F(MultipleKvStoreTestFixture, dumpAllTest) {
const uint16_t port2 = kvStoreWrapper2_->getThriftPort();

std::vector<folly::SocketAddress> sockAddrs;
sockAddrs.emplace_back(
folly::SocketAddress{Constants::kPlatformHost.toString(), port1});
sockAddrs.emplace_back(
folly::SocketAddress{Constants::kPlatformHost.toString(), port2});
sockAddrs.emplace_back(Constants::kPlatformHost.toString(), port1);
sockAddrs.emplace_back(Constants::kPlatformHost.toString(), port2);

// Step1: insert (k1, v1) and (k2, v2) to different KvStore instances
{
Expand Down
2 changes: 1 addition & 1 deletion openr/link-monitor/LinkMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ LinkMonitor::neighborUpEvent(
<< ", onlyUsedByOtherNode: " << std::boolalpha << onlyUsedByOtherNode;
fb303::fbData->addStatValue("link_monitor.neighbor_up", 1, fb303::SUM);

std::string peerAddr{""};
std::string peerAddr;
if (not mockMode_) {
// peer address used for KvStore external sync over thrift
peerAddr = fmt::format("{}%{}", toString(neighborAddrV6), localIfName);
Expand Down
8 changes: 3 additions & 5 deletions openr/messaging/Queue-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

#include <string>
#include "openr/messaging/Queue.h"
namespace openr {
namespace messaging {
namespace openr::messaging {

template <typename ValueType>
RQueue<ValueType>::RQueue(std::shared_ptr<RWQueue<ValueType>> queue)
Expand Down Expand Up @@ -46,7 +45,7 @@ RQueue<ValueType>::getReaderId() {
}

template <typename ValueType>
RWQueue<ValueType>::RWQueue() {}
RWQueue<ValueType>::RWQueue() = default;

template <typename ValueType>
RWQueue<ValueType>::RWQueue(const std::string& queueId) : queueId_(queueId) {}
Expand Down Expand Up @@ -227,5 +226,4 @@ RWQueue<ValueType>::getStats() {
return RWQueueStats{"", reads_, writes_, queue_.size()};
}

} // namespace messaging
} // namespace openr
} // namespace openr::messaging
10 changes: 4 additions & 6 deletions openr/messaging/Queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <folly/experimental/coro/Task.h>
#endif

namespace openr {
namespace messaging {
namespace openr::messaging {

enum class QueueError {
QUEUE_CLOSED,
Expand All @@ -44,7 +43,7 @@ template <typename ValueType>
class RQueue {
public:
explicit RQueue(std::shared_ptr<RWQueue<ValueType>> queue);
virtual ~RQueue() {}
virtual ~RQueue() = default;

/**
* Blocking read for native threads/fibers. In-case of fibers, the fiber
Expand Down Expand Up @@ -145,7 +144,7 @@ class RWQueue {

private:
// Name/id of the queue
std::string queueId_{""};
std::string queueId_;

struct PendingRead {
folly::fibers::Baton baton;
Expand Down Expand Up @@ -179,7 +178,6 @@ class RWQueue {
size_t reads_{0};
};

} // namespace messaging
} // namespace openr
} // namespace openr::messaging

#include <openr/messaging/Queue-inl.h>
8 changes: 3 additions & 5 deletions openr/messaging/ReplicateQueue-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#include <vector>
#include "openr/messaging/Queue.h"
#include "openr/messaging/ReplicateQueue.h"
namespace openr {
namespace messaging {
namespace openr::messaging {

template <typename ValueType>
ReplicateQueue<ValueType>::ReplicateQueue() {}
ReplicateQueue<ValueType>::ReplicateQueue() = default;

template <typename ValueType>
ReplicateQueue<ValueType>::~ReplicateQueue() {
Expand Down Expand Up @@ -136,5 +135,4 @@ ReplicateQueue<ValueType>::getReplicationStats() {
return stats;
}

} // namespace messaging
} // namespace openr
} // namespace openr::messaging
6 changes: 2 additions & 4 deletions openr/messaging/ReplicateQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include <openr/messaging/Queue.h>
#include <list>

namespace openr {
namespace messaging {
namespace openr::messaging {

class ReplicateQueueBase {
public:
Expand Down Expand Up @@ -98,7 +97,6 @@ class ReplicateQueue : public ReplicateQueueBase {
size_t writes_{0};
};

} // namespace messaging
} // namespace openr
} // namespace openr::messaging

#include <openr/messaging/ReplicateQueue-inl.h>
2 changes: 0 additions & 2 deletions openr/messaging/tests/ReplicateQueueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <folly/fibers/FiberManagerMap.h>
#include <folly/io/async/EventBase.h>

#include <openr/messaging/ReplicateQueue.h>

using namespace openr::messaging;

TEST(ReplicateQueueTest, Test) {
Expand Down
2 changes: 1 addition & 1 deletion openr/monitor/SystemMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SystemMetrics {
uint64_t sysTime = 0; /* CPU time used in system mode*/
uint64_t totalTime = 0; /* total CPU time used */
uint64_t timestamp = 0; /* timestamp for current record */
ProcCpuTime() {} // for initializing the prevCpuTime
ProcCpuTime() = default; // for initializing the prevCpuTime
explicit ProcCpuTime(struct rusage& usage)
: userTime(
usage.ru_utime.tv_sec * 1.0e9 + usage.ru_utime.tv_usec * 1.0e3),
Expand Down
2 changes: 1 addition & 1 deletion openr/nl/NetlinkMessageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include <memory>
#include <queue>

#include <limits.h>
#include <linux/lwtunnel.h>
#include <linux/mpls.h>
#include <linux/rtnetlink.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <climits>

#include <folly/futures/Future.h>

Expand Down
10 changes: 5 additions & 5 deletions openr/nl/NetlinkTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Route::Route(const RouteBuilder& builder)
oif_(builder.getOIf()),
prefSrc_(builder.getPrefSrc()) {}

Route::~Route() {}
Route::~Route() = default;

Route::Route(Route&& other) noexcept {
*this = std::move(other);
Expand Down Expand Up @@ -775,7 +775,7 @@ IfAddress::IfAddress(const IfAddressBuilder& builder)
family_(builder.getFamily()),
preferredLft_(builder.getPreferredLft()) {}

IfAddress::~IfAddress() {}
IfAddress::~IfAddress() = default;

IfAddress::IfAddress(IfAddress&& other) noexcept {
*this = std::move(other);
Expand Down Expand Up @@ -958,7 +958,7 @@ Neighbor::Neighbor(const NeighborBuilder& builder)
linkAddress_(builder.getLinkAddress()),
state_(builder.getState()) {}

Neighbor::~Neighbor() {}
Neighbor::~Neighbor() = default;

Neighbor::Neighbor(Neighbor&& other) noexcept {
*this = std::move(other);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ GreInfo::GreInfo(
uint8_t ttl)
: localAddr_(localAddr), remoteAddr_(remoteAddr), ttl_(ttl) {}

GreInfo::~GreInfo() {}
GreInfo::~GreInfo() = default;

GreInfo::GreInfo(GreInfo&& other) noexcept {
*this = std::move(other);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ Link::Link(const LinkBuilder& builder)
greInfo_(builder.getGreInfo()),
linkGroup_(builder.getLinkGroup()) {}

Link::~Link() {}
Link::~Link() = default;

Link::Link(Link&& other) noexcept {
*this = std::move(other);
Expand Down
Loading

0 comments on commit a7347ee

Please sign in to comment.