This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 2161ef7 [mini-cluster] improved WaitForTabletsRunning
2161ef7 is described below
commit 2161ef77de6626488630da7a99633aeec6b68595
Author: Alexey Serbin <[email protected]>
AuthorDate: Fri Nov 20 21:07:11 2020 -0800
[mini-cluster] improved WaitForTabletsRunning
This patch adds an extra output parameter for the
ExternalMiniCluster::WaitForTabletsRunning() method to retrieve
information on currently running tablets. This helps in test scenarios
where it's necessary to get the set of identifiers for running tablets
in the very beginning, avoiding an extra call to itest::ListTablets()
and building the TServerDetail map.
The newly added functionality is to be used in follow-up changelists.
Change-Id: I076064233c10f76b9c5c795d7943b10ef430ee90
Reviewed-on: http://gerrit.cloudera.org:8080/16764
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <[email protected]>
---
src/kudu/mini-cluster/external_mini_cluster.cc | 19 ++++++++++++++++---
src/kudu/mini-cluster/external_mini_cluster.h | 13 +++++++++++--
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/kudu/mini-cluster/external_mini_cluster.cc
b/src/kudu/mini-cluster/external_mini_cluster.cc
index 4c81ef7..d6bc748 100644
--- a/src/kudu/mini-cluster/external_mini_cluster.cc
+++ b/src/kudu/mini-cluster/external_mini_cluster.cc
@@ -720,9 +720,11 @@ void ExternalMiniCluster::AssertNoCrashes() {
ASSERT_EQ(0, num_crashes) << "At least one process crashed";
}
-Status ExternalMiniCluster::WaitForTabletsRunning(ExternalTabletServer* ts,
- int min_tablet_count,
- const MonoDelta& timeout) {
+Status ExternalMiniCluster::WaitForTabletsRunning(
+ ExternalTabletServer* ts,
+ int min_tablet_count,
+ const MonoDelta& timeout,
+ vector<TabletIdAndTableName>* tablets_info) {
TabletServerServiceProxy proxy(messenger_, ts->bound_rpc_addr(),
ts->bound_rpc_addr().host());
ListTabletsRequestPB req;
ListTabletsResponsePB resp;
@@ -747,6 +749,17 @@ Status
ExternalMiniCluster::WaitForTabletsRunning(ExternalTabletServer* ts,
// 1. All the tablets are running, and
// 2. We've observed as many tablets as we had expected or more.
if (all_running && resp.status_and_schema_size() >= min_tablet_count) {
+ if (tablets_info) {
+ tablets_info->clear();
+ const auto num_elems = resp.status_and_schema_size();
+ tablets_info->reserve(num_elems);
+ for (auto i = 0; i < num_elems; ++i) {
+ const auto& elem = resp.status_and_schema(i);
+ tablets_info->emplace_back(
+ TabletIdAndTableName{elem.tablet_status().tablet_id(),
+ elem.tablet_status().table_name()});
+ }
+ }
return Status::OK();
}
diff --git a/src/kudu/mini-cluster/external_mini_cluster.h
b/src/kudu/mini-cluster/external_mini_cluster.h
index 6d16f3c..1553f2f 100644
--- a/src/kudu/mini-cluster/external_mini_cluster.h
+++ b/src/kudu/mini-cluster/external_mini_cluster.h
@@ -93,6 +93,12 @@ class ExternalTabletServer;
// Location --> number of tablet servers in location.
typedef std::map<std::string, int> LocationInfo;
+
+struct TabletIdAndTableName {
+ const std::string tablet_id;
+ const std::string table_name;
+};
+
#if !defined(NO_CHRONY)
// The enumeration below describes the way Kudu's built-in NTP client is
// configured given the set of dedicated NTP servers run by the mini-cluster.
@@ -405,8 +411,11 @@ class ExternalMiniCluster : public MiniCluster {
// If 'min_tablet_count' is not -1, will also wait for at least that many
// RUNNING tablets to appear before returning (potentially timing out if that
// number is never reached).
- Status WaitForTabletsRunning(ExternalTabletServer* ts, int min_tablet_count,
- const MonoDelta& timeout);
+ Status WaitForTabletsRunning(
+ ExternalTabletServer* ts,
+ int min_tablet_count,
+ const MonoDelta& timeout,
+ std::vector<TabletIdAndTableName>* tablets_info = nullptr);
// Create a client configured to talk to this cluster.
// Builder may contain override options for the client. The master address
will