-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created ReliableUnicast, UNICAST4 (https://issues.redhat.com/browse…
…/JGRP-2843) - Added add(List<Tuple>...) to Buffer and implementations, plus tests - Added UNICAST4 to UnicastUnitTest - UNICAST3_Test -> UNICAST_Test (also tests UNICAST4) - Added UNICAST4 to UNICAST_ConnectionTests - Added UNICAST4 to UNICAST_ContentionTest - Added UNICAST4 to UNICAST_OOB_Test - Added UNICAST4 to UNICAST_MessagesToSelfTest - Added UNICAST4 to UNICAST_DropFirstAndLastTest - Added REVERSE2 - Simplified MessageCache (used by UNICAST-X protocols) - Fixed serialization of Average - Fixed getReceiverEntry() (https://issues.redhat.com/browse/JGRP-2852) - Added new MockTransport - Added tests to ReliableUnicastTest (https://issues.redhat.com/browse/JGRP-2852) - Changed ReliableUnicast.up(MessageBatch): conn-ids are handled after removing unicast messages from the batch into a hashmap (https://issues.redhat.com/browse/JGRP-2852)
- Loading branch information
Showing
37 changed files
with
3,025 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.jgroups.protocols; | ||
|
||
import org.jgroups.Message; | ||
import org.jgroups.annotations.MBean; | ||
import org.jgroups.stack.Protocol; | ||
import org.jgroups.util.MessageBatch; | ||
|
||
import java.util.Deque; | ||
import java.util.Iterator; | ||
import java.util.concurrent.ConcurrentLinkedDeque; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* @author Bela Ban | ||
* @since x.y | ||
*/ | ||
@MBean(description="Reverts messages based on a filter and delivers them when told") | ||
public class REVERSE2 extends Protocol { | ||
protected volatile Predicate<Message> filter; // if set and true: queue messages | ||
protected final Deque<Message> queue=new ConcurrentLinkedDeque<>(); | ||
|
||
public Predicate<Message> filter() {return filter;} | ||
public REVERSE2 filter(Predicate<Message> f) {this.filter=f; return this;} | ||
public int size() {return queue.size();} | ||
|
||
/** Delivers queued messages */ | ||
public int deliver() { | ||
Message msg; int count=0; | ||
while((msg=queue.pollLast()) != null) { | ||
up_prot.up(msg); | ||
count++; | ||
} | ||
return count; | ||
} | ||
|
||
@Override | ||
public Object up(Message msg) { | ||
if(filter != null && filter.test(msg)) { | ||
queue.add(msg); | ||
return null; | ||
} | ||
return up_prot.up(msg); | ||
} | ||
|
||
@Override | ||
public void up(MessageBatch batch) { | ||
if(filter == null) { | ||
up_prot.up(batch); | ||
return; | ||
} | ||
for(Iterator<Message> it=batch.iterator(); it.hasNext();) { | ||
Message msg=it.next(); | ||
if(filter.test(msg)) { | ||
it.remove(); | ||
queue.add(msg); | ||
} | ||
} | ||
if(!batch.isEmpty()) | ||
up_prot.up(batch); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%d msgs", queue.size()); | ||
} | ||
} |
Oops, something went wrong.