Skip to content

Commit

Permalink
ARTEMIS-3831 scale-down w/jgroups fails if using same dg as cluster-c…
Browse files Browse the repository at this point in the history
…onnection

If both scale-down and cluster-connection are using the same JGroups
discovery-group then when the cluster-connection stops it will close the
underlying org.jgroups.JChannel and when the scale-down process tries to
use it to find a server it will fail.

This commit ensures that the JGroupsBroadcastEndpoint implementation of
BroadcastEndpoint#openClient initializes the channel if it has been
closed.
  • Loading branch information
jbertram authored and clebertsuconic committed Jan 22, 2024
1 parent 54f5dae commit 3dd50f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public synchronized void openClient() throws Exception {
if (clientOpened) {
return;
}
if (channel.getChannel() == null || channel.getChannel().isClosed()) {
initChannel();
}
internalOpen();
receiver = new JGroupsReceiver();
channel.addReceiver(receiver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ public void testSimpleBroadcastJGropus() throws Exception {
assertEqualsDiscoveryEntries(Arrays.asList(live1), entries);
}

@Test
public void testJGroupsOpenClientInitializesChannel() throws Exception {
JGroupsFileBroadcastEndpointFactory factory = new JGroupsFileBroadcastEndpointFactory().setFile(TEST_JGROUPS_CONF_FILE).setChannelName("tst");
BroadcastEndpoint endpoint = factory.createBroadcastEndpoint();
endpoint.close(false);
endpoint.openClient();
endpoint.close(false);
}

/**
* Create one broadcaster and 100 receivers. Make sure broadcasting works.
* Then stop 99 of the receivers, the last one could still be working.
Expand Down

0 comments on commit 3dd50f8

Please sign in to comment.