aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-09-04 19:26:49 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-09-04 19:26:49 +0000
commit54ef666d30f8486e56382dc7962ff524962578e8 (patch)
tree37396302b0a7c246488fada6802b8acb420a1e6f /storage/src
parentbedbd44069d0464bbd23a367e144cb32fad4573a (diff)
- push_back => emplace_back
- noexcept - less default values in methods
Diffstat (limited to 'storage/src')
-rw-r--r--storage/src/tests/distributor/top_level_bucket_db_updater_test.cpp184
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketcopy.h3
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp40
-rw-r--r--storage/src/vespa/storageapi/message/bucket.h17
-rw-r--r--storage/src/vespa/storageapi/messageapi/bucketcommand.cpp8
-rw-r--r--storage/src/vespa/storageapi/messageapi/bucketcommand.h2
-rw-r--r--storage/src/vespa/storageapi/messageapi/bucketinfocommand.h2
-rw-r--r--storage/src/vespa/storageapi/messageapi/maintenancecommand.h10
-rw-r--r--storage/src/vespa/storageapi/messageapi/storagecommand.cpp2
-rw-r--r--storage/src/vespa/storageapi/messageapi/storagecommand.h3
10 files changed, 91 insertions, 180 deletions
diff --git a/storage/src/tests/distributor/top_level_bucket_db_updater_test.cpp b/storage/src/tests/distributor/top_level_bucket_db_updater_test.cpp
index 074b1492a6e..596b4491ff6 100644
--- a/storage/src/tests/distributor/top_level_bucket_db_updater_test.cpp
+++ b/storage/src/tests/distributor/top_level_bucket_db_updater_test.cpp
@@ -20,7 +20,6 @@
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <sstream>
-#include <iomanip>
using namespace storage::api;
using namespace storage::lib;
@@ -911,16 +910,11 @@ TEST_F(TopLevelBucketDBUpdaterTest, bit_change) {
for (int i=0; cnt < 2; i++) {
auto distribution = _component->getDistribution();
std::vector<uint16_t> distributors;
- if (distribution->getIdealDistributorNode(
- lib::ClusterState("bits:14 storage:1 distributor:2"),
- document::BucketId(16, i))
- == 0)
+ if (distribution->getIdealDistributorNode(lib::ClusterState("bits:14 storage:1 distributor:2"),
+ document::BucketId(16, i)) == 0)
{
- vec.push_back(api::RequestBucketInfoReply::Entry(
- document::BucketId(16, i),
- api::BucketInfo(10,1,1)));
-
- bucketlist.push_back(document::BucketId(16, i));
+ vec.emplace_back(document::BucketId(16, i), api::BucketInfo(10,1,1));
+ bucketlist.emplace_back(16, i);
cnt++;
}
}
@@ -953,14 +947,10 @@ TEST_F(TopLevelBucketDBUpdaterTest, bit_change) {
api::RequestBucketInfoReply::EntryVector &vec = sreply->getBucketInfo();
for (uint32_t i = 0; i < 3; ++i) {
- vec.push_back(api::RequestBucketInfoReply::Entry(
- document::BucketId(16, i),
- api::BucketInfo(10,1,1)));
+ vec.emplace_back(document::BucketId(16, i), api::BucketInfo(10,1,1));
}
- vec.push_back(api::RequestBucketInfoReply::Entry(
- document::BucketId(16, 4),
- api::BucketInfo(10,1,1)));
+ vec.emplace_back(document::BucketId(16, 4), api::BucketInfo(10,1,1));
}
bucket_db_updater().onRequestBucketInfoReply(sreply);
@@ -1047,9 +1037,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, recheck_node) {
EXPECT_EQ(bucket.getBucketId(), rbi.getBuckets()[0]);
auto reply = std::make_shared<api::RequestBucketInfoReply>(rbi);
- reply->getBucketInfo().push_back(
- api::RequestBucketInfoReply::Entry(document::BucketId(16, 3),
- api::BucketInfo(20, 10, 12, 50, 60, true, true)));
+ reply->getBucketInfo().emplace_back(document::BucketId(16, 3), api::BucketInfo(20, 10, 12, 50, 60, true, true));
stripe_bucket_db_updater.onRequestBucketInfoReply(reply);
lib::ClusterState state("distributor:1 storage:3");
@@ -1110,8 +1098,8 @@ TEST_F(TopLevelBucketDBUpdaterTest, notify_bucket_change) {
ASSERT_EQ(size_t(2), _sender.commands().size());
std::vector<api::BucketInfo> infos;
- infos.push_back(api::BucketInfo(4567, 200, 2000, 400, 4000, true, true));
- infos.push_back(api::BucketInfo(8999, 300, 3000, 500, 5000, false, false));
+ infos.emplace_back(4567, 200, 2000, 400, 4000, true, true);
+ infos.emplace_back(8999, 300, 3000, 500, 5000, false, false);
for (int i = 0; i < 2; ++i) {
auto& rbi = dynamic_cast<RequestBucketInfoCommand&>(*_sender.command(i));
@@ -1120,7 +1108,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, notify_bucket_change) {
EXPECT_EQ(bucket_id, rbi.getBuckets()[0]);
auto reply = std::make_shared<api::RequestBucketInfoReply>(rbi);
- reply->getBucketInfo().push_back(api::RequestBucketInfoReply::Entry(bucket_id, infos[i]));
+ reply->getBucketInfo().emplace_back(bucket_id, infos[i]);
stripe_of_bucket(bucket_id).bucket_db_updater().onRequestBucketInfoReply(reply);
}
@@ -1166,10 +1154,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, notify_bucket_change_from_node_down) {
EXPECT_EQ(bucket_id, rbi.getBuckets()[0]);
auto reply = std::make_shared<api::RequestBucketInfoReply>(rbi);
- reply->getBucketInfo().push_back(
- api::RequestBucketInfoReply::Entry(
- bucket_id,
- api::BucketInfo(8999, 300, 3000, 500, 5000, false, false)));
+ reply->getBucketInfo().emplace_back(bucket_id, api::BucketInfo(8999, 300, 3000, 500, 5000, false, false));
stripe_of_bucket(bucket_id).bucket_db_updater().onRequestBucketInfoReply(reply);
// No change
@@ -1233,9 +1218,9 @@ TEST_F(TopLevelBucketDBUpdaterTest, merge_reply) {
add_nodes_to_stripe_bucket_db(bucket_id, "0=1234,1=1234,2=1234");
std::vector<api::MergeBucketCommand::Node> nodes;
- nodes.push_back(api::MergeBucketCommand::Node(0));
- nodes.push_back(api::MergeBucketCommand::Node(1));
- nodes.push_back(api::MergeBucketCommand::Node(2));
+ nodes.emplace_back(0);
+ nodes.emplace_back(1);
+ nodes.emplace_back(2);
api::MergeBucketCommand cmd(makeDocumentBucket(bucket_id), nodes, 0);
auto reply = std::make_shared<api::MergeBucketReply>(cmd);
@@ -1253,9 +1238,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, merge_reply) {
EXPECT_EQ(bucket_id, req->getBuckets()[0]);
auto reqreply = std::make_shared<api::RequestBucketInfoReply>(*req);
- reqreply->getBucketInfo().push_back(
- api::RequestBucketInfoReply::Entry(bucket_id,
- api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1))));
+ reqreply->getBucketInfo().emplace_back(bucket_id, api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1)));
stripe_of_bucket(bucket_id).bucket_db_updater().onRequestBucketInfoReply(reqreply);
}
@@ -1275,7 +1258,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, merge_reply_node_down) {
add_nodes_to_stripe_bucket_db(bucket_id, "0=1234,1=1234,2=1234");
for (uint32_t i = 0; i < 3; ++i) {
- nodes.push_back(api::MergeBucketCommand::Node(i));
+ nodes.emplace_back(i);
}
api::MergeBucketCommand cmd(makeDocumentBucket(bucket_id), nodes, 0);
@@ -1296,10 +1279,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, merge_reply_node_down) {
EXPECT_EQ(bucket_id, req->getBuckets()[0]);
auto reqreply = std::make_shared<api::RequestBucketInfoReply>(*req);
- reqreply->getBucketInfo().push_back(
- api::RequestBucketInfoReply::Entry(
- bucket_id,
- api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1))));
+ reqreply->getBucketInfo().emplace_back(bucket_id, api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1)));
stripe_of_bucket(bucket_id).bucket_db_updater().onRequestBucketInfoReply(reqreply);
}
@@ -1338,10 +1318,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, merge_reply_node_down_after_request_sent) {
EXPECT_EQ(bucket_id, req->getBuckets()[0]);
auto reqreply = std::make_shared<api::RequestBucketInfoReply>(*req);
- reqreply->getBucketInfo().push_back(
- api::RequestBucketInfoReply::Entry(
- bucket_id,
- api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1))));
+ reqreply->getBucketInfo().emplace_back(bucket_id, api::BucketInfo(10 * (i + 1), 100 * (i +1), 1000 * (i+1)));
stripe_of_bucket(bucket_id).bucket_db_updater().onRequestBucketInfoReply(reqreply);
}
@@ -1360,7 +1337,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, flush) {
std::vector<api::MergeBucketCommand::Node> nodes;
for (uint32_t i = 0; i < 3; ++i) {
- nodes.push_back(api::MergeBucketCommand::Node(i));
+ nodes.emplace_back(i);
}
api::MergeBucketCommand cmd(makeDocumentBucket(bucket_id), nodes, 0);
@@ -1427,99 +1404,62 @@ TopLevelBucketDBUpdaterTest::get_sent_nodes_distribution_changed(const std::stri
TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_send_messages) {
EXPECT_EQ(get_node_list({0, 1, 2}),
- get_sent_nodes("cluster:d",
- "distributor:1 storage:3"));
+ get_sent_nodes("cluster:d", "distributor:1 storage:3"));
EXPECT_EQ(get_node_list({0, 1}),
- get_sent_nodes("cluster:d",
- "distributor:1 storage:3 .2.s:m"));
+ get_sent_nodes("cluster:d", "distributor:1 storage:3 .2.s:m"));
EXPECT_EQ(get_node_list({2}),
- get_sent_nodes("distributor:1 storage:2",
- "distributor:1 storage:3"));
+ get_sent_nodes("distributor:1 storage:2", "distributor:1 storage:3"));
EXPECT_EQ(get_node_list({2, 3, 4, 5}),
- get_sent_nodes("distributor:1 storage:2",
- "distributor:1 storage:6"));
+ get_sent_nodes("distributor:1 storage:2", "distributor:1 storage:6"));
EXPECT_EQ(get_node_list({0, 1, 2}),
- get_sent_nodes("distributor:4 storage:3",
- "distributor:3 storage:3"));
+ get_sent_nodes("distributor:4 storage:3", "distributor:3 storage:3"));
EXPECT_EQ(get_node_list({0, 1, 2, 3}),
- get_sent_nodes("distributor:4 storage:3",
- "distributor:4 .2.s:d storage:4"));
+ get_sent_nodes("distributor:4 storage:3", "distributor:4 .2.s:d storage:4"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:4 storage:3",
- "distributor:4 .0.s:d storage:4"));
-
- EXPECT_EQ("",
- get_sent_nodes("distributor:3 storage:3",
- "distributor:4 storage:3"));
+ EXPECT_EQ("", get_sent_nodes("distributor:4 storage:3", "distributor:4 .0.s:d storage:4"));
+ EXPECT_EQ("", get_sent_nodes("distributor:3 storage:3", "distributor:4 storage:3"));
EXPECT_EQ(get_node_list({2}),
- get_sent_nodes("distributor:3 storage:3 .2.s:i",
- "distributor:3 storage:3"));
+ get_sent_nodes("distributor:3 storage:3 .2.s:i", "distributor:3 storage:3"));
EXPECT_EQ(get_node_list({1}),
- get_sent_nodes("distributor:3 storage:3 .1.s:d",
- "distributor:3 storage:3"));
+ get_sent_nodes("distributor:3 storage:3 .1.s:d", "distributor:3 storage:3"));
EXPECT_EQ(get_node_list({1, 2, 4}),
- get_sent_nodes("distributor:3 storage:4 .1.s:d .2.s:i",
- "distributor:3 storage:5"));
-
- EXPECT_EQ("",
- get_sent_nodes("distributor:1 storage:3",
- "cluster:d"));
-
- EXPECT_EQ("",
- get_sent_nodes("distributor:1 storage:3",
- "distributor:1 storage:3"));
-
- EXPECT_EQ("",
- get_sent_nodes("distributor:1 storage:3",
- "cluster:d distributor:1 storage:6"));
+ get_sent_nodes("distributor:3 storage:4 .1.s:d .2.s:i", "distributor:3 storage:5"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:3 storage:3",
- "distributor:3 .2.s:m storage:3"));
+ EXPECT_EQ("", get_sent_nodes("distributor:1 storage:3", "cluster:d"));
+ EXPECT_EQ("", get_sent_nodes("distributor:1 storage:3", "distributor:1 storage:3"));
+ EXPECT_EQ("",get_sent_nodes("distributor:1 storage:3", "cluster:d distributor:1 storage:6"));
+ EXPECT_EQ("",get_sent_nodes("distributor:3 storage:3", "distributor:3 .2.s:m storage:3"));
EXPECT_EQ(get_node_list({0, 1, 2}),
- get_sent_nodes("distributor:3 .2.s:m storage:3",
- "distributor:3 .2.s:d storage:3"));
+ get_sent_nodes("distributor:3 .2.s:m storage:3", "distributor:3 .2.s:d storage:3"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:3 .2.s:m storage:3",
- "distributor:3 storage:3"));
+ EXPECT_EQ("", get_sent_nodes("distributor:3 .2.s:m storage:3", "distributor:3 storage:3"));
EXPECT_EQ(get_node_list({0, 1, 2}),
get_sent_nodes_distribution_changed("distributor:3 storage:3"));
EXPECT_EQ(get_node_list({0, 1}),
- get_sent_nodes("distributor:10 storage:2",
- "distributor:10 .1.s:d storage:2"));
+ get_sent_nodes("distributor:10 storage:2", "distributor:10 .1.s:d storage:2"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:2 storage:2",
- "distributor:3 .2.s:i storage:2"));
+ EXPECT_EQ("", get_sent_nodes("distributor:2 storage:2", "distributor:3 .2.s:i storage:2"));
EXPECT_EQ(get_node_list({0, 1, 2}),
- get_sent_nodes("distributor:3 storage:3",
- "distributor:3 .2.s:s storage:3"));
+ get_sent_nodes("distributor:3 storage:3", "distributor:3 .2.s:s storage:3"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:3 .2.s:s storage:3",
- "distributor:3 .2.s:d storage:3"));
+ EXPECT_EQ("", get_sent_nodes("distributor:3 .2.s:s storage:3", "distributor:3 .2.s:d storage:3"));
EXPECT_EQ(get_node_list({1}),
- get_sent_nodes("distributor:3 storage:3 .1.s:m",
- "distributor:3 storage:3"));
+ get_sent_nodes("distributor:3 storage:3 .1.s:m", "distributor:3 storage:3"));
- EXPECT_EQ("",
- get_sent_nodes("distributor:3 storage:3",
- "distributor:3 storage:3 .1.s:m"));
+ EXPECT_EQ("", get_sent_nodes("distributor:3 storage:3", "distributor:3 storage:3 .1.s:m"));
};
TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_receive) {
@@ -1546,10 +1486,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_receive) {
auto rep = std::make_shared<RequestBucketInfoReply>(*req);
- rep->getBucketInfo().push_back(
- RequestBucketInfoReply::Entry(
- document::BucketId(16, i),
- api::BucketInfo(i, i, i, i, i)));
+ rep->getBucketInfo().emplace_back(document::BucketId(16, i),api::BucketInfo(i, i, i, i, i));
ASSERT_TRUE(state->onRequestBucketInfoReply(rep));
ASSERT_EQ((i == (sender.commands().size() - 1)), state->done());
@@ -1569,13 +1506,10 @@ TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_with_group_down) {
// Entire group 1 goes down. Must refetch from all nodes.
EXPECT_EQ(get_node_list({0, 1, 2, 3, 4, 5}),
- get_sent_nodes("distributor:6 storage:6",
- "distributor:6 .2.s:d .3.s:d storage:6"));
+ get_sent_nodes("distributor:6 storage:6", "distributor:6 .2.s:d .3.s:d storage:6"));
// But don't fetch if not the entire group is down.
- EXPECT_EQ("",
- get_sent_nodes("distributor:6 storage:6",
- "distributor:6 .2.s:d storage:6"));
+ EXPECT_EQ("", get_sent_nodes("distributor:6 storage:6", "distributor:6 .2.s:d storage:6"));
}
TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_with_group_down_and_no_handover) {
@@ -1585,8 +1519,7 @@ TEST_F(TopLevelBucketDBUpdaterTest, pending_cluster_state_with_group_down_and_no
// Group is down, but config says to not do anything about it.
EXPECT_EQ(get_node_list({0, 1, 2, 3, 4, 5}, _bucket_spaces.size() - 1),
- get_sent_nodes("distributor:6 storage:6",
- "distributor:6 .2.s:d .3.s:d storage:6"));
+ get_sent_nodes("distributor:6 storage:6", "distributor:6 .2.s:d .3.s:d storage:6"));
}
@@ -1612,23 +1545,16 @@ parse_input_data(const std::string& data,
if (include_bucket_info) {
vespalib::StringTokenizer tok4(tok3[j], "/");
- pending_transition.addNodeInfo(
- document::BucketId(16, atoi(tok4[0].data())),
- BucketCopy(
- timestamp,
- node,
- api::BucketInfo(
- atoi(tok4[1].data()),
- atoi(tok4[2].data()),
- atoi(tok4[3].data()),
- atoi(tok4[2].data()),
- atoi(tok4[3].data()))));
+ pending_transition.addNodeInfo(document::BucketId(16, atoi(tok4[0].data())),
+ BucketCopy(timestamp, node,
+ api::BucketInfo(atoi(tok4[1].data()),
+ atoi(tok4[2].data()),
+ atoi(tok4[3].data()),
+ atoi(tok4[2].data()),
+ atoi(tok4[3].data()))));
} else {
- pending_transition.addNodeInfo(
- document::BucketId(16, atoi(tok3[j].data())),
- BucketCopy(timestamp,
- node,
- api::BucketInfo(3, 3, 3, 3, 3)));
+ pending_transition.addNodeInfo(document::BucketId(16, atoi(tok3[j].data())),
+ BucketCopy(timestamp, node, api::BucketInfo(3, 3, 3, 3, 3)));
}
}
}
diff --git a/storage/src/vespa/storage/bucketdb/bucketcopy.h b/storage/src/vespa/storage/bucketdb/bucketcopy.h
index ca629a6cd8e..5518e9ebe62 100644
--- a/storage/src/vespa/storage/bucketdb/bucketcopy.h
+++ b/storage/src/vespa/storage/bucketdb/bucketcopy.h
@@ -23,8 +23,7 @@ public:
_info(info),
_flags(0),
_node(nodeIdx)
- {
- }
+ { }
bool trusted() const noexcept { return _flags & TRUSTED; }
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
index 9547bee6583..3b99fa9f035 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/setbucketstateoperation.cpp
@@ -10,6 +10,10 @@ LOG_SETUP(".distributor.operation.idealstate.setactive");
namespace storage::distributor {
+namespace {
+
+}
+
SetBucketStateOperation::SetBucketStateOperation(const ClusterContext& cluster_ctx,
const BucketAndNodes& nodes,
const std::vector<uint16_t>& wantedActiveNodes)
@@ -22,10 +26,7 @@ SetBucketStateOperation::~SetBucketStateOperation() = default;
void
SetBucketStateOperation::enqueueSetBucketStateCommand(uint16_t node, bool active) {
- auto msg = std::make_shared<api::SetBucketStateCommand>(getBucket(),
- active
- ? api::SetBucketStateCommand::ACTIVE
- : api::SetBucketStateCommand::INACTIVE);
+ auto msg = std::make_shared<api::SetBucketStateCommand>(getBucket(), api::SetBucketStateCommand::toState(active));
LOG(debug, "Enqueuing %s for %s to node %u", active ? "Activate" : "Deactivate", getBucketId().toString().c_str(), node);
setCommandMeta(*msg);
_tracker.queueCommand(std::move(msg), node);
@@ -34,8 +35,8 @@ SetBucketStateOperation::enqueueSetBucketStateCommand(uint16_t node, bool active
bool
SetBucketStateOperation::shouldBeActive(uint16_t node) const
{
- for (uint32_t i=0, n=_wantedActiveNodes.size(); i<n; ++i) {
- if (_wantedActiveNodes[i] == node) {
+ for (unsigned short _wantedActiveNode : _wantedActiveNodes) {
+ if (_wantedActiveNode == node) {
return true;
}
}
@@ -44,8 +45,8 @@ SetBucketStateOperation::shouldBeActive(uint16_t node) const
void
SetBucketStateOperation::activateNode(DistributorStripeMessageSender& sender) {
- for (uint32_t i=0; i<_wantedActiveNodes.size(); ++i) {
- enqueueSetBucketStateCommand(_wantedActiveNodes[i], true);
+ for (unsigned short _wantedActiveNode : _wantedActiveNodes) {
+ enqueueSetBucketStateCommand(_wantedActiveNode, true);
}
_tracker.flushQueue(sender);
_ok = true;
@@ -55,9 +56,9 @@ SetBucketStateOperation::activateNode(DistributorStripeMessageSender& sender) {
void
SetBucketStateOperation::deactivateNodes(DistributorStripeMessageSender& sender) {
const std::vector<uint16_t>& nodes(getNodes());
- for (size_t i = 0; i < nodes.size(); ++i) {
- if (!shouldBeActive(nodes[i])) {
- enqueueSetBucketStateCommand(nodes[i], false);
+ for (unsigned short node : nodes) {
+ if (!shouldBeActive(node)) {
+ enqueueSetBucketStateCommand(node, false);
}
}
_tracker.flushQueue(sender);
@@ -80,12 +81,10 @@ SetBucketStateOperation::onReceive(DistributorStripeMessageSender& sender,
bool deactivate = false;
if (reply->getResult().success()) {
- BucketDatabase::Entry entry =
- _bucketSpace->getBucketDatabase().get(rep.getBucketId());
+ BucketDatabase::Entry entry = _bucketSpace->getBucketDatabase().get(rep.getBucketId());
if (entry.valid()) {
const BucketCopy* copy = entry->getNode(node);
-
if (copy) {
api::BucketInfo bInfo = copy->getBucketInfo();
@@ -96,23 +95,18 @@ SetBucketStateOperation::onReceive(DistributorStripeMessageSender& sender,
bInfo.setActive(false);
}
- entry->updateNode(
- BucketCopy(_manager->operation_context().generate_unique_timestamp(),
- node,
- bInfo).setTrusted(copy->trusted()));
+ entry->updateNode(BucketCopy(_manager->operation_context().generate_unique_timestamp(), node, bInfo)
+ .setTrusted(copy->trusted()));
_bucketSpace->getBucketDatabase().update(entry);
}
} else {
LOG(debug, "%s did not exist when receiving %s",
- rep.getBucketId().toString().c_str(),
- rep.toString(true).c_str());
+ rep.getBucketId().toString().c_str(), rep.toString(true).c_str());
}
} else {
LOG(debug, "Failed setting state for %s on node %u: %s",
- rep.getBucketId().toString().c_str(),
- node,
- reply->getResult().toString().c_str());
+ rep.getBucketId().toString().c_str(), node, reply->getResult().toString().c_str());
_ok = false;
}
if (deactivate) {
diff --git a/storage/src/vespa/storageapi/message/bucket.h b/storage/src/vespa/storageapi/message/bucket.h
index e02b8fcd672..80565334331 100644
--- a/storage/src/vespa/storageapi/message/bucket.h
+++ b/storage/src/vespa/storageapi/message/bucket.h
@@ -106,7 +106,8 @@ public:
uint16_t index;
bool sourceOnly;
- Node(uint16_t index_, bool sourceOnly_ = false) noexcept
+ Node(uint16_t index_) noexcept : Node(index_, false) { }
+ Node(uint16_t index_, bool sourceOnly_) noexcept
: index(index_), sourceOnly(sourceOnly_) {}
bool operator==(const Node& n) const noexcept
@@ -471,21 +472,15 @@ public:
class SetBucketStateCommand : public MaintenanceCommand
{
public:
- enum BUCKET_STATE
- {
- INACTIVE,
- ACTIVE
- };
-private:
- BUCKET_STATE _state;
-public:
+ enum BUCKET_STATE { INACTIVE, ACTIVE };
SetBucketStateCommand(const document::Bucket &bucket, BUCKET_STATE state);
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
BUCKET_STATE getState() const { return _state; }
- DECLARE_STORAGECOMMAND(SetBucketStateCommand, onSetBucketState)
+ static BUCKET_STATE toState(bool active) noexcept { return active ? ACTIVE : INACTIVE; }
+ DECLARE_STORAGECOMMAND(SetBucketStateCommand, onSetBucketState);
private:
-
vespalib::string getSummary() const override;
+ BUCKET_STATE _state;
};
/**
diff --git a/storage/src/vespa/storageapi/messageapi/bucketcommand.cpp b/storage/src/vespa/storageapi/messageapi/bucketcommand.cpp
index c75267f560d..f202ce9da7d 100644
--- a/storage/src/vespa/storageapi/messageapi/bucketcommand.cpp
+++ b/storage/src/vespa/storageapi/messageapi/bucketcommand.cpp
@@ -7,10 +7,9 @@ using document::Bucket;
using document::BucketId;
using document::BucketSpace;
-namespace storage {
-namespace api {
+namespace storage::api {
-BucketCommand::BucketCommand(const MessageType& type, const Bucket &bucket)
+BucketCommand::BucketCommand(const MessageType& type, const Bucket &bucket) noexcept
: StorageCommand(type),
_bucket(bucket),
_originalBucket()
@@ -42,5 +41,4 @@ BucketCommand::print(std::ostream& out,
}
}
-} // api
-} // storage
+}
diff --git a/storage/src/vespa/storageapi/messageapi/bucketcommand.h b/storage/src/vespa/storageapi/messageapi/bucketcommand.h
index 605653681b5..f1d5cea377c 100644
--- a/storage/src/vespa/storageapi/messageapi/bucketcommand.h
+++ b/storage/src/vespa/storageapi/messageapi/bucketcommand.h
@@ -18,7 +18,7 @@ class BucketCommand : public StorageCommand {
document::BucketId _originalBucket;
protected:
- BucketCommand(const MessageType& type, const document::Bucket &bucket);
+ BucketCommand(const MessageType& type, const document::Bucket &bucket) noexcept;
public:
DECLARE_POINTER_TYPEDEFS(BucketCommand);
diff --git a/storage/src/vespa/storageapi/messageapi/bucketinfocommand.h b/storage/src/vespa/storageapi/messageapi/bucketinfocommand.h
index 0f6627328a9..0675e639096 100644
--- a/storage/src/vespa/storageapi/messageapi/bucketinfocommand.h
+++ b/storage/src/vespa/storageapi/messageapi/bucketinfocommand.h
@@ -18,7 +18,7 @@ namespace storage::api {
class BucketInfoCommand : public BucketCommand {
protected:
- BucketInfoCommand(const MessageType& type, const document::Bucket &bucket)
+ BucketInfoCommand(const MessageType& type, const document::Bucket &bucket) noexcept
: BucketCommand(type, bucket) {}
public:
diff --git a/storage/src/vespa/storageapi/messageapi/maintenancecommand.h b/storage/src/vespa/storageapi/messageapi/maintenancecommand.h
index 6bb36d0d32f..4b4612123a5 100644
--- a/storage/src/vespa/storageapi/messageapi/maintenancecommand.h
+++ b/storage/src/vespa/storageapi/messageapi/maintenancecommand.h
@@ -3,8 +3,7 @@
#include "bucketinfocommand.h"
-namespace storage {
-namespace api {
+namespace storage::api {
class MaintenanceCommand : public BucketInfoCommand
{
@@ -13,10 +12,10 @@ public:
: BucketInfoCommand(type, bucket)
{}
MaintenanceCommand(const MaintenanceCommand &) = default;
- MaintenanceCommand(MaintenanceCommand &&) = default;
+ MaintenanceCommand(MaintenanceCommand &&) noexcept = default;
MaintenanceCommand & operator = (const MaintenanceCommand &) = delete;
- MaintenanceCommand & operator = (MaintenanceCommand &&) = delete;
- ~MaintenanceCommand();
+ MaintenanceCommand & operator = (MaintenanceCommand &&) noexcept = delete;
+ ~MaintenanceCommand() override;
const vespalib::string& getReason() const { return _reason; };
void setReason(vespalib::stringref reason) { _reason = reason; };
@@ -25,4 +24,3 @@ protected:
};
}
-}
diff --git a/storage/src/vespa/storageapi/messageapi/storagecommand.cpp b/storage/src/vespa/storageapi/messageapi/storagecommand.cpp
index 249e08362d4..c0da654627c 100644
--- a/storage/src/vespa/storageapi/messageapi/storagecommand.cpp
+++ b/storage/src/vespa/storageapi/messageapi/storagecommand.cpp
@@ -17,7 +17,7 @@ StorageCommand::StorageCommand(const StorageCommand& other)
{
}
-StorageCommand::StorageCommand(const MessageType& type, Priority p)
+StorageCommand::StorageCommand(const MessageType& type, Priority p) noexcept
: StorageMessage(type, generateMsgId(), 0),
_timeout(MAX_TIMEOUT),
_sourceIndex(0xFFFF)
diff --git a/storage/src/vespa/storageapi/messageapi/storagecommand.h b/storage/src/vespa/storageapi/messageapi/storagecommand.h
index 06817a65b05..e5810ec638a 100644
--- a/storage/src/vespa/storageapi/messageapi/storagecommand.h
+++ b/storage/src/vespa/storageapi/messageapi/storagecommand.h
@@ -20,7 +20,8 @@ class StorageCommand : public StorageMessage {
protected:
StorageCommand(const StorageCommand& other);
- explicit StorageCommand(const MessageType& type, Priority p = NORMAL);
+ explicit StorageCommand(const MessageType& type) noexcept : StorageCommand(type, NORMAL) { }
+ explicit StorageCommand(const MessageType& type, Priority p) noexcept;
public:
DECLARE_POINTER_TYPEDEFS(StorageCommand);