mirror of https://github.com/apache/activemq.git
add the data size to datagram headers
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@383894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eba4c9cfa8
commit
fcd06b2077
|
@ -111,6 +111,7 @@ public class CommandChannel implements Service {
|
||||||
int size = wireFormat.tightMarshalNestedObject1(command, bs);
|
int size = wireFormat.tightMarshalNestedObject1(command, bs);
|
||||||
if (size < datagramSize ) {
|
if (size < datagramSize ) {
|
||||||
header.setPartial(false);
|
header.setPartial(false);
|
||||||
|
header.setDataSize(size);
|
||||||
writeBuffer.rewind();
|
writeBuffer.rewind();
|
||||||
wireFormat.marshal(command, dataOut);
|
wireFormat.marshal(command, dataOut);
|
||||||
dataOut.flush();
|
dataOut.flush();
|
||||||
|
@ -132,6 +133,7 @@ public class CommandChannel implements Service {
|
||||||
writeBuffer.rewind();
|
writeBuffer.rewind();
|
||||||
int chunkSize = writeBuffer.capacity() - headerMarshaller.getHeaderSize(header);
|
int chunkSize = writeBuffer.capacity() - headerMarshaller.getHeaderSize(header);
|
||||||
lastFragment = offset + chunkSize >= length;
|
lastFragment = offset + chunkSize >= length;
|
||||||
|
header.setDataSize(chunkSize);
|
||||||
header.setComplete(lastFragment);
|
header.setComplete(lastFragment);
|
||||||
headerMarshaller.writeHeader(header, writeBuffer);
|
headerMarshaller.writeHeader(header, writeBuffer);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class DatagramHeaderMarshaller {
|
||||||
public DatagramHeader readHeader(ByteBuffer readBuffer) {
|
public DatagramHeader readHeader(ByteBuffer readBuffer) {
|
||||||
DatagramHeader answer = new DatagramHeader();
|
DatagramHeader answer = new DatagramHeader();
|
||||||
answer.setCounter(readBuffer.getLong());
|
answer.setCounter(readBuffer.getLong());
|
||||||
|
answer.setDataSize(readBuffer.getInt());
|
||||||
byte flags = readBuffer.get();
|
byte flags = readBuffer.get();
|
||||||
answer.setFlags(flags);
|
answer.setFlags(flags);
|
||||||
return answer;
|
return answer;
|
||||||
|
@ -35,11 +36,12 @@ public class DatagramHeaderMarshaller {
|
||||||
|
|
||||||
public void writeHeader(DatagramHeader header, ByteBuffer writeBuffer) {
|
public void writeHeader(DatagramHeader header, ByteBuffer writeBuffer) {
|
||||||
writeBuffer.putLong(header.getCounter());
|
writeBuffer.putLong(header.getCounter());
|
||||||
|
writeBuffer.putInt(header.getDataSize());
|
||||||
writeBuffer.put(header.getFlags());
|
writeBuffer.put(header.getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeaderSize(DatagramHeader header) {
|
public int getHeaderSize(DatagramHeader header) {
|
||||||
return 8 + 1;
|
return 8 + 4 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue