Skip to content

Commit

Permalink
Merge "DiscoveryClient stops resusbcribing even after ttl period." in…
Browse files Browse the repository at this point in the history
…to R3.0
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 3, 2016
2 parents c63ffb4 + 167ee74 commit 1c37c05
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/discovery/client/discovery_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ void DiscoveryServiceClient::PublishResponseHandler(std::string &xmls,

// Errorcode is of type CURLcode
if (ec.value() != 0) {
DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg,
"Error PublishResponseHandler ",
serviceName + " " + curl_error_category.message(ec.value()),
ec.value());
// exponential back-off and retry
resp->pub_fail_++;
resp->attempts_++;
Expand All @@ -336,6 +332,11 @@ void DiscoveryServiceClient::PublishResponseHandler(std::string &xmls,
resp->pub_timeout_++;
// reset attempts so publish can be sent right away
resp->attempts_ = 0;
} else {
DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg,
"Error PublishResponseHandler ",
serviceName + " " + curl_error_category.message(ec.value()),
ec.value());
}

// Update connection info
Expand Down Expand Up @@ -556,6 +557,7 @@ void DiscoveryServiceClient::ReEvaluatePublish(std::string serviceName,

/* Send publish unconditionally */
resp->pub_sent_++;
resp->publish_cb_called_ = false;
SendHttpPostMessage(resp->publish_hdr_, serviceName,
resp->publish_msg_);
}
Expand Down Expand Up @@ -630,6 +632,7 @@ void DiscoveryServiceClient::Publish(std::string serviceName) {

DSPublishResponse *resp = loc->second;
resp->pub_sent_++;
resp->publish_cb_called_ = false;
SendHttpPostMessage(resp->publish_hdr_, serviceName, resp->publish_msg_);
}
}
Expand Down Expand Up @@ -798,6 +801,7 @@ void DiscoveryServiceClient::Subscribe(std::string serviceName) {

DSSubscribeResponse *resp = loc->second;
resp->subscribe_timer_->Cancel();
resp->subscribe_cb_called_ = false;
resp->sub_sent_++;

if (resp->inuse_service_list_.size()) {
Expand Down Expand Up @@ -831,6 +835,8 @@ void DiscoveryServiceClient::Subscribe(std::string serviceName) {
if (resp->subscribe_chksum_ != gen_chksum) {
DISCOVERY_CLIENT_TRACE(DiscoveryClientMsg, "subscribe",
serviceName, ss.str());
DISCOVERY_CLIENT_LOG_NOTICE(DiscoveryClientLogMsg, "subscribe",
serviceName, ss.str());
resp->subscribe_chksum_ = gen_chksum;
}
} else {
Expand Down Expand Up @@ -907,6 +913,8 @@ void DiscoveryServiceClient::SubscribeResponseHandler(std::string &xmls,
DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg,
"SubscribeResponseHandler, Only header received",
serviceName, ec.value());
DISCOVERY_CLIENT_LOG_ERROR(DiscoveryClientErrorLog, serviceName,
"SubscribeResponseHandler, Only header received");
// exponential back-off and retry
hdr->attempts_++;
hdr->sub_fail_++;
Expand Down Expand Up @@ -1102,11 +1110,6 @@ void DiscoveryServiceClient::HeartBeatResponseHandler(std::string &xmls,

// Errorcode is of type CURLcode
if (ec.value() != 0) {
DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg,
"Error HeartBeatResponseHandler ",
serviceName + " " + curl_error_category.message(ec.value()),
ec.value());

resp->pub_hb_fail_++;
// Resend original publish request after exponential back-off
resp->attempts_++;
Expand All @@ -1123,6 +1126,11 @@ void DiscoveryServiceClient::HeartBeatResponseHandler(std::string &xmls,
// reset attempts so publish can be sent right away
resp->attempts_ = 0;
}
} else {
DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg,
"Error HeartBeatResponseHandler ",
serviceName + " " + curl_error_category.message(ec.value()),
ec.value());
}

// Update connection info
Expand Down

0 comments on commit 1c37c05

Please sign in to comment.