{
ObjectLock olock(this);
+ RotateLogFile();
OpenLogFile();
}
{
ObjectLock olock(this);
CloseLogFile();
+ RotateLogFile();
}
String ClusterComponent::GetCertificateFile(void) const
if (m_LogMessageCount > 250000) {
CloseLogFile();
+ RotateLogFile();
OpenLogFile();
}
}
m_LogFile->Close();
m_LogFile.reset();
- if (m_LogMessageTimestamp != 0) {
- String oldpath = GetClusterDir() + "current";
- String newpath = GetClusterDir() + Convert::ToString(static_cast<int>(m_LogMessageTimestamp) + 1);
- (void) rename(oldpath.CStr(), newpath.CStr());
- }
+}
+
+void ClusterComponent::RotateLogFile(void)
+{
+ ASSERT(OwnsLock());
+
+ double ts = m_LogMessageTimestamp;
+
+ if (ts == 0)
+ ts = Utility::GetTime();
+
+ String oldpath = GetClusterDir() + "current";
+ String newpath = GetClusterDir() + Convert::ToString(static_cast<int>(ts) + 1);
+ (void) rename(oldpath.CStr(), newpath.CStr());
}
void ClusterComponent::LogGlobHandler(std::vector<int>& files, const String& file)
ASSERT(OwnsLock());
CloseLogFile();
+ RotateLogFile();
std::vector<int> files;
Utility::Glob(GetClusterDir() + "*", boost::bind(&ClusterComponent::LogGlobHandler, boost::ref(files), _1));
bag->Set("bind_port", m_BindPort);
bag->Set("peers", m_Peers);
}
+
+ if (attributeTypes & Attribute_State)
+ bag->Set("log_message_timestamp", m_LogMessageTimestamp);
}
void ClusterComponent::InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes)
m_BindPort = bag->Get("bind_port");
m_Peers = bag->Get("peers");
}
+
+ if (attributeTypes & Attribute_State)
+ m_LogMessageTimestamp = bag->Get("log_message_timestamp");
}
void RelayMessage(const Endpoint::Ptr& except, const Dictionary::Ptr& message, bool persistent);
void OpenLogFile(void);
+ void RotateLogFile(void);
void CloseLogFile(void);
static void LogGlobHandler(std::vector<int>& files, const String& file);
void ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Ptr& stream);