Skip to content

Commit

Permalink
ns
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Oct 24, 2012
1 parent c1f08ac commit 5860440
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
Expand Up @@ -20,7 +20,7 @@ METHOD testSendingOfMsgsOnUnconnectedChannel
AT ENTRY
IF TRUE
DO System.out.println("--> Creating rendezvous");
createRendezvous("BecomeServerTest", 2, true);
createRendezvous("rv", 2, true); ## we use this RV 2 times, so it needs to be rejoinable
ENDRULE

## Delete the rendezvous when the test is done
Expand All @@ -30,7 +30,7 @@ METHOD testSendingOfMsgsOnUnconnectedChannel
AT EXIT
IF TRUE
DO System.out.println("--> Deleting rendezvous");
deleteRendezvous("BecomeServerTest", 2);
deleteRendezvous("rv", 2);
ENDRULE


Expand All @@ -39,7 +39,7 @@ RULE MessageSending
CLASS BecomeServerTest
METHOD sendMessage
AT ENTRY
IF rendezvous("BecomeServerTest") != -1
IF rendezvous("rv") != -1
DO System.out.println("--> A: sending message");
ENDRULE

Expand All @@ -50,21 +50,33 @@ CLASS NAKACK2
METHOD up
AFTER INVOKE BoundedList.add(Message) ALL
BIND len=$msg.getLength();
is_server=$0.is_server;
IF len > 0
DO System.out.println("--> " + $0.local_addr + ": received message " + $msg.printHeaders() + ", added to queue");
rendezvous("BecomeServerTest");
DO System.out.println("--> " + $0.local_addr + ": received message " + $msg.printHeaders() + ", added to queue, is_server=" + is_server);
rendezvous("rv");
ENDRULE


#RULE dummy
#CLASS BoundedList
##METHOD BoundedList.add(Message)
#METHOD add
#AT EXIT
##BIND len=$1.getLength();
#IF TRUE
# DO System.out.println("**** ADDED " + $1);
#ENDRULE


## Blocks until A has sent the message and B has received (and queued) it
RULE InstallView
CLASS ClientGmsImpl
METHOD installView
AT ENTRY
BIND local_addr_name=org.jgroups.util.UUID.get($0.gms.local_addr);
IF local_addr_name.equals("B") AND rendezvous("BecomeServerTest") != -1
DO System.out.println("--> B: installView() entered rendezvous; blocking until message has been received");
rendezvous("BecomeServerTest");
IF local_addr_name.equals("B") AND rendezvous("rv") != -1
DO System.out.println("--> B: installView() waiting on rendezvous until message has been received");
rendezvous("rv");
System.out.println("--> B: installView() was unblocked");
ENDRULE

Expand Down
5 changes: 5 additions & 0 deletions src/org/jgroups/protocols/pbcast/NAKACK2.java
Expand Up @@ -216,6 +216,11 @@ public void setDiscardDeliveredMsgs(boolean discard_delivered_msgs) {
this.discard_delivered_msgs=discard_delivered_msgs;
}

@ManagedAttribute(description="Actual size of the become_server_queue")
public int getBecomeServerQueueSizeActual() {
return become_server_queue != null? become_server_queue.size() : -1;
}

/** Returns the receive window for sender; only used for testing. Do not use ! */
public Table<Message> getWindow(Address sender) {
return xmit_table.get(sender);
Expand Down
9 changes: 5 additions & 4 deletions tests/byteman/org/jgroups/tests/byteman/BecomeServerTest.java
Expand Up @@ -58,7 +58,7 @@ public void receive(Message msg) {
System.out.println("B: received message from " + msg.getSrc() + ": " + msg.getObject());
if(msg.getSrc().equals(a.getAddress())) {
try {
b.send(null, "This message triggers an exception if the channel is not yet connected");
b.send(null, "This message would trigger an exception if the channel was not yet connected");
}
catch(Exception e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -89,9 +89,10 @@ protected void sendMessage(JChannel ch, String message) {


protected JChannel createChannel(String name) throws Exception {
JChannel ch=Util.createChannel(new SHARED_LOOPBACK(),
new PING().setValue("timeout",1000).setValue("num_initial_members",2),
new NAKACK2().setValue("become_server_queue_size",10),
JChannel ch=Util.createChannel(new SHARED_LOOPBACK().setValue("enable_bundling", false)
.setValue("enable_unicast_bundling", false),
new PING().setValue("timeout", 500).setValue("num_initial_members", 2),
new NAKACK2().setValue("become_server_queue_size", 10),
new UNICAST2(),
new GMS().setValue("print_local_addr", false));
ch.setName(name);
Expand Down

0 comments on commit 5860440

Please sign in to comment.