/** * Write a list of messages with the *same* destination and src addresses. The message list is * marshalled as follows (see doc/design/MarshallingFormat.txt for details): * <pre> * List: * | version | flags | dest | src | cluster-name | [Message*] | * * Message: | presence | leading | flags | [src] | length | [buffer] | size | [Headers*] | * * </pre> * @param dest * @param src * @param msgs * @param dos * @param multicast * @throws Exception */ public static void writeMessageList(Address dest, Address src, byte[] cluster_name, List<Message> msgs, DataOutput dos, boolean multicast, short transport_id) throws Exception { writeMessageListHeader(dest, src, cluster_name, msgs != null ? msgs.size() : 0, dos, multicast); if(msgs != null) for(Message msg: msgs) msg.writeToNoAddrs(src, dos, transport_id); // exclude the transport header }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, final int start_index, final int end_index, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; for(int i=start_index; i != end_index; i=increment(i)) { Message msg=buf[i]; if(msg != null && msg != NULL_MSG && Objects.equals(dest, msg.dest())) { long msg_size=msg.size(); if(bytes + msg_size > max_bundle_size) break; bytes+=msg_size; num_msgs++; buf[i]=NULL_MSG; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } } return num_msgs; }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, final int end_index, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; for(;;) { Message msg=buf[start_index]; if(msg != null && Objects.equals(dest, msg.dest())) { long size=msg.size(); if(bytes + size > max_bundle_size) break; bytes+=size; num_msgs++; buf[start_index]=null; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } if(start_index == end_index) break; start_index=advance(start_index); } return num_msgs; }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int available_msgs, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; while(available_msgs > 0) { Message msg=buf[start_index]; if(msg != null && Objects.equals(dest, msg.dest())) { long msg_size=msg.size(); if(bytes + msg_size > max_bundle_size) break; bytes+=msg_size; num_msgs++; buf[start_index]=null; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } available_msgs--; start_index=increment(start_index); } return num_msgs; }
msg.writeToNoAddrs(msg.getSrc(), output, transport.getId()); msg_queue[i]=null;
/** * Write a list of messages with the *same* destination and src addresses. The message list is * marshalled as follows (see doc/design/MarshallingFormat.txt for details): * <pre> * List: * | version | flags | dest | src | cluster-name | [Message*] | * * Message: | presence | leading | flags | [src] | length | [buffer] | size | [Headers*] | * * </pre> * @param dest * @param src * @param msgs * @param dos * @param multicast * @throws Exception */ public static void writeMessageList(Address dest, Address src, byte[] cluster_name, List<Message> msgs, DataOutput dos, boolean multicast, short transport_id) throws Exception { writeMessageListHeader(dest, src, cluster_name, msgs != null ? msgs.size() : 0, dos, multicast); if(msgs != null) for(Message msg: msgs) msg.writeToNoAddrs(src, dos, transport_id); // exclude the transport header }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, final int start_index, final int end_index, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; for(int i=start_index; i != end_index; i=increment(i)) { Message msg=buf[i]; if(msg != null && msg != NULL_MSG && Objects.equals(dest, msg.dest())) { long msg_size=msg.size(); if(bytes + msg_size > max_bundle_size) break; bytes+=msg_size; num_msgs++; buf[i]=NULL_MSG; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } } return num_msgs; }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, int available_msgs, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; while(available_msgs > 0) { Message msg=buf[start_index]; if(msg != null && Objects.equals(dest, msg.dest())) { long msg_size=msg.size(); if(bytes + msg_size > max_bundle_size) break; bytes+=msg_size; num_msgs++; buf[start_index]=null; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } available_msgs--; start_index=increment(start_index); } return num_msgs; }
protected int marshalMessagesToSameDestination(Address dest, Message[] buf, int start_index, final int end_index, int max_bundle_size) throws Exception { int num_msgs=0, bytes=0; for(;;) { Message msg=buf[start_index]; if(msg != null && Objects.equals(dest, msg.dest())) { long size=msg.size(); if(bytes + size > max_bundle_size) break; bytes+=size; num_msgs++; buf[start_index]=null; msg.writeToNoAddrs(msg.src(), output, transport.getId()); } if(start_index == end_index) break; start_index=advance(start_index); } return num_msgs; }
msg.writeToNoAddrs(msg.getSrc(), output, transport.getId()); msg_queue[i]=null;