qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r711623 - in /incubator/qpid/trunk/qpid/cpp/src: qpid/cluster/Cluster.cpp qpid/cluster/Connection.cpp qpid/cluster/Connection.h tests/cluster_test.cpp tests/run_test tests/vg_check
Date Wed, 05 Nov 2008 17:09:34 GMT
Author: aconway
Date: Wed Nov  5 09:09:33 2008
New Revision: 711623

URL: http://svn.apache.org/viewvc?rev=711623&view=rev
Log:

Cluster: clean up connections when a member leaves the cluster.

Fixed a memory error in cluster_test and some reporting errors in test scripts.

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h
    incubator/qpid/trunk/qpid/cpp/src/tests/cluster_test.cpp
    incubator/qpid/trunk/qpid/cpp/src/tests/run_test
    incubator/qpid/trunk/qpid/cpp/src/tests/vg_check

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Cluster.cpp Wed Nov  5 09:09:33 2008
@@ -565,6 +565,17 @@
         }
         mgmtObject->set_members(urlstr);
     }
+
+    //close connections belonging to members that have now been excluded
+    for (ConnectionMap::iterator i = connections.begin(); i != connections.end();) {
+        MemberId member = i->first.getMember();
+        if (member != myId && !map.isMember(member)) { 
+            i->second->left();
+            connections.erase(i++);
+        } else {
+            i++;
+        }
+    }
 }
 
 std::ostream& operator<<(std::ostream& o, const Cluster& cluster) {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp Wed Nov  5 09:09:33 2008
@@ -141,6 +141,7 @@
     }
 }
 
+// A local connection is closed by the network layer.
 void Connection::closed() {
     try {
         if (catchUp) {
@@ -165,12 +166,19 @@
     }
 }
 
+// Self-delivery of close message, close the connection.
 void Connection::deliverClose () {
     assert(!catchUp);
     connection.closed();
     cluster.erase(self);
 }
 
+// Member of a shadow connection left the cluster.
+void Connection::left() {
+    assert(isShadow());
+    connection.closed();
+}
+
 // Decode data from local clients.
 size_t Connection::decode(const char* buffer, size_t size) {
     if (catchUp) {  // Handle catch-up locally.

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h Wed Nov  5 09:09:33 2008
@@ -89,6 +89,9 @@
     void idleOut() { connection.idleOut(); }
     void idleIn() { connection.idleIn(); }
 
+    /** Called if the connectors member has left the cluster */
+    void left();
+    
     // ConnectionCodec methods
     size_t decode(const char* buffer, size_t size);
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/cluster_test.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/cluster_test.cpp?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/cluster_test.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/cluster_test.cpp Wed Nov  5 09:09:33 2008
@@ -117,12 +117,13 @@
 void ClusterFixture::add() {
     if (size() != size_t(localIndex))  { // fork a broker process.
         std::ostringstream os; os << "fork" << size();
+        std::string prefix = os.str();
         const char* argv[] = {
             "qpidd " __FILE__ ,
             "--load-module=../.libs/cluster.so",
             "--cluster-name", name.c_str(), 
             "--auth=no", "--no-data-dir",
-            "--log-prefix", os.str().c_str(),
+            "--log-prefix", prefix.c_str(),
         };
         size_t argc = sizeof(argv)/sizeof(argv[0]);
         forkedBrokers.push_back(shared_ptr<ForkedBroker>(new ForkedBroker(argc, argv)));

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/run_test
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/run_test?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/run_test (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/run_test Wed Nov  5 09:09:33 2008
@@ -49,7 +49,7 @@
     test -n "$VALGRIND" && VALGRIND="$VALGRIND $VALGRIND_OPTS"
     # Hide output unless there's an error.
     libtool --mode=execute $VALGRIND "$@" 2>&1 || ERROR=1
-    test -n "$VALGRIND" && { vg_check $VG_LOG* || ERROR=1 ; }
+    test -n "$VALGRIND" && { vg_check $VG_LOG || ERROR=1 ; }
 else
     # This is a non-libtool shell script, just execute it.
     exec "$@"

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/vg_check
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/vg_check?rev=711623&r1=711622&r2=711623&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/vg_check (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/vg_check Wed Nov  5 09:09:33 2008
@@ -1,6 +1,7 @@
 # Check for valgrind errors. Sourced by test scripts.
 
 vg_failed() {
+    echo "Valgrind error log in $VG_LOG." 1>&2
     cat $VG_LOG 1>&2
     echo $1 1>&2
     exit 1
@@ -12,10 +13,10 @@
     test -f $VG_LOG || vg_failed Valgrind log file $VG_LOG missing.
     # Ensure there is an ERROR SUMMARY line.
     grep -E '^==[0-9]+== ERROR SUMMARY:' $VG_LOG > /dev/null || \
-	vg_failed "No valgrind ERROR SUMMARY line in $$vg_failed."
+	vg_failed "No valgrind ERROR SUMMARY line in $VG_LOG."
     # Ensure that the number of errors is 0.
     grep -E '^==[0-9]+== ERROR SUMMARY: [^0]' $VG_LOG > /dev/null && \
-	vg_failed "Valgrind reported errors in $vg_out; see above." 
+	vg_failed "Valgrind reported errors in $VG_LOG; see above." 
     # Check for leaks.
     grep -E '^==[0-9]+== +.* lost: [^0]' $VG_LOG && \
 	vg_failed "Found memory leaks (see log file, $VG_LOG); see above."



Mime
View raw message