[icinga-checkins] icinga.org: icinga2/master: cluster: Remove old logs before reconnecting.

git at icinga.org git at icinga.org
Mon Sep 16 14:01:48 CEST 2013


Module: icinga2
Branch: master
Commit: 2739d5e0cde2c2d48e798a53b1ddd86afbdc6bad
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2739d5e0cde2c2d48e798a53b1ddd86afbdc6bad

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Sep 16 14:01:24 2013 +0200

cluster: Remove old logs before reconnecting.

---

 components/cluster/clustercomponent.cpp |   56 +++++++++++++++----------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp
index 642be1b..d6e6100 100644
--- a/components/cluster/clustercomponent.cpp
+++ b/components/cluster/clustercomponent.cpp
@@ -517,6 +517,34 @@ void ClusterComponent::ClusterTimerHandler(void)
 		}
 	}
 
+	std::vector<int> files;
+	Utility::Glob(GetClusterDir() + "log/*", boost::bind(&ClusterComponent::LogGlobHandler, boost::ref(files), _1));
+	std::sort(files.begin(), files.end());
+
+	BOOST_FOREACH(int ts, files) {
+		bool need = false;
+
+		BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
+			if (endpoint->GetName() == GetIdentity())
+				continue;
+
+			double position = endpoint->GetLocalLogPosition();
+
+			if (position != 0 && ts > position) {
+				need = true;
+				break;
+			}
+		}
+
+		if (!need) {
+			String path = GetClusterDir() + "log/" + Convert::ToString(ts);
+			Log(LogInformation, "cluster", "Removing old log file: " + path);
+			(void) unlink(path.CStr());
+		}
+	}
+
+	UpdateAuthority();
+
 	Array::Ptr peers = GetPeers();
 
 	if (peers) {
@@ -554,34 +582,6 @@ void ClusterComponent::ClusterTimerHandler(void)
 			}
 		}
 	}
-
-	std::vector<int> files;
-	Utility::Glob(GetClusterDir() + "log/*", boost::bind(&ClusterComponent::LogGlobHandler, boost::ref(files), _1));
-	std::sort(files.begin(), files.end());
-
-	BOOST_FOREACH(int ts, files) {
-		bool need = false;
-
-		BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
-			if (endpoint->GetName() == GetIdentity())
-				continue;
-
-			double position = endpoint->GetLocalLogPosition();
-
-			if (position != 0 && ts > position) {
-				need = true;
-				break;
-			}
-		}
-
-		if (!need) {
-			String path = GetClusterDir() + "log/" + Convert::ToString(ts);
-			Log(LogInformation, "cluster", "Removing old log file: " + path);
-			(void) unlink(path.CStr());
-		}
-	}
-
-	UpdateAuthority();
 }
 
 void ClusterComponent::CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority)





More information about the icinga-checkins mailing list