Fix: Cluster log files were not properly removed when an instance has no peers.

This commit is contained in:
Gunnar Beutner 2013-09-16 11:08:13 +02:00
parent 5495b0279e
commit e391fc0858
1 changed files with 28 additions and 29 deletions

View File

@ -519,40 +519,39 @@ void ClusterComponent::ClusterTimerHandler(void)
Array::Ptr peers = GetPeers(); Array::Ptr peers = GetPeers();
if (!peers) if (peers) {
return; ObjectLock olock(peers);
BOOST_FOREACH(const String& peer, peers) {
Endpoint::Ptr endpoint = Endpoint::GetByName(peer);
ObjectLock olock(peers); if (!endpoint) {
BOOST_FOREACH(const String& peer, peers) { Log(LogWarning, "cluster", "Attempted to reconnect to endpoint '" + peer + "': No configuration found.");
Endpoint::Ptr endpoint = Endpoint::GetByName(peer); continue;
}
if (!endpoint) { if (endpoint->IsConnected())
Log(LogWarning, "cluster", "Attempted to reconnect to endpoint '" + peer + "': No configuration found."); continue;
continue;
}
if (endpoint->IsConnected()) String host, port;
continue; host = endpoint->GetHost();
port = endpoint->GetPort();
String host, port; if (host.IsEmpty() || port.IsEmpty()) {
host = endpoint->GetHost(); Log(LogWarning, "cluster", "Can't reconnect "
port = endpoint->GetPort(); "to endpoint '" + endpoint->GetName() + "': No "
"host/port information.");
continue;
}
if (host.IsEmpty() || port.IsEmpty()) { try {
Log(LogWarning, "cluster", "Can't reconnect " Log(LogInformation, "cluster", "Attempting to reconnect to cluster endpoint '" + endpoint->GetName() + "' via '" + host + ":" + port + "'.");
"to endpoint '" + endpoint->GetName() + "': No " AddConnection(host, port);
"host/port information."); } catch (std::exception& ex) {
continue; std::ostringstream msgbuf;
} msgbuf << "Exception occured while reconnecting to endpoint '"
<< endpoint->GetName() << "': " << boost::diagnostic_information(ex);
try { Log(LogWarning, "cluster", msgbuf.str());
Log(LogInformation, "cluster", "Attempting to reconnect to cluster endpoint '" + endpoint->GetName() + "' via '" + host + ":" + port + "'."); }
AddConnection(host, port);
} catch (std::exception& ex) {
std::ostringstream msgbuf;
msgbuf << "Exception occured while reconnecting to endpoint '"
<< endpoint->GetName() << "': " << boost::diagnostic_information(ex);
Log(LogWarning, "cluster", msgbuf.str());
} }
} }