Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-4424 Unecessary AMQ212025 (not connected) when no nodes are c… #4610

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,10 @@ public String toString() {
return null;
}

ActiveMQClientLogger.LOGGER.errorConnectingToNodes(traceException);
if (logger.isTraceEnabled()) {
logger.trace("Could not connect to any nodes. throwing an error now.", new Exception("trace"));
}

throw ActiveMQClientMessageBundle.BUNDLE.cannotConnectToStaticConnectors2();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
import org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.uri.ServerLocatorParser;
import org.junit.Assert;
Expand All @@ -49,11 +51,11 @@ public void setUp() throws Exception {
super.setUp();
Configuration configuration = createDefaultConfig(isNetty());
server = createServer(false, configuration);
server.start();
}

@Test
public void testFailFastConnectOnClosing() throws Exception {
server.start();
CountDownLatch connectLatch = new CountDownLatch(1);
CountDownLatch subscribeLatch = new CountDownLatch(1);
AtomicBoolean connectTimedOut = new AtomicBoolean(false);
Expand Down Expand Up @@ -95,6 +97,7 @@ public void testFailFastConnectOnClosing() throws Exception {

@Test
public void testURL() throws Exception {
server.start();
ServerLocatorParser parser = new ServerLocatorParser();
// This URL was failing in some ConnectionFactoryTests.
// The issue seemed to be the # to be creating extra spaces on the parsing
Expand Down Expand Up @@ -124,6 +127,7 @@ public void testURL() throws Exception {

@Test
public void testSingleConnectorSingleServer() throws Exception {
server.start();
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
ClientSessionFactory csf = createSessionFactory(locator);
csf.close();
Expand All @@ -132,6 +136,7 @@ public void testSingleConnectorSingleServer() throws Exception {

@Test
public void testSingleConnectorSingleServerConnect() throws Exception {
server.start();
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
Expand All @@ -141,6 +146,7 @@ public void testSingleConnectorSingleServerConnect() throws Exception {

@Test
public void testMultipleConnectorSingleServerConnect() throws Exception {
server.start();
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())));
ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
Expand All @@ -150,6 +156,7 @@ public void testMultipleConnectorSingleServerConnect() throws Exception {

@Test
public void testMultipleConnectorSingleServerConnectReconnect() throws Exception {
server.start();
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())));
locator.setReconnectAttempts(15);
ClientSessionFactoryInternal csf = locator.connect();
Expand All @@ -160,6 +167,7 @@ public void testMultipleConnectorSingleServerConnectReconnect() throws Exception

@Test
public void testMultipleConnectorSingleServerNoConnect() throws Exception {
server.start();
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty())));
ClientSessionFactoryInternal csf = null;
try {
Expand All @@ -176,6 +184,7 @@ public void testMultipleConnectorSingleServerNoConnect() throws Exception {

@Test
public void testMultipleConnectorSingleServerNoConnectAttemptReconnect() throws Exception {
server.start();
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty())));
locator.setReconnectAttempts(15);
CountDownLatch countDownLatch = new CountDownLatch(1);
Expand All @@ -189,6 +198,23 @@ public void testMultipleConnectorSingleServerNoConnectAttemptReconnect() throws
assertNull(target.csf);
}

@Test
public void testNoWarningWhenNotConnecting() throws Exception {
try (AssertionLoggerHandler handler = new AssertionLoggerHandler()) {
try (ServerLocatorImpl locator = (ServerLocatorImpl) ServerLocatorImpl.newLocator("tcp://localhost:61616")) {
locator.connect();
Assert.fail("Expected an exception");
} catch (Exception expected) {
}

// The connect operation used to log a warning and throw an exception.
// which will flood the logs when a server is being started for the first time.
// Having the exception thrown only should be enough.
Assert.assertFalse(handler.findText("AMQ212025"));
}
}


public boolean isNetty() {
return true;
}
Expand Down
Loading