Author: rgemmell
Date: 2011-09-10 18:07:16 -0400 (Sat, 10 Sep 2011)
New Revision: 4479
Modified:
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/MessageMetaDataTB_4.java
Log:
update to account for latest broker changes, remove dependency on the Mina ByteBuffer
Applied patch from Rob Godfrey
Modified:
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java
===================================================================
---
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java 2011-09-07
15:05:36 UTC (rev 4478)
+++
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/FieldTableEncoding.java 2011-09-10
22:07:16 UTC (rev 4479)
@@ -1,15 +1,15 @@
package org.apache.qpid.server.store.berkeleydb;
-import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.AMQFrameDecodingException;
-import org.apache.mina.common.ByteBuffer;
-
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
import com.sleepycat.je.DatabaseException;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+
public class FieldTableEncoding
{
public static FieldTable readFieldTable(TupleInput tupleInput) throws
DatabaseException
@@ -25,8 +25,14 @@
byte[] data = new byte[(int)length];
tupleInput.readFast(data);
- ByteBuffer buffer = ByteBuffer.wrap(data);
- return new FieldTable(buffer,length);
+ try
+ {
+ return new FieldTable(new DataInputStream(new
ByteArrayInputStream(data)),length);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
}
Modified:
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/MessageMetaDataTB_4.java
===================================================================
---
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/MessageMetaDataTB_4.java 2011-09-07
15:05:36 UTC (rev 4478)
+++
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/MessageMetaDataTB_4.java 2011-09-10
22:07:16 UTC (rev 4479)
@@ -24,13 +24,14 @@
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;
import org.apache.log4j.Logger;
-import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.*;
import org.apache.qpid.framing.abstraction.MessagePublishInfo;
import org.apache.qpid.server.message.MessageMetaData;
import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
+import java.io.*;
+
/**
* Handles the mapping to and from 0-8/0-9 message meta data
*/
@@ -121,9 +122,15 @@
int bodySize = tupleInput.readInt();
byte[] underlying = new byte[bodySize];
tupleInput.readFast(underlying);
- ByteBuffer buf = ByteBuffer.wrap(underlying);
- return ContentHeaderBody.createFromBuffer(buf, bodySize);
+ try
+ {
+ return ContentHeaderBody.createFromBuffer(new DataInputStream(new
ByteArrayInputStream(underlying)), bodySize);
+ }
+ catch (IOException e)
+ {
+ throw new AMQFrameDecodingException(null, e.getMessage(), e);
+ }
}
private void writeMessagePublishInfo(MessagePublishInfo publishBody, TupleOutput
tupleOutput) throws AMQException
@@ -139,10 +146,17 @@
{
// write out the content header body
final int bodySize = headerBody.getSize();
- byte[] underlying = new byte[bodySize];
- ByteBuffer buf = ByteBuffer.wrap(underlying);
- headerBody.writePayload(buf);
- tupleOutput.writeInt(bodySize);
- tupleOutput.writeFast(underlying);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(bodySize);
+ try
+ {
+ headerBody.writePayload(new DataOutputStream(baos));
+ tupleOutput.writeInt(bodySize);
+ tupleOutput.writeFast(baos.toByteArray());
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+
}
}
Show replies by date