[ARTEMIS-147] Add WARN log when setting connection-ttl OR connection-ttl-override equal to check-period.

Now works when ARTEMIS is deployed in an application server as well as standalone.
This commit is contained in:
Ryan Emerson 2015-08-04 16:09:08 +01:00 committed by Clebert Suconic
parent 38fb9300c7
commit 699a7ca7ef
4 changed files with 36 additions and 19 deletions

View File

@ -24,6 +24,7 @@ import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration;
import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration;
import org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.cluster.ha.BackupPolicy;
import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy;
import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
@ -143,4 +144,29 @@ public final class ConfigurationUtils
}
return null;
}
// A method to check the passed Configuration object and warn users if semantically unwise parameters are present
public static void validateConfiguration(Configuration configuration)
{
// Warn if connection-ttl-override/connection-ttl == check-period
compareTTLWithCheckPeriod(configuration);
}
private static void compareTTLWithCheckPeriod(Configuration configuration)
{
for (ClusterConnectionConfiguration c : configuration.getClusterConfigurations())
compareTTLWithCheckPeriod(c.getName(), c.getConnectionTTL(), configuration.getConnectionTTLOverride(), c.getClientFailureCheckPeriod());
for (BridgeConfiguration c : configuration.getBridgeConfigurations())
compareTTLWithCheckPeriod(c.getName(), c.getConnectionTTL(), configuration.getConnectionTTLOverride(), c.getClientFailureCheckPeriod());
}
private static void compareTTLWithCheckPeriod(String name, long connectionTTL, long connectionTTLOverride, long checkPeriod)
{
if (connectionTTLOverride == checkPeriod)
ActiveMQServerLogger.LOGGER.connectionTTLEqualsCheckPeriod(name, "connection-ttl-override", "check-period");
if (connectionTTL == checkPeriod)
ActiveMQServerLogger.LOGGER.connectionTTLEqualsCheckPeriod(name, "connection-ttl", "check-period");
}
}

View File

@ -1525,9 +1525,6 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
}
}
// Warn if connection-ttl-override/connection-ttl == check-period
compareTTLWithCheckPeriod(mainConfig, connectionTTL, clientFailureCheckPeriod);
ClusterConnectionConfiguration config = new ClusterConnectionConfiguration()
.setName(name)
.setAddress(address)
@ -1689,8 +1686,6 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
}
}
// Warn if connection-ttl-override/connection-ttl == check-period
compareTTLWithCheckPeriod(mainConfig, connectionTTL, clientFailureCheckPeriod);
BridgeConfiguration config = new BridgeConfiguration()
.setName(name)
@ -1811,13 +1806,4 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
.setParams(params)
.setName(name);
}
private void compareTTLWithCheckPeriod(final Configuration config, final long connectionTTL, final long checkPeriod)
{
if (config.getConnectionTTLOverride() == checkPeriod)
ActiveMQServerLogger.LOGGER.connectionTTLEqualsCheckPeriod("connection-ttl-override", "check-period");
if (connectionTTL == checkPeriod)
ActiveMQServerLogger.LOGGER.connectionTTLEqualsCheckPeriod("connection-ttl", "check-period");
}
}

View File

@ -1168,11 +1168,11 @@ public interface ActiveMQServerLogger extends BasicLogger
@LogMessage(level = Logger.Level.WARN)
@Message(id = 222202,
value = "<{0}> should not be set to the same value as <{1}>. " +
value = "{0}: <{1}> should not be set to the same value as <{2}>. " +
"If a system is under high load, or there is a minor network delay, " +
"there is a high probability of a cluster split/failure due to connection timeout.",
format = Message.Format.MESSAGE_FORMAT)
void connectionTTLEqualsCheckPeriod(String ttl, String checkPeriod);
void connectionTTLEqualsCheckPeriod(String connectionName, String ttl, String checkPeriod);
@LogMessage(level = Logger.Level.ERROR)
@Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT)

View File

@ -316,6 +316,11 @@ public class ActiveMQServerImpl implements ActiveMQServer
{
configuration = new ConfigurationImpl();
}
else
{
ConfigurationUtils.validateConfiguration(configuration);
}
if (mbeanServer == null)
{
// Just use JVM mbean server