-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archival: consistent log size probes across replicas #24257
Closed
nvartolomei
wants to merge
1
commit into
redpanda-data:dev
from
nvartolomei:nv/CORE-8326-cloud-log-size-drift
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
#pragma once | ||
|
||
#include "base/seastarx.h" | ||
#include "utils/named_type.h" | ||
|
||
#include <seastar/util/noncopyable_function.hh> | ||
|
||
#include <absl/container/flat_hash_map.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace archival { | ||
|
||
/// A manager for archival stm state changes subscriptions. | ||
class stm_subscriptions { | ||
public: | ||
using id_t = named_type<int32_t, struct id_tag>; | ||
using cb_t = ss::noncopyable_function<void() noexcept>; | ||
|
||
/// Subscribe to state changes. The callback will be called every time the | ||
/// state of the STM changes. The subscription ID is returned and must be | ||
/// used to unsubscribe. It is unique for the lifetime of the STM. | ||
/// | ||
/// If you need to store subscriptions for multiple STMs in the same | ||
/// container, augment the id with additional information like to | ||
/// distinguish between different STMs. | ||
[[nodiscard("return value must be used to unsubscribe")]] id_t | ||
subscribe(cb_t f) { | ||
auto id = _next_sub_id++; | ||
_subscriptions.emplace(id, std::move(f)); | ||
return id; | ||
} | ||
|
||
/// Unsubscribe from state changes if subscription id exists. If the | ||
/// subscription id does not exist, the method is a no-op. | ||
void unsubscribe(id_t id) { _subscriptions.erase(id); } | ||
|
||
/// Notify all subscribers. | ||
void notify() { | ||
for (auto& [_, f] : _subscriptions) { | ||
f(); | ||
} | ||
} | ||
|
||
private: | ||
absl::flat_hash_map<id_t, cb_t> _subscriptions; | ||
id_t _next_sub_id{0}; | ||
}; | ||
|
||
}; // namespace archival |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you could add this requirement to parameter to
subscribe_to_state_change
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is there
subscribe_to_state_change(ss::noncopyable_function<void() noexcept> f)
unless I got your comment wrong