return false;
}
- Log(LogInformation, "ApiListener")
- << "Applying configuration file update for path '" << configDir << "'. Received timestamp '"
- << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", newTimestamp) << "' ("
- << std::fixed << std::setprecision(6) << newTimestamp
- << ") is more recent than current timestamp '"
- << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", oldTimestamp) << "' ("
- << oldTimestamp << ").";
+ size_t numBytes = 0;
{
ObjectLock olock(newConfig);
Log(LogInformation, "ApiListener")
<< "Updating configuration file: " << path;
- //pass the directory and generate a dir tree, if not existing already
+ /* Sync string content only. */
+ String content = kv.second;
+
+ /* Generate a directory tree (zones/1/2/3 might not exist yet). */
Utility::MkDirP(Utility::DirName(path), 0755);
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
- fp << kv.second;
+ fp << content;
fp.close();
+
+ numBytes += content.GetLength();
}
}
}
+ Log(LogInformation, "ApiListener")
+ << "Applying configuration file update for path '" << configDir << "' (" << numBytes << " Bytes). Received timestamp '"
+ << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", newTimestamp) << "' ("
+ << std::fixed << std::setprecision(6) << newTimestamp
+ << "), Current timestamp '"
+ << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", oldTimestamp) << "' ("
+ << oldTimestamp << ").";
+
ObjectLock xlock(oldConfig);
for (const Dictionary::Pair& kv : oldConfig) {
if (!newConfig->Contains(kv.first)) {
String port = endpoint->GetPort();
Log(LogInformation, "ApiListener")
- << "Reconnecting to API endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
+ << "Reconnecting to endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
TcpSocket::Ptr client = new TcpSocket();
Log(LogDebug, "ApiListener")
<< info.str() << "\n" << DiagnosticInformation(ex);
}
+
+ Log(LogInformation, "ApiListener")
+ << "Finished reconnecting to endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'";
}
void ApiListener::NewClientHandler(const Socket::Ptr& client, const String& hostname, ConnectionRole role)
NewClientHandlerInternal(client, hostname, role);
} catch (const std::exception& ex) {
Log(LogCritical, "ApiListener")
+ << "Exception while handling new API client connection: " << DiagnosticInformation(ex, false);
+
+ Log(LogDebug, "ApiListener")
<< "Exception while handling new API client connection: " << DiagnosticInformation(ex);
}
}
void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint, bool needSync)
{
+ Zone::Ptr eZone = endpoint->GetZone();
+
try {
{
ObjectLock olock(endpoint);
*/
Log(LogInformation, "ApiListener")
- << "Sending config updates for endpoint '" << endpoint->GetName() << "'.";
+ << "Sending config updates for endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
/* sync zone file config */
SendConfigUpdate(aclient);
+
+ Log(LogInformation, "ApiListener")
+ << "Finished sending config file updates for endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
+
/* sync runtime config */
SendRuntimeConfigObjects(aclient);
Log(LogInformation, "ApiListener")
- << "Finished sending config updates for endpoint '" << endpoint->GetName() << "'.";
+ << "Finished sending runtime config updates for endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
if (!needSync) {
ObjectLock olock2(endpoint);
}
Log(LogInformation, "ApiListener")
- << "Sending replay log for endpoint '" << endpoint->GetName() << "'.";
+ << "Sending replay log for endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
ReplayLog(aclient);
- if (endpoint->GetZone() == Zone::GetLocalZone())
+ if (eZone == Zone::GetLocalZone())
UpdateObjectAuthority();
Log(LogInformation, "ApiListener")
- << "Finished sending replay log for endpoint '" << endpoint->GetName() << "'.";
+ << "Finished sending replay log for endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
} catch (const std::exception& ex) {
- ObjectLock olock2(endpoint);
- endpoint->SetSyncing(false);
+ {
+ ObjectLock olock2(endpoint);
+ endpoint->SetSyncing(false);
+ }
Log(LogCritical, "ApiListener")
+ << "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false);
+
+ Log(LogDebug, "ApiListener")
<< "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
}
+
+ Log(LogInformation, "ApiListener")
+ << "Finished syncing endpoint '" << endpoint->GetName() << "' in zone '" << eZone->GetName() << "'.";
}
void ApiListener::ApiTimerHandler(void)
count++;
} catch (const std::exception& ex) {
Log(LogWarning, "ApiListener")
+ << "Error while replaying log for endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false);
+
+ Log(LogDebug, "ApiListener")
<< "Error while replaying log for endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
+
break;
}