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-4951 Support multiple connection router occurrences with same policy #666

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -2049,7 +2049,7 @@
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:ID" use="required">
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
the name of the policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public void testFileConfiguration() {
}
}

assertEquals(5, conf.getConnectionRouters().size());
assertEquals(6, conf.getConnectionRouters().size());
for (ConnectionRouterConfiguration bc : conf.getConnectionRouters()) {
if (bc.getName().equals("simple-local")) {
assertEquals(bc.getKeyType(), KeyType.CLIENT_ID);
Expand All @@ -367,6 +367,13 @@ public void testFileConfiguration() {
assertFalse(bc.getPoolConfiguration().isLocalTargetEnabled());
assertEquals("connector1", bc.getPoolConfiguration().getStaticConnectors().get(0));
assertNull(bc.getPoolConfiguration().getDiscoveryGroupName());
} else if (bc.getName().equals("simple-router-connector2")) {
assertEquals(bc.getKeyType(), KeyType.USER_NAME);
assertNull(bc.getLocalTargetFilter());
assertEquals(bc.getPolicyConfiguration().getName(), FirstElementPolicy.NAME);
assertFalse(bc.getPoolConfiguration().isLocalTargetEnabled());
assertEquals("connector2", bc.getPoolConfiguration().getStaticConnectors().get(0));
assertNull(bc.getPoolConfiguration().getDiscoveryGroupName());
} else if (bc.getName().equals("consistent-hash-router")) {
assertEquals(bc.getKeyType(), KeyType.SNI_HOST);
assertEquals(bc.getKeyFilter(), "^[^.]+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,22 @@ public void deployLocalOnlyWithPolicy() throws Exception {

underTest.deployConnectionRouter(connectionRouterConfiguration);
}

@Test
public void deploy2LocalOnlyWithSamePolicy() throws Exception {

ManagementService mockManagementService = Mockito.mock(ManagementService.class);
Mockito.when(mockServer.getManagementService()).thenReturn(mockManagementService);

ConnectionRouterConfiguration connectionRouterConfiguration = new ConnectionRouterConfiguration();
connectionRouterConfiguration.setName("partition-local-consistent-hash").setKeyType(KeyType.CLIENT_ID).setLocalTargetFilter(String.valueOf(2));
NamedPropertyConfiguration policyConfig = new NamedPropertyConfiguration()
.setName(ConsistentHashModuloPolicy.NAME)
.setProperties(Collections.singletonMap(ConsistentHashModuloPolicy.MODULO, String.valueOf(2)));
connectionRouterConfiguration.setPolicyConfiguration(policyConfig);
underTest.deployConnectionRouter(connectionRouterConfiguration);

connectionRouterConfiguration.setName("partition-local-consistent-hash-bis");
underTest.deployConnectionRouter(connectionRouterConfiguration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@
</static-connectors>
</pool>
</connection-router>
<connection-router name="simple-router-connector2">
<key-type>USER_NAME</key-type>
<policy name="FIRST_ELEMENT"/>
<pool>
<static-connectors>
<connector-ref>connector2</connector-ref>
</static-connectors>
</pool>
</connection-router>
<connection-router name="consistent-hash-router">
<key-type>SNI_HOST</key-type>
<key-filter>^[^.]+</key-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
</static-connectors>
</pool>
</connection-router>
<connection-router name="simple-router-connector2">
<key-type>USER_NAME</key-type>
<policy name="FIRST_ELEMENT"/>
<pool>
<static-connectors>
<connector-ref>connector2</connector-ref>
</static-connectors>
</pool>
</connection-router>
<connection-router name="consistent-hash-router">
<key-type>SNI_HOST</key-type>
<key-filter>^[^.]+</key-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
</static-connectors>
</pool>
</connection-router>
<connection-router name="simple-router-connector2">
<key-type>USER_NAME</key-type>
<policy name="FIRST_ELEMENT"/>
<pool>
<static-connectors>
<connector-ref>connector2</connector-ref>
</static-connectors>
</pool>
</connection-router>
<connection-router name="consistent-hash-router">
<key-type>SNI_HOST</key-type>
<key-filter>^[^.]+</key-filter>
Expand Down