Skip to content

Commit

Permalink
- Created ReliableUnicast, UNICAST4 (https://issues.redhat.com/browse…
Browse files Browse the repository at this point in the history
…/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
belaban committed Nov 13, 2024
1 parent f1d5c4f commit afe3281
Show file tree
Hide file tree
Showing 37 changed files with 3,025 additions and 463 deletions.
1 change: 1 addition & 0 deletions conf/jg-magic-map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<class id="97" name="org.jgroups.protocols.RTTHeader"/>
<class id="98" name="org.jgroups.protocols.ProtPerfHeader"/>
<class id="99" name="org.jgroups.protocols.NakAckHeader"/>
<class id="100" name="org.jgroups.protocols.UnicastHeader"/>

</magic-number-class-mapping>

1 change: 1 addition & 0 deletions conf/jg-protocol-ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<class id="75" name="org.jgroups.protocols.JDBC_PING2"/>
<class id="76" name="org.jgroups.protocols.NAKACK3"/>
<class id="77" name="org.jgroups.protocols.NAKACK4"/>
<class id="78" name="org.jgroups.protocols.UNICAST4"/>

<!-- IDs reserved for building blocks -->
<class id="200" name="org.jgroups.blocks.RequestCorrelator"/> <!-- ID should be the same as Global.BLOCKS_START_ID -->
Expand Down
7 changes: 5 additions & 2 deletions src/org/jgroups/ObjectMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ObjectMessage(Address dest, SizeStreamable obj) {
public ObjectMessage setArray(ByteArray buf) {throw new UnsupportedOperationException();}
public boolean isWrapped() {return isFlagSet(Flag.SERIALIZED);}

// reusing SERIALIZABLE
// reusing SERIALIZED
public ObjectMessage setWrapped(boolean b) {
if(b) setFlag(Flag.SERIALIZED);
else clearFlag(Flag.SERIALIZED);
Expand Down Expand Up @@ -145,8 +145,11 @@ public void readPayload(DataInput in) throws IOException, ClassNotFoundException
}

@Override protected Message copyPayload(Message copy) {
if(obj != null)
if(obj != null) {
((ObjectMessage)copy).setObject(obj);
if(isFlagSet(Flag.SERIALIZED))
copy.setFlag(Flag.SERIALIZED);
}
return copy;
}

Expand Down
4 changes: 2 additions & 2 deletions src/org/jgroups/conf/ClassConfigurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ClassConfigurator {
protected static final String ID = "id";
protected static final String NAME = "name";
protected static final String EXTERNAL = "external";
private static final int MAX_MAGIC_VALUE=100;
private static final int MAX_MAGIC_VALUE=124;
private static final int MAX_PROT_ID_VALUE=256;
private static final short MIN_CUSTOM_MAGIC_NUMBER=1024;
private static final short MIN_CUSTOM_PROTOCOL_ID=512;
Expand Down Expand Up @@ -292,7 +292,7 @@ protected static void alreadyInProtocolsMap(short prot_id, String classname) {
* try to read the magic number configuration file as a Resource form the classpath using getResourceAsStream
* if this fails this method tries to read the configuration file from mMagicNumberFile using a FileInputStream (not in classpath but somewhere else in the disk)
*
* @return an array of ClassMap objects that where parsed from the file (if found) or an empty array if file not found or had en exception
* @return a list of ClassMap objects that where parsed from the file (if found) or an empty array if file not found or had en exception
*/
protected static List<Triple<Short,String,Boolean>> readMappings(String name) throws Exception {
InputStream stream=Util.getResourceAsStream(name, ClassConfigurator.class);
Expand Down
2 changes: 1 addition & 1 deletion src/org/jgroups/protocols/NAKACK4.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.jgroups.conf.AttributeType.SCALAR;

/**
* New multicast protocols based on fixed-size xmit windows and message ACKs<rb/>
* New multicast protocol based on fixed-size xmit windows and message ACKs<br/>
* Details: https://issues.redhat.com/browse/JGRP-2780
* @author Bela Ban
* @since 5.4
Expand Down
66 changes: 66 additions & 0 deletions src/org/jgroups/protocols/REVERSE2.java
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());
}
}
Loading

0 comments on commit afe3281

Please sign in to comment.