// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "statbucketlistoperation.h" #include #include #include namespace storage::distributor { StatBucketListOperation::StatBucketListOperation( const BucketDatabase& bucketDb, const MaintenanceOperationGenerator& generator, uint16_t distributorIndex, const std::shared_ptr& cmd) : _bucketDb(bucketDb), _generator(generator), _distributorIndex(distributorIndex), _command(cmd) { } StatBucketListOperation::~StatBucketListOperation() = default; void StatBucketListOperation::getBucketStatus(const BucketDatabase::Entry& entry, std::ostream& ost) const { document::Bucket bucket(_command->getBucket().getBucketSpace(), entry.getBucketId()); std::vector operations(_generator.generateAll(bucket)); for (uint32_t i = 0; i < operations.size(); ++i) { const MaintenanceOperation& op(*operations[i]); if (i > 0) { ost << ", "; } ost << op.getName() << ": " << op.getDetailedReason(); } if (!operations.empty()) { ost << ' '; } ost << "[" << entry->toString() << "]"; } void StatBucketListOperation::onStart(DistributorStripeMessageSender& sender) { auto reply = std::make_shared(*_command); std::vector entries; _bucketDb.getAll(_command->getBucketId(), entries); for (const auto& entry : entries) { std::ostringstream ost; ost << "[distributor:" << _distributorIndex << "] "; getBucketStatus(entry, ost); reply->getBuckets().emplace_back(entry.getBucketId(), ost.str()); } sender.sendReply(reply); } }