|
10 | 10 |
|
11 | 11 | #include "cloud_topics/app.h"
|
12 | 12 |
|
| 13 | +#include "cloud_topics/cluster_services.h" |
| 14 | +#include "cloud_topics/data_plane_impl.h" |
| 15 | +#include "cluster/cluster_epoch_service.h" |
| 16 | +#include "cluster/controller.h" |
| 17 | +#include "ssx/sharded_service_container.h" |
| 18 | + |
13 | 19 | #include <seastar/core/coroutine.hh>
|
14 | 20 |
|
15 | 21 | namespace experimental::cloud_topics {
|
16 | 22 |
|
17 |
| -app::app( |
18 |
| - ss::shared_ptr<data_plane_api> dp, |
19 |
| - std::unique_ptr<l1::domain_supervisor> l1_cp) |
20 |
| - : _data_plane(std::move(dp)) |
21 |
| - , _domain_supervisor(std::move(l1_cp)) {} |
| 23 | +namespace { |
| 24 | +class real_cluster_services |
| 25 | + : public experimental::cloud_topics::cluster_services { |
| 26 | +public: |
| 27 | + explicit real_cluster_services( |
| 28 | + ss::sharded<cluster::cluster_epoch_service<>>* epoch_generator) |
| 29 | + : _epoch_service(epoch_generator) {} |
| 30 | + |
| 31 | + seastar::future<experimental::cloud_topics::cluster_epoch> |
| 32 | + current_epoch(seastar::abort_source* as) override { |
| 33 | + std::expected<int64_t, std::error_code> epoch |
| 34 | + = co_await _epoch_service->local().get_cached_epoch(as); |
| 35 | + if (!epoch) { |
| 36 | + throw std::system_error(epoch.error()); |
| 37 | + } |
| 38 | + co_return experimental::cloud_topics::cluster_epoch(epoch.value()); |
| 39 | + } |
| 40 | + |
| 41 | +private: |
| 42 | + ss::sharded<cluster::cluster_epoch_service<>>* _epoch_service; |
| 43 | +}; |
| 44 | +} // namespace |
22 | 45 |
|
23 |
| -seastar::future<> app::start() { |
24 |
| - co_await _domain_supervisor->start(); |
25 |
| - co_await _data_plane->start(); |
| 46 | +app::app() |
| 47 | + : ssx::sharded_service_container("cloud_topics::app") {} |
| 48 | + |
| 49 | +ss::future<> app::construct( |
| 50 | + model::node_id self, |
| 51 | + cluster::controller* controller, |
| 52 | + ss::sharded<cluster::partition_manager>* partition_mgr, |
| 53 | + ss::sharded<cluster::partition_leaders_table>* leaders_table, |
| 54 | + ss::sharded<cluster::shard_table>* shard_table, |
| 55 | + ss::sharded<cloud_io::remote>* remote, |
| 56 | + ss::sharded<cloud_storage::cache>* cloud_cache, |
| 57 | + ss::sharded<cluster::metadata_cache>* metadata_cache, |
| 58 | + ss::sharded<rpc::connection_cache>* connection_cache, |
| 59 | + cloud_storage_clients::bucket_name bucket, |
| 60 | + ss::sharded<storage::api>* storage) { |
| 61 | + co_await construct_service( |
| 62 | + state, |
| 63 | + ss::sharded_parameter([remote, cloud_cache, bucket, storage, controller] { |
| 64 | + return experimental::cloud_topics::make_data_plane( |
| 65 | + remote, |
| 66 | + cloud_cache, |
| 67 | + bucket, |
| 68 | + storage, |
| 69 | + std::make_unique<real_cluster_services>( |
| 70 | + &controller->get_cluster_epoch_generator())); |
| 71 | + })); |
| 72 | + co_await construct_service(domain_supervisor, controller); |
| 73 | + co_await construct_service( |
| 74 | + l1_metastore_fe, |
| 75 | + self, |
| 76 | + metadata_cache, |
| 77 | + leaders_table, |
| 78 | + shard_table, |
| 79 | + connection_cache, |
| 80 | + &domain_supervisor); |
26 | 81 | }
|
27 | 82 |
|
28 |
| -seastar::future<> app::stop() { |
29 |
| - co_await _domain_supervisor->stop(); |
30 |
| - co_await _data_plane->stop(); |
| 83 | +ss::future<> app::start() { |
| 84 | + co_await state.invoke_on_all([](auto& s) { return s.start(); }); |
| 85 | + co_await domain_supervisor.invoke_on_all( |
| 86 | + [](auto& ds) { return ds.start(); }); |
31 | 87 | }
|
32 | 88 |
|
33 |
| -ss::shared_ptr<data_plane_api> app::get_data_plane_api() { return _data_plane; } |
| 89 | +ss::future<> app::stop() { |
| 90 | + ssx::sharded_service_container::shutdown(); |
| 91 | + co_return; |
| 92 | +} |
34 | 93 |
|
35 |
| -l1::domain_supervisor* app::get_l1_domain_supervisor() { |
36 |
| - return _domain_supervisor.get(); |
| 94 | +ss::sharded<l1::frontend>* app::get_sharded_l1_metastore_fe() { |
| 95 | + return &l1_metastore_fe; |
37 | 96 | }
|
38 | 97 |
|
| 98 | +ss::sharded<state_accessors>* app::get_state() { return &state; } |
| 99 | + |
39 | 100 | } // namespace experimental::cloud_topics
|
0 commit comments