You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/03/31 21:52:25 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1087 Make InVM buffer pooling configurable

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 848090fad -> 05ca44d90


ARTEMIS-1087 Make InVM buffer pooling configurable


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8760b3dd
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8760b3dd
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8760b3dd

Branch: refs/heads/master
Commit: 8760b3ddfd0ea52a0417ce91b6abe4840ca5ddca
Parents: 848090f
Author: Martyn Taylor <mt...@redhat.com>
Authored: Fri Mar 31 13:13:46 2017 +0100
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Fri Mar 31 18:56:07 2017 +0100

----------------------------------------------------------------------
 .../activemq/artemis/api/core/ActiveMQBuffers.java       |  2 --
 .../artemis/core/remoting/impl/invm/InVMAcceptor.java    |  5 +++++
 .../artemis/core/remoting/impl/invm/InVMConnection.java  | 11 ++++++++++-
 .../artemis/core/remoting/impl/invm/InVMConnector.java   |  6 ++++++
 .../core/remoting/impl/invm/TransportConstants.java      |  4 ++++
 5 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8760b3dd/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
index 25fcfea..d14f9dc 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQBuffers.java
@@ -28,7 +28,6 @@ import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
  */
 public final class ActiveMQBuffers {
 
-
    private static final PooledByteBufAllocator ALLOCATOR = PooledByteBufAllocator.DEFAULT;
 
    /**
@@ -45,7 +44,6 @@ public final class ActiveMQBuffers {
       return new ChannelBufferWrapper(ALLOCATOR.heapBuffer(size),true, true);
    }
 
-
    /**
     * Creates a <em>self-expanding</em> ActiveMQBuffer filled with the given byte array
     *

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8760b3dd/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java
index 9c26b47..398baa4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java
@@ -72,6 +72,8 @@ public final class InVMAcceptor extends AbstractAcceptor {
 
    private static final Logger logger = Logger.getLogger(InVMAcceptor.class);
 
+   private final boolean enableBufferPooling;
+
    public InVMAcceptor(final String name,
                        final ClusterConnection clusterConnection,
                        final Map<String, Object> configuration,
@@ -96,6 +98,8 @@ public final class InVMAcceptor extends AbstractAcceptor {
       executorFactory = new OrderedExecutorFactory(threadPool);
 
       connectionsAllowed = ConfigurationHelper.getLongProperty(TransportConstants.CONNECTIONS_ALLOWED, TransportConstants.DEFAULT_CONNECTIONS_ALLOWED, configuration);
+
+      enableBufferPooling = ConfigurationHelper.getBooleanProperty(TransportConstants.BUFFER_POOLING, TransportConstants.DEFAULT_BUFFER_POOLING, configuration);
    }
 
    @Override
@@ -222,6 +226,7 @@ public final class InVMAcceptor extends AbstractAcceptor {
       Listener connectionListener = new Listener(connector);
 
       InVMConnection inVMConnection = new InVMConnection(id, connectionID, remoteHandler, connectionListener, clientExecutor, defaultActiveMQPrincipal);
+      inVMConnection.setEnableBufferPooling(enableBufferPooling);
 
       connectionListener.connectionCreated(this, inVMConnection, protocolMap.get(ActiveMQClient.DEFAULT_CORE_PROTOCOL));
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8760b3dd/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
index f49aade..889493e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
@@ -63,6 +63,8 @@ public class InVMConnection implements Connection {
 
    private RemotingConnection protocolConnection;
 
+   private boolean bufferPoolingEnabled = TransportConstants.DEFAULT_BUFFER_POOLING;
+
    public InVMConnection(final int serverID,
                          final BufferHandler handler,
                          final BaseConnectionLifeCycleListener listener,
@@ -97,6 +99,10 @@ public class InVMConnection implements Connection {
       this.defaultActiveMQPrincipal = defaultActiveMQPrincipal;
    }
 
+   public void setEnableBufferPooling(boolean enableBufferPooling) {
+      this.bufferPoolingEnabled = enableBufferPooling;
+   }
+
    @Override
    public void forceClose() {
       // no op
@@ -146,7 +152,10 @@ public class InVMConnection implements Connection {
 
    @Override
    public ActiveMQBuffer createTransportBuffer(final int size) {
-      return ActiveMQBuffers.pooledBuffer(size);
+      if (bufferPoolingEnabled) {
+         return ActiveMQBuffers.pooledBuffer( size );
+      }
+      return ActiveMQBuffers.dynamicBuffer( size );
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8760b3dd/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
index 907fb40..51e917d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
@@ -95,6 +95,8 @@ public class InVMConnector extends AbstractConnector {
 
    private final Executor closeExecutor;
 
+   private final boolean bufferPoolingEnabled;
+
    private static ExecutorService threadPoolExecutor;
 
    public static synchronized void resetThreadPool() {
@@ -126,6 +128,8 @@ public class InVMConnector extends AbstractConnector {
 
       id = ConfigurationHelper.getIntProperty(TransportConstants.SERVER_ID_PROP_NAME, 0, configuration);
 
+      bufferPoolingEnabled = ConfigurationHelper.getBooleanProperty(TransportConstants.BUFFER_POOLING, TransportConstants.DEFAULT_BUFFER_POOLING, configuration);
+
       this.handler = handler;
 
       this.closeExecutor = closeExecutor;
@@ -215,6 +219,8 @@ public class InVMConnector extends AbstractConnector {
                                                  final Executor serverExecutor) {
       // No acceptor on a client connection
       InVMConnection inVMConnection = new InVMConnection(id, handler, listener, serverExecutor);
+      inVMConnection.setEnableBufferPooling(bufferPoolingEnabled);
+
       listener.connectionCreated(null, inVMConnection, protocolManager);
       return inVMConnection;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8760b3dd/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/TransportConstants.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/TransportConstants.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/TransportConstants.java
index f8a5117..c02b0fd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/TransportConstants.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/TransportConstants.java
@@ -26,6 +26,10 @@ public final class TransportConstants {
 
    public static final long DEFAULT_CONNECTIONS_ALLOWED = -1L;
 
+   public static final String BUFFER_POOLING = "bufferPooling";
+
+   public static final boolean DEFAULT_BUFFER_POOLING = true;
+
    private TransportConstants() {
       // Utility class
    }


[2/2] activemq-artemis git commit: This closes #1166

Posted by cl...@apache.org.
This closes #1166


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/05ca44d9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/05ca44d9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/05ca44d9

Branch: refs/heads/master
Commit: 05ca44d901f4954bbec00f0785ea58e8c3b6b74c
Parents: 848090f 8760b3d
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 31 17:52:14 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Mar 31 17:52:14 2017 -0400

----------------------------------------------------------------------
 .../activemq/artemis/api/core/ActiveMQBuffers.java       |  2 --
 .../artemis/core/remoting/impl/invm/InVMAcceptor.java    |  5 +++++
 .../artemis/core/remoting/impl/invm/InVMConnection.java  | 11 ++++++++++-
 .../artemis/core/remoting/impl/invm/InVMConnector.java   |  6 ++++++
 .../core/remoting/impl/invm/TransportConstants.java      |  4 ++++
 5 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------