incubator-mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1131600 - in /incubator/mesos/trunk/src: ft_messaging.cpp ft_messaging.hpp
Date Sun, 05 Jun 2011 03:28:08 GMT
Author: benh
Date: Sun Jun  5 03:28:08 2011
New Revision: 1131600

URL: http://svn.apache.org/viewvc?rev=1131600&view=rev
Log:
resend of outstanding messages done in the right order to avoid unnecessary resends

Modified:
    incubator/mesos/trunk/src/ft_messaging.cpp
    incubator/mesos/trunk/src/ft_messaging.hpp

Modified: incubator/mesos/trunk/src/ft_messaging.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/ft_messaging.cpp?rev=1131600&r1=1131599&r2=1131600&view=diff
==============================================================================
--- incubator/mesos/trunk/src/ft_messaging.cpp (original)
+++ incubator/mesos/trunk/src/ft_messaging.cpp Sun Jun  5 03:28:08 2011
@@ -85,6 +85,7 @@ void FTMessaging::sendOutstanding() {
       outMsgs.erase(ftId);
     }
   }
+
 }
 
 // Careful: not idempotent function.
@@ -118,13 +119,15 @@ bool FTMessaging::acceptMessage(string f
 }
 
 bool FTMessaging::acceptMessageAck(string from, string ftId) {
+  DLOG(INFO) << "FT: Received message with id: " << ftId << " sending FT_RELAY_ACK";
+
   bool res = acceptMessage(from, ftId);
 
-  if (!res)
-    LOG(WARNING) << "FT: asked called to ignore duplicate message " << ftId;
-  
-  DLOG(INFO) << "FT: Received message with id: " << ftId << " sending FT_RELAY_ACK";
-  
+  if (!res) {
+    LOG(WARNING) << "FT: asked caller to ignore duplicate message " << ftId;
+    return res;
+  }  
+
   string msgStr = Tuple<EmptyClass>::tupleToString( Tuple<EmptyClass>::pack<FT_RELAY_ACK>(ftId,
from) );
   Process::post(master, FT_RELAY_ACK, msgStr.data(), msgStr.size()); 
 

Modified: incubator/mesos/trunk/src/ft_messaging.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/ft_messaging.hpp?rev=1131600&r1=1131599&r2=1131600&view=diff
==============================================================================
--- incubator/mesos/trunk/src/ft_messaging.hpp (original)
+++ incubator/mesos/trunk/src/ft_messaging.hpp Sun Jun  5 03:28:08 2011
@@ -48,6 +48,7 @@
 #include "messages.hpp"
 #include "tuple.hpp"
 #include "foreach.hpp"
+#include <ctime>
 
 
 namespace nexus { namespace internal {
@@ -69,17 +70,19 @@ class EmptyClass {
 struct FTStoredMsg {
 
   FTStoredMsg(const string &_ftId, const string &_data, const MSGID &_id) : 
-    ftId(_ftId), data(_data), id(_id), count(0) {}
+    ftId(_ftId), data(_data), id(_id), count(1), ts(time(0)) {}
 
-  FTStoredMsg() : ftId(""), data(""), id(), count(0) {}
+  FTStoredMsg() : ftId(""), data(""), id(), count(1), ts(time(0)) {}
 
   string ftId;
   string data;
   MSGID id;
   long count;
+  time_t ts;   // not currently used
 };
 
 
+
 /**
  * Singleton class that provides functionality for reliably sending messages, 
  * resending them on timeout, acking received messages, and dropping duplicates.
@@ -166,8 +169,14 @@ public:
 private:
 
   PID master;
+  
+  class cmpstrs { public: 
+      bool operator()(const string &s1, const string &s2) const { return s1.compare(s2)
== -1 ? true : false; } 
+  };
+
+  typedef map<string, FTStoredMsg, cmpstrs> OutMsgsMap;
 
-  unordered_map<string, FTStoredMsg> outMsgs;
+  OutMsgsMap outMsgs;
 
   unordered_map<string, string> inMsgs;
 



Mime
View raw message