 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5841 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-26 14:41:34 -0400 (Fri, 26 Mar 2010)
New Revision: 5841
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
Log:
JBREM-1215 part 2.1: Push copies to other threads so our main buffer may be reused
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java	2010-03-26 18:41:34 UTC (rev 5841)
@@ -240,7 +240,7 @@
                     }
                     byteInput = inboundRequest.getByteInput();
                 }
-                byteInput.push(buffer);
+                byteInput.push(Buffers.flip(ByteBuffer.allocate(buffer.remaining()).put(buffer)));
                 return;
             }
             case RemoteProtocol.REQUEST_ABORT: {
@@ -301,7 +301,7 @@
                         byteInput = outboundRequest.getByteInput();
                     }
                 }
-                byteInput.push(buffer);
+                byteInput.push(Buffers.flip(ByteBuffer.allocate(buffer.remaining()).put(buffer)));
                 return;
             }
             case RemoteProtocol.REPLY_ACK_CHUNK: {
@@ -342,7 +342,7 @@
                         byteInput = outboundRequest.getByteInput();
                     }
                 }
-                byteInput.push(buffer);
+                byteInput.push(Buffers.flip(ByteBuffer.allocate(buffer.remaining()).put(buffer)));
                 return;
             }
             case RemoteProtocol.REPLY_EXCEPTION_ABORT: {
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5840 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-26 14:38:10 -0400 (Fri, 26 Mar 2010)
New Revision: 5840
Added:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/FramingChannelListener.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/AbstractMessageHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientGreetingHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientOpenListener.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundClient.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyInputHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundStream.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundStream.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteProtocol.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/SaslUtils.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java
Log:
JBREM-1215 part 2: Use 2-byte message size; more efficient buffer handling
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/AbstractMessageHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/AbstractMessageHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/AbstractMessageHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -23,17 +23,19 @@
 package org.jboss.remoting3.remote;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
 import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.channels.MessageHandler;
 
-abstract class AbstractMessageHandler implements MessageHandler {
+abstract class AbstractMessageHandler {
     protected final RemoteConnection remoteConnection;
 
     protected AbstractMessageHandler(final RemoteConnection remoteConnection) {
         this.remoteConnection = remoteConnection;
     }
 
+    public abstract void handleMessage(ByteBuffer message);
+
     public void handleEof() {
         try {
             remoteConnection.getChannel().shutdownReads();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientGreetingHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientGreetingHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientGreetingHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -146,7 +146,7 @@
                 log.trace("Sasl mechanism selected: %s", mechanismName);
                 final ByteBuffer outBuf = connection.allocate();
                 try {
-                    outBuf.putInt(0);
+                    outBuf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
                     outBuf.put(RemoteProtocol.AUTH_REQUEST);
                     Buffers.putModifiedUtf8(outBuf, mechanismName);
                     outBuf.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientOpenListener.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientOpenListener.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientOpenListener.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -69,7 +69,7 @@
         // Send client greeting packet...
         final ByteBuffer buffer = connection.allocate();
         // length placeholder
-        buffer.putInt(0);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(RemoteProtocol.GREETING);
         // marshaller versions
         final int[] versions = providerDescriptor.getSupportedVersions();
@@ -80,7 +80,7 @@
         GreetingUtils.writeByte(buffer, RemoteProtocol.GREETING_VERSION, RemoteProtocol.VERSION);
         // that's it!
         buffer.flip();
-        buffer.putInt(0, buffer.remaining() - 4);
+        buffer.putShort(0, (short) (buffer.remaining() - 2));
         channel.getWriteSetter().set(new ChannelListener<ConnectedStreamChannel<InetSocketAddress>>() {
             public void handleEvent(final ConnectedStreamChannel<InetSocketAddress> channel) {
                 for (;;) {
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/FramingChannelListener.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/FramingChannelListener.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/FramingChannelListener.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.remote;
+
+import java.io.IOException;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import org.jboss.remoting3.RemotingOptions;
+import org.jboss.xnio.Buffers;
+import org.jboss.xnio.ChannelListener;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
+import org.jboss.xnio.channels.StreamChannel;
+
+final class FramingChannelListener implements ChannelListener<StreamChannel> {
+
+    private volatile int maxSize;
+    private final ByteBuffer receiveBuffer;
+    private volatile AbstractMessageHandler messageHandler;
+    private State state = State.SIZE;
+    private int nextSize;
+
+    FramingChannelListener(final OptionMap optionMap, final AbstractMessageHandler messageHandler) {
+        this.messageHandler = messageHandler;
+        maxSize = optionMap.get(Options.MAX_INBOUND_MESSAGE_SIZE, 2048);
+        receiveBuffer = ByteBuffer.allocate(Math.min(optionMap.get(RemotingOptions.BUFFER_SIZE, maxSize * 4), 4096));
+    }
+
+    private enum State {
+        SIZE,
+        BODY,
+    }
+
+    public void handleEvent(final StreamChannel streamChannel) {
+        final ByteBuffer receiveBuffer = this.receiveBuffer;
+        assert receiveBuffer.hasRemaining();
+        int res;
+        try {
+            res = streamChannel.read(receiveBuffer);
+        } catch (IOException e) {
+            messageHandler.handleException(e);
+            return;
+        }
+        if (res == 0) {
+            streamChannel.resumeReads();
+            return;
+        }
+        if (res == -1) {
+            messageHandler.handleEof();
+            return;
+        }
+        for (;;) {
+            while (receiveBuffer.hasRemaining()) {
+                try {
+                    res = streamChannel.read(receiveBuffer);
+                } catch (IOException e) {
+                    handleBufferedData();
+                    messageHandler.handleException(e);
+                    return;
+                }
+                if (res == 0) {
+                    handleBufferedData();
+                    streamChannel.resumeReads();
+                    return;
+                }
+                if (res == -1) {
+                    handleBufferedData();
+                    messageHandler.handleEof();
+                    return;
+                }
+            }
+            handleBufferedData();
+        }
+    }
+
+    private void handleBufferedData() {
+        final ByteBuffer receiveBuffer = this.receiveBuffer;
+        final State initial = state;
+        receiveBuffer.flip();
+        try {
+            if (initial == State.BODY) {
+                final int size = nextSize;
+                if (receiveBuffer.remaining() < size) {
+                    return;
+                }
+                final ByteBuffer buffer = Buffers.slice(receiveBuffer, size);
+                try {
+                    messageHandler.handleMessage(buffer);
+                } catch (BufferUnderflowException e) {
+                    final IOException e1 = new IOException();
+                    e1.initCause(e);
+                    messageHandler.handleException(e1);
+                    return;
+                }
+            }
+            int size;
+            for (;;) {
+                if (receiveBuffer.remaining() < 2) {
+                    state = State.SIZE;
+                    return;
+                }
+                size = receiveBuffer.getShort() & 0xffff;
+                if (receiveBuffer.remaining() < size) {
+                    nextSize = size;
+                    state = State.BODY;
+                    return;
+                }
+                final ByteBuffer buffer = Buffers.slice(receiveBuffer, size);
+                try {
+                    messageHandler.handleMessage(buffer);
+                } catch (BufferUnderflowException e) {
+                    final IOException e1 = new IOException();
+                    e1.initCause(e);
+                    messageHandler.handleException(e1);
+                    return;
+                }
+            }
+        } finally {
+            // we use TCP_NODELAY so this usually will clear the buffer with no bytes copied
+            receiveBuffer.compact();
+        }
+    }
+
+    void setMaxSize(final int maxSize) {
+        this.maxSize = maxSize;
+    }
+
+    void setMessageHandler(final AbstractMessageHandler messageHandler) {
+        this.messageHandler = messageHandler;
+    }
+}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundClient.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundClient.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundClient.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -52,7 +52,7 @@
         final RemoteConnection remoteConnection = remoteConnectionHandler.getRemoteConnection();
         final ByteBuffer buffer = remoteConnection.allocate();
         try {
-            buffer.position(4);
+            buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buffer.put(RemoteProtocol.CLIENT_ASYNC_CLOSE);
             buffer.putInt(id);
             buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyInputHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyInputHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyInputHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -39,7 +39,7 @@
         final RemoteConnectionHandler connectionHandler = outboundRequest.getRemoteConnectionHandler();
         final ByteBuffer buffer = connectionHandler.getBufferPool().allocate();
         try {
-            buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+            buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buffer.put(RemoteProtocol.REPLY_ACK_CHUNK);
             buffer.putInt(rid);
             buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestInputHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -44,7 +44,7 @@
         final Pool<ByteBuffer> bufferPool = connectionHandler.getBufferPool();
         final ByteBuffer buffer = bufferPool.allocate();
         try {
-            buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+            buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buffer.put(RemoteProtocol.REQUEST_ACK_CHUNK);
             buffer.putInt(rid);
             buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundStream.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundStream.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundStream.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -85,7 +85,7 @@
 
     private void doSend(byte code) {
         final ByteBuffer buffer = remoteConnection.allocate();
-        buffer.position(4);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(code);
         buffer.putInt(id);
         buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyBufferWriter.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -49,7 +49,7 @@
         final Pool<ByteBuffer> bufferPool = connectionHandler.getBufferPool();
         final ByteBuffer buffer = bufferPool.allocate();
         log.trace("Allocated buffer %s for %s", buffer, this);
-        buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(exception ? RemoteProtocol.REPLY_EXCEPTION : RemoteProtocol.REPLY);
         buffer.putInt(id);
         final boolean isFirst = first.getAndSet(false);
@@ -75,7 +75,7 @@
                 buffer.put(7, (byte) (buffer.get(3) | RemoteProtocol.MSG_FLAG_LAST));
             }
             log.trace("Sending buffer %s for %s", buffer, this);
-            connectionHandler.getRemoteConnection().sendBlocking(buffer, eof);
+            connectionHandler.getRemoteConnection().sendBlocking(buffer, true);
         } finally {
             connectionHandler.getBufferPool().free(buffer);
         }
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -77,7 +77,7 @@
                     final Pool<ByteBuffer> bufferPool = connectionHandler.getBufferPool();
                     final ByteBuffer buffer = bufferPool.allocate();
                     try {
-                        buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+                        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
                         buffer.put(RemoteProtocol.REPLY_EXCEPTION_ABORT);
                         buffer.putInt(rid);
                         buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestBufferWriter.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -45,7 +45,7 @@
     public ByteBuffer getBuffer() {
         final ByteBuffer buffer = outboundRequest.getRemoteConnectionHandler().getBufferPool().allocate();
         log.trace("Allocated buffer %s for %s", buffer, this);
-        buffer.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(RemoteProtocol.REQUEST);
         buffer.putInt(rid);
         final boolean isFirst = first.getAndSet(false);
@@ -76,7 +76,7 @@
                 }
             }
             log.trace("Sending buffer %s for %s", buffer, this);
-            remoteConnectionHandler.getRemoteConnection().sendBlocking(buffer, eof);
+            remoteConnectionHandler.getRemoteConnection().sendBlocking(buffer, true);
         } finally {
             remoteConnectionHandler.getBufferPool().free(buffer);
         }
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -80,7 +80,7 @@
             }
             // send request abort msg
             final ByteBuffer buf = connectionHandler.getBufferPool().allocate();
-            buf.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+            buf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buf.put(RemoteProtocol.REQUEST_ABORT);
             buf.putInt(rid);
             buf.flip();
@@ -102,7 +102,7 @@
         final Pool<ByteBuffer> bufferPool = connectionHandler.getBufferPool();
         final ByteBuffer buf = bufferPool.allocate();
         try {
-            buf.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+            buf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buf.put(RemoteProtocol.CLIENT_CLOSE);
             buf.putInt(outboundClient.getId());
             buf.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundStream.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundStream.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundStream.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -59,7 +59,7 @@
      */
     ByteBuffer getBuffer() {
         final ByteBuffer buffer = remoteConnection.allocate();
-        buffer.position(4);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(RemoteProtocol.STREAM_DATA);
         buffer.putInt(id);
         return buffer;
@@ -132,7 +132,7 @@
 
     private void doSend(byte code) {
         final ByteBuffer buffer = remoteConnection.allocate();
-        buffer.position(4);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(code);
         buffer.putInt(id);
         buffer.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -35,16 +35,14 @@
 import org.jboss.xnio.OptionMap;
 import org.jboss.xnio.Options;
 import org.jboss.xnio.Pool;
-import org.jboss.xnio.channels.Channels;
 import org.jboss.xnio.channels.ConnectedStreamChannel;
-import org.jboss.xnio.channels.MessageHandler;
 import org.jboss.xnio.log.Logger;
 
 final class RemoteConnection extends AbstractHandleableCloseable<RemoteConnection> implements Closeable {
     private final ConnectedStreamChannel<InetSocketAddress> channel;
     private final ProviderDescriptor providerDescriptor;
     private final Pool<ByteBuffer> bufferPool;
-    private final MessageHandler.Setter messageHandlerSetter;
+    private final FramingChannelListener framingChannelListener;
     private final OptionMap optionMap;
     private final Object writeLock = new Object();
     private static final Logger log = Loggers.main;
@@ -53,7 +51,7 @@
         super(executor);
         this.channel = channel;
         this.providerDescriptor = providerDescriptor;
-        messageHandlerSetter = Channels.createMessageReader(channel, optionMap);
+        channel.getReadSetter().set(framingChannelListener = new FramingChannelListener(optionMap, null));
         bufferPool = Buffers.createHeapByteBufferAllocator(optionMap.get(Options.MAX_INBOUND_MESSAGE_SIZE, 2048));
         this.optionMap = optionMap;
     }
@@ -85,14 +83,14 @@
         bufferPool.free(buffer);
     }
 
-    void setMessageHandler(MessageHandler handler) {
-        messageHandlerSetter.set(handler);
+    void setMessageHandler(AbstractMessageHandler handler) {
+        framingChannelListener.setMessageHandler(handler);
     }
 
     void sendBlocking(final ByteBuffer buffer, boolean flush) throws IOException {
         try {
             synchronized (writeLock) {
-                buffer.putInt(0, buffer.remaining() - 4);
+                buffer.putShort(0, (short) (buffer.remaining() - 2));
                 boolean intr = false;
                 try {
                     while (buffer.hasRemaining()) {
@@ -177,7 +175,7 @@
     void sendAuthReject(final String msg) throws IOException {
         final ByteBuffer buf = allocate();
         try {
-            buf.putInt(0);
+            buf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buf.put(RemoteProtocol.AUTH_REJECTED);
             Buffers.putModifiedUtf8(buf, msg);
             buf.flip();
@@ -190,7 +188,7 @@
     void sendAuthMessage(final byte msgType, final byte[] message) throws IOException {
         final ByteBuffer buf = allocate();
         try {
-            buf.putInt(0);
+            buf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
             buf.put(msgType);
             if (message != null) buf.put(message);
             buf.flip();
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -51,7 +51,7 @@
 
 final class RemoteConnectionHandler extends AbstractHandleableCloseable<RemoteConnectionHandler> implements ConnectionHandler {
 
-    static final int LENGTH_PLACEHOLDER = 0;
+    static final short LENGTH_PLACEHOLDER = 0;
 
     private final Pool<ByteBuffer> bufferPool = Buffers.createHeapByteBufferAllocator(4096);
     private final MarshallerFactory marshallerFactory;
@@ -99,7 +99,7 @@
         // compose & send message
         final ByteBuffer buffer = bufferPool.allocate();
         try {
-            buffer.putInt(LENGTH_PLACEHOLDER);
+            buffer.putShort(LENGTH_PLACEHOLDER);
             buffer.put(RemoteProtocol.SERVICE_REQUEST);
             buffer.putInt(id);
             Buffers.putModifiedUtf8(buffer, serviceType);
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -80,7 +80,7 @@
                         }
                     } catch (Exception e) {
                         log.error("Failed to unmarshall service request option map: %s", e);
-                        outBuf.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+                        outBuf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
                         outBuf.put(RemoteProtocol.SERVICE_ERROR);
                         outBuf.putInt(id);
                         outBuf.flip();
@@ -94,7 +94,7 @@
                     }
                     final LocalRequestHandler handler;
                     handler = connectionHandler.getConnectionContext().openService(serviceType, instanceName, optionMap);
-                    outBuf.putInt(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
+                    outBuf.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
                     if (handler == null) {
                         // no matching service found
                         outBuf.put(RemoteProtocol.SERVICE_NOT_FOUND);
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteProtocol.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteProtocol.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteProtocol.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -86,6 +86,9 @@
     static final byte GREETING_SASL_MECH = 1; // sent by server
     static final byte GREETING_ENDPOINT_NAME = 2; // sent by client & server
     static final byte GREETING_MARSHALLER_VERSION = 3; // sent by client & server
+    static final byte GREETING_SERVER_MIN_MESSAGE_SIZE = 4; // sent by server
+    static final byte GREETING_SERVER_MAX_MESSAGE_SIZE = 5; // sent by server
+    static final byte GREETING_CLIENT_MESSAGE_SIZE = 6; // sent by client
 
     // Object sink stream commands
 
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/SaslUtils.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/SaslUtils.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/SaslUtils.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -96,18 +96,4 @@
     static boolean isSecureQop(Object qop) {
         return SECURE_QOP.contains(qop);
     }
-
-    static void wrapFramed(SaslClient saslClient, ByteBuffer message) throws SaslException {
-        final byte[] result;
-        if (message.hasArray()) {
-            result = saslClient.wrap(message.array(), message.arrayOffset() + 4, message.position());
-        } else {
-            final int end = message.position();
-            message.position(4);
-            final byte[] bytes = Buffers.take(message, end - 4);
-            result = saslClient.wrap(bytes, 0, bytes.length);
-        }
-        message.position(4);
-        message.put(result);
-    }
 }
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java	2010-03-26 00:56:45 UTC (rev 5839)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java	2010-03-26 18:38:10 UTC (rev 5840)
@@ -112,7 +112,7 @@
         // Send server greeting packet...
         final ByteBuffer buffer = connection.allocate();
         // length placeholder
-        buffer.putInt(0);
+        buffer.putShort(RemoteConnectionHandler.LENGTH_PLACEHOLDER);
         buffer.put(RemoteProtocol.GREETING);
         // version ID
         GreetingUtils.writeByte(buffer, RemoteProtocol.GREETING_VERSION, RemoteProtocol.VERSION);
@@ -129,7 +129,7 @@
         GreetingUtils.writeString(buffer, RemoteProtocol.GREETING_ENDPOINT_NAME, connectionProviderContext.getEndpoint().getName());
         // that's it!
         buffer.flip();
-        buffer.putInt(0, buffer.remaining() - 4);
+        buffer.putShort(0, (short) (buffer.remaining() - 2));
         channel.getWriteSetter().set(new ChannelListener<ConnectedStreamChannel<InetSocketAddress>>() {
             public void handleEvent(final ConnectedStreamChannel<InetSocketAddress> channel) {
                 for (;;) {
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5839 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-25 20:56:45 -0400 (Thu, 25 Mar 2010)
New Revision: 5839
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java
Log:
JBREM-1215 stopgap: Make sure the buffer allocator message size matches the channel message size
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java	2010-03-25 23:32:01 UTC (rev 5838)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnection.java	2010-03-26 00:56:45 UTC (rev 5839)
@@ -33,6 +33,7 @@
 import org.jboss.xnio.Buffers;
 import org.jboss.xnio.IoUtils;
 import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
 import org.jboss.xnio.Pool;
 import org.jboss.xnio.channels.Channels;
 import org.jboss.xnio.channels.ConnectedStreamChannel;
@@ -42,7 +43,7 @@
 final class RemoteConnection extends AbstractHandleableCloseable<RemoteConnection> implements Closeable {
     private final ConnectedStreamChannel<InetSocketAddress> channel;
     private final ProviderDescriptor providerDescriptor;
-    private final Pool<ByteBuffer> bufferPool = Buffers.createHeapByteBufferAllocator(4096);
+    private final Pool<ByteBuffer> bufferPool;
     private final MessageHandler.Setter messageHandlerSetter;
     private final OptionMap optionMap;
     private final Object writeLock = new Object();
@@ -53,6 +54,7 @@
         this.channel = channel;
         this.providerDescriptor = providerDescriptor;
         messageHandlerSetter = Channels.createMessageReader(channel, optionMap);
+        bufferPool = Buffers.createHeapByteBufferAllocator(optionMap.get(Options.MAX_INBOUND_MESSAGE_SIZE, 2048));
         this.optionMap = optionMap;
     }
 
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5838 - in remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3: remote and 1 other directories.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-25 19:32:01 -0400 (Thu, 25 Mar 2010)
New Revision: 5838
Added:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClosingCloseHandler.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/SpiUtils.java
Log:
Extract ClosingCloseHandler into its own class
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClosingCloseHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClosingCloseHandler.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClosingCloseHandler.java	2010-03-25 23:32:01 UTC (rev 5838)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3;
+
+import java.io.Closeable;
+import org.jboss.xnio.IoUtils;
+
+/**
+ * A close handler which closes some resource.
+ */
+public final class ClosingCloseHandler<T> implements CloseHandler<T> {
+    private final Closeable c;
+
+    /**
+     * Construct a new instance.
+     *
+     * @param c the resource to close
+     */
+    public ClosingCloseHandler(final Closeable c) {
+        this.c = c;
+    }
+
+    /** {@inheritDoc} */
+    public void handleClose(final T closed) {
+        IoUtils.safeClose(c);
+    }
+}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-25 23:25:26 UTC (rev 5837)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-25 23:32:01 UTC (rev 5838)
@@ -32,6 +32,7 @@
 import org.jboss.marshalling.MarshallingConfiguration;
 import org.jboss.marshalling.util.IntKeyMap;
 import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.ClosingCloseHandler;
 import org.jboss.remoting3.IndeterminateOutcomeException;
 import org.jboss.remoting3.ServiceOpenException;
 import org.jboss.remoting3.spi.AbstractHandleableCloseable;
@@ -83,11 +84,7 @@
         config.setStreamHeader(Marshalling.nullStreamHeader());
         // fixed for now (v0)
         config.setVersion(2);
-        remoteConnection.addCloseHandler(new CloseHandler<RemoteConnection>() {
-            public void handleClose(final RemoteConnection closed) {
-                IoUtils.safeClose(RemoteConnectionHandler.this);
-            }
-        });
+        remoteConnection.addCloseHandler(new ClosingCloseHandler<RemoteConnection>(this));
         marshallingConfiguration = config;
     }
 
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/SpiUtils.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/SpiUtils.java	2010-03-25 23:25:26 UTC (rev 5837)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/SpiUtils.java	2010-03-25 23:32:01 UTC (rev 5838)
@@ -25,6 +25,7 @@
 import java.io.Closeable;
 import java.io.IOException;
 import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.ClosingCloseHandler;
 import org.jboss.remoting3.RequestCancelHandler;
 import org.jboss.remoting3.RequestContext;
 import org.jboss.xnio.IoUtils;
@@ -159,11 +160,7 @@
      * @param c the resource to close
      * @return the close handler
      */
-    public static CloseHandler<Object> closingCloseHandler(final Closeable c) {
-        return new CloseHandler<Object>() {
-            public void handleClose(final Object closed) {
-                IoUtils.safeClose(c);
-            }
-        };
+    public static <T> CloseHandler<T> closingCloseHandler(final Closeable c) {
+        return new ClosingCloseHandler<T>(c);
     }
 }
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5837 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-25 19:25:26 -0400 (Thu, 25 Mar 2010)
New Revision: 5837
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
Log:
JBREM-1214 - fix a bug where exceptions thrown during message processing do not close the connection correctly
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-25 03:40:22 UTC (rev 5836)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java	2010-03-25 23:25:26 UTC (rev 5837)
@@ -31,6 +31,7 @@
 import org.jboss.marshalling.Marshalling;
 import org.jboss.marshalling.MarshallingConfiguration;
 import org.jboss.marshalling.util.IntKeyMap;
+import org.jboss.remoting3.CloseHandler;
 import org.jboss.remoting3.IndeterminateOutcomeException;
 import org.jboss.remoting3.ServiceOpenException;
 import org.jboss.remoting3.spi.AbstractHandleableCloseable;
@@ -82,6 +83,11 @@
         config.setStreamHeader(Marshalling.nullStreamHeader());
         // fixed for now (v0)
         config.setVersion(2);
+        remoteConnection.addCloseHandler(new CloseHandler<RemoteConnection>() {
+            public void handleClose(final RemoteConnection closed) {
+                IoUtils.safeClose(RemoteConnectionHandler.this);
+            }
+        });
         marshallingConfiguration = config;
     }
 
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5836 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: trustin
Date: 2010-03-24 23:40:22 -0400 (Wed, 24 Mar 2010)
New Revision: 5836
Removed:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java
Log:
ManagedCloseable is not necessary at the moment
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java	2010-03-25 03:35:27 UTC (rev 5835)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java	2010-03-25 03:40:22 UTC (rev 5836)
@@ -21,7 +21,10 @@
  */
 package org.jboss.remoting3.management;
 
-public interface ConnectionMXBean extends ManagedCloseable {
+public interface ConnectionMXBean {
     Counters getRequestCounters();
     Counters getClientCounters();
+
+    void close();
+    void forceClose();
 }
Deleted: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java	2010-03-25 03:35:27 UTC (rev 5835)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java	2010-03-25 03:40:22 UTC (rev 5836)
@@ -1,27 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.remoting3.management;
-
-public interface ManagedCloseable {
-    void close();
-    void forceClose();
-}
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5835 - in remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3: management and 1 other directory.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: trustin
Date: 2010-03-24 23:35:27 -0400 (Wed, 24 Mar 2010)
New Revision: 5835
Added:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/Counters.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/EndpointMXBean.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ServiceInfo.java
Log:
Draft MXBeans and composite types
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java	2010-03-25 03:35:27 UTC (rev 5835)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.remoting3.management;
+
+public interface ConnectionMXBean extends ManagedCloseable {
+    Counters getRequestCounters();
+    Counters getClientCounters();
+}
Property changes on: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ConnectionMXBean.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/Counters.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/Counters.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/Counters.java	2010-03-25 03:35:27 UTC (rev 5835)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.remoting3.management;
+
+import java.beans.ConstructorProperties;
+
+public class Counters {
+    private final long active;
+    private final long success;
+    private final long failure;
+    
+    @ConstructorProperties({"active", "success", "failure"})
+    public Counters(long active, long success, long failure) {
+        this.active = active;
+        this.success = success;
+        this.failure = failure;
+    }
+    
+    public long getActive() {
+        return active;
+    }
+
+    public long getSuccess() {
+        return success;
+    }
+
+    public long getFailure() {
+        return failure;
+    }
+    
+    @Override
+    public String toString() {
+        return active + ", " + success + ", " + failure;
+    }
+}
Property changes on: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/Counters.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/EndpointMXBean.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/EndpointMXBean.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/EndpointMXBean.java	2010-03-25 03:35:27 UTC (rev 5835)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.remoting3.management;
+
+import java.util.List;
+
+
+public interface EndpointMXBean {
+    Counters getRequestCounters();
+    Counters getClientCounters();
+    
+    List<ServiceInfo> getServices();
+}
Property changes on: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/EndpointMXBean.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java	2010-03-25 03:35:27 UTC (rev 5835)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.remoting3.management;
+
+public interface ManagedCloseable {
+    void close();
+    void forceClose();
+}
Property changes on: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ManagedCloseable.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native
Added: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ServiceInfo.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ServiceInfo.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ServiceInfo.java	2010-03-25 03:35:27 UTC (rev 5835)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.remoting3.management;
+
+import java.beans.ConstructorProperties;
+import java.util.Map;
+
+public class ServiceInfo {
+    private final String instanceName;
+    private final String serviceType;
+    private final String requestType;
+    private final String replyType;
+    private final Map<String, String> options;
+    
+    @ConstructorProperties({
+        "instanceName", "serviceType", "requestType", "replyType", "options"})
+    public ServiceInfo(
+            String instanceName, String serviceType,
+            String requestType, String replyType, Map<String, String> options) {
+        this.instanceName = instanceName;
+        this.serviceType = serviceType;
+        this.requestType = requestType;
+        this.replyType = replyType;
+        this.options = options;
+    }
+    
+    public String getInstanceName() {
+        return instanceName;
+    }
+    
+    public String getServiceType() {
+        return serviceType;
+    }
+    
+    public String getRequestType() {
+        return requestType;
+    }
+    
+    public String getReplyType() {
+        return replyType;
+    }
+    
+    public Map<String, String> getOptions() {
+        return options;
+    }
+}
Property changes on: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management/ServiceInfo.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5834 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: david.lloyd(a)jboss.com
Date: 2010-03-23 22:31:56 -0400 (Tue, 23 Mar 2010)
New Revision: 5834
Modified:
   remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java
Log:
JBREM-1213: send an auth reject if the SASL server fails to create
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java	2010-03-18 03:22:46 UTC (rev 5833)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java	2010-03-24 02:31:56 UTC (rev 5834)
@@ -66,7 +66,14 @@
                     if (serverFactory != null) {
                         log.trace("Selected SASL mechanism %s", name);
                         final String realm = connectionProviderContext.getEndpoint().getName();
-                        final SaslServer server = serverFactory.createSaslServer(name, "remote", realm, saslPropertyMap, authenticationProvider.getCallbackHandler());
+                        final SaslServer server;
+                        try {
+                            server = serverFactory.createSaslServer(name, "remote", realm, saslPropertyMap, authenticationProvider.getCallbackHandler());
+                        } catch (IOException e) {
+                            log.warn("Failed to create SASL server for mechanism \"%s\": %s", name, e);
+                            rejectAuth();
+                            return;
+                        }
                         remoteConnection.setMessageHandler(new ServerAuthenticationHandler(remoteConnection, server, connectionProviderContext, this));
                         log.trace("Sending initial challenge");
                         final byte[] resp;
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5833 - in remoting3/trunk: samples and 1 other directories.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: trustin
Date: 2010-03-17 23:22:46 -0400 (Wed, 17 Mar 2010)
New Revision: 5833
Modified:
   remoting3/trunk/jboss-remoting/
   remoting3/trunk/samples/
   remoting3/trunk/taglet/
Log:
Added Eclipse project files to svn:ignore
Property changes on: remoting3/trunk/jboss-remoting
___________________________________________________________________
Name: svn:ignore
   - *.iml
target
   + *.iml
target
.settings
.classpath
.project
Property changes on: remoting3/trunk/samples
___________________________________________________________________
Name: svn:ignore
   - *.iml
target
   + *.iml
target
.settings
.classpath
.project
Property changes on: remoting3/trunk/taglet
___________________________________________________________________
Name: svn:ignore
   - *.iml
target
   + *.iml
target
.settings
.classpath
.project
                                
                         
                        
                                
                                15 years, 7 months
                        
                        
                 
         
 
        
            
        
        
        
                
                        
                        
                                
                                
                                        
                                                
                                        
                                        
                                        JBoss Remoting SVN: r5832 - remoting3/trunk.
                                
                                
                                
                                    
                                        by jboss-remoting-commits@lists.jboss.org
                                    
                                
                                
                                        Author: trustin
Date: 2010-03-17 23:03:49 -0400 (Wed, 17 Mar 2010)
New Revision: 5832
Modified:
   remoting3/trunk/pom.xml
Log:
Fixed a build problem where the actual source version is 1.6 while the compiler plugin's properties were set to 1.5
Modified: remoting3/trunk/pom.xml
===================================================================
--- remoting3/trunk/pom.xml	2010-03-18 02:46:34 UTC (rev 5831)
+++ remoting3/trunk/pom.xml	2010-03-18 03:03:49 UTC (rev 5832)
@@ -104,6 +104,14 @@
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-deploy-plugin</artifactId>
                 <configuration>
                     <skip>true</skip>
                                
                         
                        
                                
                                15 years, 7 months