[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:
parent
38fb9300c7
commit
699a7ca7ef
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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}>. " +
|
||||
"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);
|
||||
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 connectionName, String ttl, String checkPeriod);
|
||||
|
||||
@LogMessage(level = Logger.Level.ERROR)
|
||||
@Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT)
|
||||
|
|
|
@ -316,6 +316,11 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
{
|
||||
configuration = new ConfigurationImpl();
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfigurationUtils.validateConfiguration(configuration);
|
||||
}
|
||||
|
||||
if (mbeanServer == null)
|
||||
{
|
||||
// Just use JVM mbean server
|
||||
|
|
Loading…
Reference in New Issue