confluent_kafka/admin/alter_replica_log_dirs_result.rs
1// Copyright 2025 Confluent Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! The result of `Admin::alter_replica_log_dirs`.
16
17use std::collections::HashMap;
18
19use crate::common::KafkaFuture;
20use crate::common::TopicPartitionReplica;
21
22/// The result of the `Admin::alter_replica_log_dirs` call.
23///
24/// To retrieve the detailed result per specified [`TopicPartitionReplica`], use
25/// [`values`](Self::values). To retrieve the overall result only, use
26/// [`all`](Self::all).
27#[derive(Debug)]
28#[doc(alias = "org.apache.kafka.clients.admin.AlterReplicaLogDirsResult")]
29pub struct AlterReplicaLogDirsResult {
30 futures: HashMap<TopicPartitionReplica, KafkaFuture<()>>,
31}
32
33impl AlterReplicaLogDirsResult {
34 /// Creates a new result from the per-replica futures.
35 #[doc(alias = "org.apache.kafka.clients.admin.AlterReplicaLogDirsResult#AlterReplicaLogDirsResult")]
36 pub(crate) fn new(futures: HashMap<TopicPartitionReplica, KafkaFuture<()>>) -> Self {
37 Self { futures }
38 }
39
40 /// Returns a map from [`TopicPartitionReplica`] to [`KafkaFuture`] which holds the status of
41 /// individual replica movement. To check the result of individual replica movement, call
42 /// [`KafkaFuture::get`] from the value contained in the returned map. If there is no error,
43 /// it will return silently; if not, it returns an error like the following:
44 ///
45 /// - `Error::is_cluster_authorization_error`: Authorization failed.
46 /// (`CLUSTER_AUTHORIZATION_FAILED`, 31)
47 /// - `Error::is_invalid_topic_error`: The specified topic name is too long.
48 /// (`INVALID_TOPIC_EXCEPTION`, 17)
49 /// - `Error::is_log_dir_not_found_error`: The specified log directory is not found in the
50 /// broker. (`LOG_DIR_NOT_FOUND`, 57)
51 /// - `Error::is_replica_not_available_error`: The replica does not exist on the broker.
52 /// (`REPLICA_NOT_AVAILABLE`, 9)
53 /// - `Error::is_kafka_storage_error`: Disk error occurred. (`KAFKA_STORAGE_ERROR`, 56)
54 /// - `Error::is_unknown_server_error`: Unknown. (`UNKNOWN_SERVER_ERROR`, -1)
55 ///
56 /// # Translation notes
57 ///
58 /// [`KafkaFuture::get`] returns the cause itself: it has no cancellation, interruption or
59 /// execution wrapper.
60 #[doc(alias = "org.apache.kafka.clients.admin.AlterReplicaLogDirsResult#values")]
61 pub fn values(&self) -> &HashMap<TopicPartitionReplica, KafkaFuture<()>> {
62 &self.futures
63 }
64
65 /// Returns a future which succeeds if all the replica movements have
66 /// succeeded, otherwise yields the first error described in
67 /// [`values`](Self::values).
68 #[doc(alias = "org.apache.kafka.clients.admin.AlterReplicaLogDirsResult#all")]
69 pub fn all(&self) -> KafkaFuture<()> {
70 KafkaFuture::all_of(self.futures.values().cloned().collect())
71 }
72}