qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r663325 - in /incubator/qpid/trunk/qpid/java: ./ common/ common/src/main/java/org/apache/qpidity/transport/codec/ common/src/main/java/org/apache/qpidity/transport/network/
Date Wed, 04 Jun 2008 17:44:57 GMT
Author: rhs
Date: Wed Jun  4 10:44:57 2008
New Revision: 663325

URL: http://svn.apache.org/viewvc?rev=663325&view=rev
Log:
QPID-1062: use BBDecoder for non fragmented segments, modified BBDecoder/Encoder to use byte
buffer primitives, made various classes final (including generated classes)

Modified:
    incubator/qpid/trunk/qpid/java/common/Composite.tpl
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBDecoder.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBEncoder.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/Decoder.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Frame.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/OutputHandler.java
    incubator/qpid/trunk/qpid/java/log4j-test.xml

Modified: incubator/qpid/trunk/qpid/java/common/Composite.tpl
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/Composite.tpl?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/Composite.tpl (original)
+++ incubator/qpid/trunk/qpid/java/common/Composite.tpl Wed Jun  4 10:44:57 2008
@@ -50,7 +50,7 @@
 typecode = code(type)
 }
 
-public class $name extends $base {
+public final class $name extends $base {
 
     public static final int TYPE = $typecode;
 

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBDecoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBDecoder.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBDecoder.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBDecoder.java
Wed Jun  4 10:44:57 2008
@@ -21,6 +21,7 @@
 package org.apache.qpidity.transport.codec;
 
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 
 /**
@@ -29,7 +30,7 @@
  * @author Rafael H. Schloming
  */
 
-public class BBDecoder extends AbstractDecoder
+public final class BBDecoder extends AbstractDecoder
 {
 
     private final ByteBuffer in;
@@ -37,6 +38,7 @@
     public BBDecoder(ByteBuffer in)
     {
         this.in = in;
+        this.in.order(ByteOrder.BIG_ENDIAN);
     }
 
     protected byte doGet()
@@ -49,4 +51,29 @@
         in.get(bytes);
     }
 
+    public boolean hasRemaining()
+    {
+        return in.hasRemaining();
+    }
+
+    public short readUint8()
+    {
+        return (short) (0xFF & in.get());
+    }
+
+    public int readUint16()
+    {
+        return 0xFFFF & in.getShort();
+    }
+
+    public long readUint32()
+    {
+        return 0xFFFFFFFFL & in.getInt();
+    }
+
+    public long readUint64()
+    {
+        return in.getLong();
+    }
+
 }

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBEncoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBEncoder.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBEncoder.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/BBEncoder.java
Wed Jun  4 10:44:57 2008
@@ -21,6 +21,7 @@
 package org.apache.qpidity.transport.codec;
 
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 
 /**
@@ -29,13 +30,14 @@
  * @author Rafael H. Schloming
  */
 
-public class BBEncoder extends AbstractEncoder
+public final class BBEncoder extends AbstractEncoder
 {
 
     private final ByteBuffer out;
 
     public BBEncoder(ByteBuffer out) {
         this.out = out;
+        this.out.order(ByteOrder.BIG_ENDIAN);
     }
 
     protected void doPut(byte b)
@@ -48,4 +50,30 @@
         out.put(src);
     }
 
+    public void writeUint8(short b)
+    {
+        assert b < 0x100;
+
+        out.put((byte) b);
+    }
+
+    public void writeUint16(int s)
+    {
+        assert s < 0x10000;
+
+        out.putShort((short) s);
+    }
+
+    public void writeUint32(long i)
+    {
+        assert i < 0x100000000L;
+
+        out.putInt((int) i);
+    }
+
+    public void writeUint64(long l)
+    {
+        out.putLong(l);
+    }
+
 }

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/Decoder.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/Decoder.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/Decoder.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/codec/Decoder.java
Wed Jun  4 10:44:57 2008
@@ -37,6 +37,8 @@
 public interface Decoder
 {
 
+    boolean hasRemaining();
+
     short readUint8();
     int readUint16();
     long readUint32();

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java
Wed Jun  4 10:44:57 2008
@@ -27,6 +27,8 @@
 
 import java.nio.ByteBuffer;
 
+import org.apache.qpidity.transport.codec.BBDecoder;
+import org.apache.qpidity.transport.codec.Decoder;
 import org.apache.qpidity.transport.codec.FragmentDecoder;
 
 import org.apache.qpidity.transport.ConnectionEvent;
@@ -161,7 +163,15 @@
 
     private ProtocolEvent decode(Frame frame, SegmentType type, List<ByteBuffer> segment)
     {
-        FragmentDecoder dec = new FragmentDecoder(segment.iterator());
+        Decoder dec;
+        if (segment.size() == 1)
+        {
+            dec = new BBDecoder(segment.get(0));
+        }
+        else
+        {
+            dec = new FragmentDecoder(segment.iterator());
+        }
 
         switch (type)
         {

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Frame.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Frame.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Frame.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/Frame.java
Wed Jun  4 10:44:57 2008
@@ -38,8 +38,7 @@
  * @author Rafael H. Schloming
  */
 
-// RA: changed it to public until we sort the package issues
-public class Frame implements NetworkEvent, Iterable<ByteBuffer>
+public final class Frame implements NetworkEvent, Iterable<ByteBuffer>
 {
     public static final int HEADER_SIZE = 12;
 

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/OutputHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/OutputHandler.java?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/OutputHandler.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/transport/network/OutputHandler.java
Wed Jun  4 10:44:57 2008
@@ -67,29 +67,26 @@
         }
     }
 
-    public static final int FRAME_END = 0xCE;
-
     public void frame(Frame frame)
     {
-       ByteBuffer hdr = ByteBuffer.allocate(HEADER_SIZE +   frame.getSize() + 1);
-        hdr.put(frame.getFlags());
-        hdr.put((byte) frame.getType().getValue());
-        hdr.putShort((short) (frame.getSize() + HEADER_SIZE));
-        hdr.put(RESERVED);
-        hdr.put(frame.getTrack());
-        hdr.putShort((short) frame.getChannel());
-        hdr.put(RESERVED);
-        hdr.put(RESERVED);
-        hdr.put(RESERVED);
-        hdr.put(RESERVED);
-        for(ByteBuffer buf : frame)
+        ByteBuffer buf = ByteBuffer.allocate(HEADER_SIZE + frame.getSize());
+        buf.put(frame.getFlags());
+        buf.put((byte) frame.getType().getValue());
+        buf.putShort((short) (frame.getSize() + HEADER_SIZE));
+        // RESERVED
+        buf.put(RESERVED);
+        buf.put(frame.getTrack());
+        buf.putShort((short) frame.getChannel());
+        // RESERVED
+        buf.putInt(0);
+        for(ByteBuffer frg : frame)
         {
-            hdr.put(buf);
+            buf.put(frg);
         }
-        hdr.flip();
+        buf.flip();
         synchronized (lock)
         {
-            sender.send(hdr);
+            sender.send(buf);
         }
     }
 

Modified: incubator/qpid/trunk/qpid/java/log4j-test.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/log4j-test.xml?rev=663325&r1=663324&r2=663325&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/log4j-test.xml (original)
+++ incubator/qpid/trunk/qpid/java/log4j-test.xml Wed Jun  4 10:44:57 2008
@@ -35,11 +35,11 @@
   </appender>
 
   <logger name="org.apache.qpid">
-    <level value="${amqj.logging.level}"/>
+    <level value="warn"/>
   </logger>
 
   <root>
-    <level value="${root.logging.level}"/>
+    <level value="warn"/>
     <appender-ref ref="console" />
   </root>
 </log4j:configuration>



Mime
View raw message