Skip to content

Commit 361fd76

Browse files
authored
Print the word "INFINITE" for the cluster connect timeout instead of the max milliseconds number possible for better user experience. (#868)
1 parent 39bfb2a commit 361fd76

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

hazelcast/include/hazelcast/client/connection/wait_strategy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace hazelcast {
4848
std::chrono::milliseconds cluster_connect_timeout_millis_{0};
4949
std::chrono::steady_clock::time_point cluster_connect_attempt_begin_{
5050
std::chrono::steady_clock::now()};
51+
std::string cluster_connect_timeout_text_;
5152
};
5253
}
5354
}

hazelcast/src/hazelcast/client/network.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,14 @@ namespace hazelcast {
11391139
: initial_backoff_millis_(retry_config.get_initial_backoff_duration()),
11401140
max_backoff_millis_(retry_config.get_max_backoff_duration()),
11411141
multiplier_(retry_config.get_multiplier()), jitter_(retry_config.get_jitter()), logger_(log),
1142-
cluster_connect_timeout_millis_(retry_config.get_cluster_connect_timeout()) {}
1142+
cluster_connect_timeout_millis_(retry_config.get_cluster_connect_timeout()) {
1143+
if (cluster_connect_timeout_millis_ == std::chrono::milliseconds::max()) {
1144+
cluster_connect_timeout_text_ = "INFINITE";
1145+
} else {
1146+
cluster_connect_timeout_text_ = (boost::format("%1% msecs")
1147+
%cluster_connect_timeout_millis_.count()).str();
1148+
}
1149+
}
11431150

11441151
bool wait_strategy::sleep() {
11451152
attempt_++;
@@ -1148,9 +1155,8 @@ namespace hazelcast {
11481155
auto time_passed = duration_cast<milliseconds>(current_time - cluster_connect_attempt_begin_);
11491156
if (time_passed > cluster_connect_timeout_millis_) {
11501157
HZ_LOG(logger_, warning, (boost::format(
1151-
"Unable to get live cluster connection, cluster connect timeout (%1% millis) is reached. Attempt %2%.") %
1152-
duration_cast<milliseconds>(cluster_connect_timeout_millis_).count() %
1153-
attempt_).str());
1158+
"Unable to get live cluster connection, cluster connect timeout (%1%) is reached. Attempt %2%.")
1159+
%cluster_connect_timeout_text_ %attempt_).str());
11541160
return false;
11551161
}
11561162

@@ -1162,9 +1168,9 @@ namespace hazelcast {
11621168
actual_sleep_time = (std::min)(actual_sleep_time, cluster_connect_timeout_millis_ - time_passed);
11631169

11641170
HZ_LOG(logger_, warning, (boost::format(
1165-
"Unable to get live cluster connection, retry in %1% ms, attempt: %2% , cluster connect timeout: %3% seconds , max backoff millis: %4%") %
1171+
"Unable to get live cluster connection, retry in %1% ms, attempt: %2% , cluster connect timeout: %3% , max backoff millis: %4%") %
11661172
actual_sleep_time.count() % attempt_ %
1167-
cluster_connect_timeout_millis_.count() %
1173+
cluster_connect_timeout_text_ %
11681174
max_backoff_millis_.count()).str());
11691175

11701176
std::this_thread::sleep_for(actual_sleep_time);

0 commit comments

Comments
 (0)