Skip to content

Commit

Permalink
using removeManyAsList()
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Mar 2, 2010
1 parent 1434a50 commit 7f43c78
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ private static void start(int num_threads, int num_msgs, int segment_size) {
else {
System.out.println("removed: " + removed_msgs.get());
Util.sleep(100);
Tuple<List<Message>,Long> tuple=win.removeMany(segment_size);
if(tuple == null)
continue;
List<Message> msgs=tuple.getVal1();
if(!msgs.isEmpty())
List<Message> msgs=win.removeManyAsList(segment_size);
if(msgs != null && !msgs.isEmpty())
removed_msgs.addAndGet(msgs.size());
}
}
Expand Down Expand Up @@ -120,11 +117,8 @@ public void run() {
if(processing.compareAndSet(false, true)) {
try {
while(true) {
Tuple<List<Message>,Long> tuple=win.removeMany(20000);
if(tuple == null)
break;
List<Message> msgs=tuple.getVal1();
if(msgs.isEmpty())
List<Message> msgs=win.removeManyAsList(20000);
if(msgs == null || msgs.isEmpty())
break;
removed_msgs.addAndGet(msgs.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* @author Bela Ban
* @version $Id: AckReceiverWindowTest.java,v 1.15 2010/03/01 15:56:58 belaban Exp $
* @version $Id: AckReceiverWindowTest.java,v 1.16 2010/03/02 08:17:48 belaban Exp $
*/
@Test(groups=Global.FUNCTIONAL,sequential=true)
public class AckReceiverWindowTest {
Expand Down Expand Up @@ -160,6 +160,24 @@ public static void testRemoveMany() {
}


public static void testRemoveMany2() {
AckReceiverWindow win=new AckReceiverWindow(1);
for(int i=1; i <=50; i++)
win.add(i, msg());
System.out.println("win = " + win);
List<Message> list=win.removeManyAsList(25);

System.out.println("win = " + win);
assert list != null && list.size() == 25;
assert win.size() == 25;

list=win.removeManyAsList(30);
System.out.println("win = " + win);
assert list != null && list.size() == 25;
assert win.size() == 0;
}


public static void testSmallerThanNextToRemove() {
AckReceiverWindow win=new AckReceiverWindow(1);
Message msg;
Expand Down

0 comments on commit 7f43c78

Please sign in to comment.