activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [1/3] activemq-artemis git commit: ARTEMIS-640 Allow config of cxn TTL check interval
Date Tue, 19 Jul 2016 15:06:19 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 7bf62ff66 -> d59299cc9


ARTEMIS-640 Allow config of cxn TTL check interval

Add connection-ttl-check-interval configuration attribute to allow
control of how frequently connection TTL checks are performed.


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

Branch: refs/heads/master
Commit: dc76e2a6a00964990fa50ec091d96473616aba87
Parents: 7bf62ff
Author: jbertram <jbertram@apache.org>
Authored: Mon Jul 18 16:34:22 2016 -0500
Committer: jbertram <jbertram@apache.org>
Committed: Mon Jul 18 17:06:26 2016 -0500

----------------------------------------------------------------------
 .../api/config/ActiveMQDefaultConfiguration.java    |  7 +++++++
 .../activemq/artemis/core/config/Configuration.java |  4 ++++
 .../artemis/core/config/impl/ConfigurationImpl.java | 16 ++++++++++++++++
 .../deployers/impl/FileConfigurationParser.java     |  2 ++
 .../main/resources/schema/artemis-configuration.xsd |  8 ++++++++
 .../core/config/impl/FileConfigurationTest.java     |  1 +
 .../resources/ConfigurationTest-full-config.xml     |  1 +
 docs/user-manual/en/configuration-index.md          |  1 +
 docs/user-manual/en/connection-ttl.md               |  5 +++++
 .../integration/client/IncompatibleVersionTest.java |  3 +--
 .../integration/client/TemporaryQueueTest.java      |  5 ++---
 .../tests/integration/remoting/PingTest.java        |  3 +--
 12 files changed, 49 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
index e8fe1c5..b95e515 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
@@ -423,6 +423,9 @@ public final class ActiveMQDefaultConfiguration {
    // Default large messages table name, used with Database storage type
    private static final String DEFAULT_LARGE_MESSAGES_TABLE_NAME = "LARGE_MESSAGES";
 
+   // Default period to wait between connection TTL checks
+   public static final long DEFAULT_CONNECTION_TTL_CHECK_INTERVAL = 2000;
+
    /**
     * If true then the ActiveMQ Artemis Server will make use of any Protocol Managers that
are in available on the classpath. If false then only the core protocol will be available,
unless in Embedded mode where users can inject their own Protocol Managers.
     */
@@ -1130,4 +1133,8 @@ public final class ActiveMQDefaultConfiguration {
    public static String getDefaultLargeMessagesTableName() {
       return DEFAULT_LARGE_MESSAGES_TABLE_NAME;
    }
+
+   public static long getDefaultConnectionTtlCheckInterval() {
+      return DEFAULT_CONNECTION_TTL_CHECK_INTERVAL;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index 8eb7f10..400709e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -955,4 +955,8 @@ public interface Configuration {
    /** It will return all the connectors in a toString manner for debug purposes. */
    String debugConnectors();
 
+   Configuration setConnectionTtlCheckInterval(long connectionTtlCheckInterval);
+
+   long getConnectionTtlCheckInterval();
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 6ecdc77..8f1f6f5 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -239,6 +239,8 @@ public class ConfigurationImpl implements Configuration, Serializable
{
 
    protected boolean populateValidatedUser = ActiveMQDefaultConfiguration.isDefaultPopulateValidatedUser();
 
+   private long connectionTtlCheckInterval = ActiveMQDefaultConfiguration.getDefaultConnectionTtlCheckInterval();
+
    /**
     * Parent folder for all data folders.
     */
@@ -1366,6 +1368,17 @@ public class ConfigurationImpl implements Configuration, Serializable
{
    }
 
    @Override
+   public long getConnectionTtlCheckInterval() {
+      return connectionTtlCheckInterval;
+   }
+
+   @Override
+   public ConfigurationImpl setConnectionTtlCheckInterval(long connectionTtlCheckInterval)
{
+      this.connectionTtlCheckInterval = connectionTtlCheckInterval;
+      return this;
+   }
+
+   @Override
    public int hashCode() {
       final int prime = 31;
       int result = 1;
@@ -1440,6 +1453,7 @@ public class ConfigurationImpl implements Configuration, Serializable
{
       result = prime * result + (wildcardRoutingEnabled ? 1231 : 1237);
       result = prime * result + (resolveProtocols ? 1231 : 1237);
       result = prime * result + (int) (journalLockAcquisitionTimeout ^ (journalLockAcquisitionTimeout
>>> 32));
+      result = prime * result + (int) (connectionTtlCheckInterval ^ (connectionTtlCheckInterval
>>> 32));
       return result;
    }
 
@@ -1692,6 +1706,8 @@ public class ConfigurationImpl implements Configuration, Serializable
{
          return false;
       if (journalLockAcquisitionTimeout != other.journalLockAcquisitionTimeout)
          return false;
+      if (connectionTtlCheckInterval != other.connectionTtlCheckInterval)
+         return false;
       return true;
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index deda1ad..e884c31 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -278,6 +278,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       config.setPopulateValidatedUser(getBoolean(e, "populate-validated-user", config.isPopulateValidatedUser()));
 
+      config.setConnectionTtlCheckInterval(getLong(e, "connection-ttl-check-interval", config.getConnectionTtlCheckInterval(),
Validators.GT_ZERO));
+
       // parsing cluster password
       String passwordText = getString(e, "cluster-password", null, Validators.NO_CHECK);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 53e5aa8..5ac86a0 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -238,6 +238,14 @@
             </xsd:annotation>
          </xsd:element>
 
+         <xsd:element name="connection-ttl-check-interval" type="xsd:long" default="2000"
maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  how often (in ms) to check connections for ttl violation
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+
          <xsd:element name="async-connection-execution-enabled" type="xsd:boolean" default="true"
maxOccurs="1"
                       minOccurs="0">
             <xsd:annotation>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index 3f4edd8..27c997f 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -103,6 +103,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       Assert.assertEquals(true, conf.isGracefulShutdownEnabled());
       Assert.assertEquals(12345, conf.getGracefulShutdownTimeout());
       Assert.assertEquals(true, conf.isPopulateValidatedUser());
+      Assert.assertEquals(98765, conf.getConnectionTtlCheckInterval());
 
       Assert.assertEquals("largemessagesdir", conf.getLargeMessagesDirectory());
       Assert.assertEquals(95, conf.getMemoryWarningThreshold());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 8bd540d..3639da4 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -51,6 +51,7 @@
       <id-cache-size>127</id-cache-size>
       <persist-id-cache>true</persist-id-cache>
       <populate-validated-user>true</populate-validated-user>
+      <connection-ttl-check-interval>98765</connection-ttl-check-interval>
       <remoting-incoming-interceptors>
          <class-name>org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor1</class-name>
          <class-name>org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor2</class-name>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/docs/user-manual/en/configuration-index.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/configuration-index.md b/docs/user-manual/en/configuration-index.md
index 57b36e0..bf4461c 100644
--- a/docs/user-manual/en/configuration-index.md
+++ b/docs/user-manual/en/configuration-index.md
@@ -35,6 +35,7 @@ Name | Description
 [cluster-password](clusters.md "Clusters")                                              
                                               |   Cluster password. It applies to all cluster
configurations.
 [cluster-user](clusters.md "Clusters")                                                  
                                               |   Cluster username. It applies to all cluster
configurations.
 [connection-ttl-override](connection-ttl.md)                                            
                                                           |   if set, this will override
how long (in ms) to keep a connection alive without receiving a ping. -1 disables this setting.
Default -1
+[connection-ttl-check-period](connection-ttl.md)                                        
                                                           |   how often (in ms) to check
connections for ttl violation. Default 2000
 [connectors.connector](configuring-transports.md "Understanding Connectors") | The URL for
the connector. This is a list
 [create-bindings-dir](persistence.md "Configuring the bindings journal") |  true means that
the server will create the bindings directory on start up. Default=true
 [create-journal-dir](persistence.md)                                             |  true
means that the journal directory will be created. Default=true

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/docs/user-manual/en/connection-ttl.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/connection-ttl.md b/docs/user-manual/en/connection-ttl.md
index c24b5ac..f4b6738 100644
--- a/docs/user-manual/en/connection-ttl.md
+++ b/docs/user-manual/en/connection-ttl.md
@@ -114,6 +114,11 @@ server side. This can be done by specifying the
 The default value for `connection-ttl-override` is `-1` which means "do
 not override" (i.e. let clients use their own values).
 
+The logic to check connections for TTL violations runs periodically on
+the broker. By default, the checks are done every 2,000 milliseconds.
+However, this can be changed if necessary by using the 
+`connection-ttl-check-interval` attribute.
+
 ## Closing core sessions or JMS connections that you have failed to close
 
 As previously discussed, it's important that all core client sessions

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
index 21905df..e2c3ae5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
@@ -37,7 +37,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionMessage;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage;
-import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.core.version.impl.VersionImpl;
@@ -162,7 +161,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
             fail("Invalid Exception type:" + e.getType());
          }
          long start = System.currentTimeMillis();
-         while (System.currentTimeMillis() < start + 3 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL)
{
+         while (System.currentTimeMillis() < start + 3 * server.getConfiguration().getConnectionTtlCheckInterval())
{
             if (server.getConnectionCount() == 0) {
                break;
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java
index 9503ddb..a25805c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java
@@ -37,7 +37,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl;
 import org.apache.activemq.artemis.core.remoting.CloseListener;
-import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
@@ -475,7 +474,7 @@ public class TemporaryQueueTest extends SingleServerTestBase {
       session = sf.createSession(false, true, true);
 
       session.createTemporaryQueue(address, queue);
-      assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2
* RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL, TimeUnit.MILLISECONDS));
+      assertTrue("server has not received any ping from the client", pingOnServerLatch.await(2
* server.getConfiguration().getConnectionTtlCheckInterval(), TimeUnit.MILLISECONDS));
       assertEquals(1, server.getConnectionCount());
 
       RemotingConnection remotingConnection = server.getRemotingService().getConnections().iterator().next();
@@ -490,7 +489,7 @@ public class TemporaryQueueTest extends SingleServerTestBase {
       ((ClientSessionInternal) session).getConnection().fail(new ActiveMQInternalErrorException("simulate
a client failure"));
 
       // let some time for the server to clean the connections
-      assertTrue("server has not closed the connection", serverCloseLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL
+ 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
+      assertTrue("server has not closed the connection", serverCloseLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval()
+ 2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
 
       // The next getCount will be asynchronously done at the end of failure. We will wait
some time until it has reached there.
       for (long timeout = System.currentTimeMillis() + 5000; timeout > System.currentTimeMillis()
&& server.getConnectionCount() > 0; ) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dc76e2a6/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java
index ed4506f..564c6b6 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/remoting/PingTest.java
@@ -31,7 +31,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
 import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
 import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.Ping;
 import org.apache.activemq.artemis.core.remoting.CloseListener;
-import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
 import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
@@ -397,7 +396,7 @@ public class PingTest extends ActiveMQTestBase {
       Assert.assertTrue(clientLatch.await(8 * PingTest.CLIENT_FAILURE_CHECK_PERIOD, TimeUnit.MILLISECONDS));
 
       // Server connection will be closed too, when client closes client side connection
after failure is detected
-      Assert.assertTrue(serverLatch.await(2 * RemotingServiceImpl.CONNECTION_TTL_CHECK_INTERVAL,
TimeUnit.MILLISECONDS));
+      Assert.assertTrue(serverLatch.await(2 * server.getConfiguration().getConnectionTtlCheckInterval(),
TimeUnit.MILLISECONDS));
 
       long start = System.currentTimeMillis();
       while (true) {


Mime
View raw message