qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r655533 - in /incubator/qpid/trunk/qpid/python: qpid/datatypes.py qpid/delegates.py qpid/session.py tests/datatypes.py
Date Mon, 12 May 2008 15:37:10 GMT
Author: rhs
Date: Mon May 12 08:37:10 2008
New Revision: 655533

URL: http://svn.apache.org/viewvc?rev=655533&view=rev
Log:
QPID-947: added handler for known_completed and generate known_completed when timely-reply
is set

Modified:
    incubator/qpid/trunk/qpid/python/qpid/datatypes.py
    incubator/qpid/trunk/qpid/python/qpid/delegates.py
    incubator/qpid/trunk/qpid/python/qpid/session.py
    incubator/qpid/trunk/qpid/python/tests/datatypes.py

Modified: incubator/qpid/trunk/qpid/python/qpid/datatypes.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/datatypes.py?rev=655533&r1=655532&r2=655533&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/datatypes.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/datatypes.py Mon May 12 08:37:10 2008
@@ -142,6 +142,14 @@
   def span(self, r):
     return Range(min(self.lower, r.lower), max(self.upper, r.upper))
 
+  def intersect(self, r):
+    lower = max(self.lower, r.lower)
+    upper = min(self.upper, r.upper)
+    if lower > upper:
+      return None
+    else:
+      return Range(lower, upper)
+
   def __repr__(self):
     return "%s-%s" % (self.lower, self.upper)
 

Modified: incubator/qpid/trunk/qpid/python/qpid/delegates.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/delegates.py?rev=655533&r1=655532&r2=655533&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/delegates.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/delegates.py Mon May 12 08:37:10 2008
@@ -87,8 +87,13 @@
 
   def session_completed(self, ch, cmp):
     ch.session.sender.completed(cmp.commands)
+    if cmp.timely_reply:
+      ch.session_known_completed(cmp.commands)
     notify(ch.session.condition)
 
+  def session_known_completed(self, ch, kn_cmp):
+    ch.session.receiver.known_completed(kn_cmp.commands)
+
   def session_flush(self, ch, f):
     rcv = ch.session.receiver
     if f.expected:

Modified: incubator/qpid/trunk/qpid/python/qpid/session.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/qpid/session.py?rev=655533&r1=655532&r2=655533&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/qpid/session.py (original)
+++ incubator/qpid/trunk/qpid/python/qpid/session.py Mon May 12 08:37:10 2008
@@ -289,6 +289,16 @@
     if seg.last:
       self._completed.add(seg.id)
 
+  def known_completed(self, commands):
+    completed = RangeSet()
+    for c in self._completed.ranges:
+      for kc in commands.ranges:
+        if c.lower in kc and c.upper in kc:
+          break
+      else:
+        completed.add_range(c)
+    self._completed = completed
+
 class Sender:
 
   def __init__(self, session):

Modified: incubator/qpid/trunk/qpid/python/tests/datatypes.py
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/tests/datatypes.py?rev=655533&r1=655532&r2=655533&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/tests/datatypes.py (original)
+++ incubator/qpid/trunk/qpid/python/tests/datatypes.py Mon May 12 08:37:10 2008
@@ -103,6 +103,34 @@
     assert range.lower == 0
     assert range.upper == 8
 
+class RangeTest(TestCase):
+
+  def testIntersect1(self):
+    a = Range(0, 10)
+    b = Range(9, 20)
+    i1 = a.intersect(b)
+    i2 = b.intersect(a)
+    assert i1.upper == 10
+    assert i2.upper == 10
+    assert i1.lower == 9
+    assert i2.lower == 9
+
+  def testIntersect2(self):
+    a = Range(0, 10)
+    b = Range(11, 20)
+    assert a.intersect(b) == None
+    assert b.intersect(a) == None
+
+  def testIntersect3(self):
+    a = Range(0, 10)
+    b = Range(3, 5)
+    i1 = a.intersect(b)
+    i2 = b.intersect(a)
+    assert i1.upper == 5
+    assert i2.upper == 5
+    assert i1.lower == 3
+    assert i2.lower == 3
+
 class UUIDTest(TestCase):
 
   def test(self):



Mime
View raw message