Permalink
Browse files

Changed ParseMessages to use methods exposed by TP to parse captured …

…message dumps
  • Loading branch information...
1 parent 4d4b54d commit d085b37fb456665bec43f0ebb068d8287b08e3fc Bela Ban committed Apr 5, 2013
Showing with 23 additions and 12 deletions.
  1. +1 −1 src/org/jgroups/protocols/TP.java
  2. +22 −11 tests/other/org/jgroups/tests/ParseMessages.java
@@ -1632,7 +1632,7 @@ protected static void writeMessage(Message msg, DataOutputStream dos, boolean mu
msg.writeTo(dos);
}
- protected static Message readMessage(DataInputStream instream) throws Exception {
+ public static Message readMessage(DataInputStream instream) throws Exception {
Message msg=new Message(false); // don't create headers, readFrom() will do this
msg.readFrom(instream);
return msg;
@@ -3,9 +3,12 @@
import org.jgroups.Address;
import org.jgroups.Message;
import org.jgroups.Version;
+import org.jgroups.protocols.TP;
+import org.jgroups.util.MessageBatch;
import org.jgroups.util.Util;
import java.io.*;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -53,16 +56,29 @@ public void parse() {
boolean multicast=(flags & MULTICAST) == MULTICAST;
if(is_message_list) { // used if message bundling is enabled
- List<Message> msgs=readMessageList(dis);
- System.out.println(msgs.size() + " msgs: ");
+ final MessageBatch[] batches=TP.readMessageBatch(dis,multicast);
+ final MessageBatch batch=batches[0], oob_batch=batches[1], internal_batch=batches[2];
+ int size=batch != null? batch.size() : 0;
+ if(oob_batch != null)
+ size+=oob_batch.size();
+ if(internal_batch != null)
+ size+=internal_batch.size();
+
+ System.out.println(size + " msgs: ");
+
int cnt=1;
- for(Message msg: msgs) {
- System.out.print("#" + cnt++ + ": ");
- print(msg, multicast);
+
+ for(MessageBatch tmp: Arrays.asList(batch, oob_batch, internal_batch)) {
+ if(tmp != null) {
+ for(Message msg: tmp) {
+ System.out.print("#" + cnt++ + ": ");
+ print(msg, multicast);
+ }
+ }
}
}
else {
- Message msg=readMessage(dis);
+ Message msg=TP.readMessage(dis);
print(msg, multicast);
}
}
@@ -95,11 +111,6 @@ private static void print(Message msg, boolean multicast) {
return list;
}
- protected static Message readMessage(DataInputStream instream) throws Exception {
- Message msg=new Message(false); // don't create headers, readFrom() will do this
- msg.readFrom(instream);
- return msg;
- }
public static void main(String[] args) throws FileNotFoundException {

0 comments on commit d085b37

Please sign in to comment.