Polish gh-38559

See gh-39931
This commit is contained in:
Johnny Lim 2024-03-14 00:46:58 +09:00 committed by Moritz Halbritter
parent 736f712ba9
commit c5df4e3530
6 changed files with 15 additions and 11 deletions

View File

@ -901,7 +901,7 @@ public class PulsarProperties {
public static class Failover {
/**
* Cluster Failover Policy.
* Cluster failover policy.
*/
private FailoverPolicy failoverPolicy = FailoverPolicy.ORDER;
@ -909,7 +909,7 @@ public class PulsarProperties {
* Delay before the Pulsar client switches from the primary cluster to the backup
* cluster.
*/
private Duration failOverDelay;
private Duration failoverDelay;
/**
* Delay before the Pulsar client switches from the backup cluster to the primary
@ -923,7 +923,7 @@ public class PulsarProperties {
private Duration checkInterval;
/**
* List of backupClusters The backup cluster is chosen in the sequence of the
* List of backup clusters. The backup cluster is chosen in the sequence of the
* given list. If all backup clusters are available, the Pulsar client chooses the
* first backup cluster.
*/
@ -937,12 +937,12 @@ public class PulsarProperties {
this.failoverPolicy = failoverPolicy;
}
public Duration getFailOverDelay() {
return this.failOverDelay;
public Duration getFailoverDelay() {
return this.failoverDelay;
}
public void setFailOverDelay(Duration failOverDelay) {
this.failOverDelay = failOverDelay;
public void setFailoverDelay(Duration failoverDelay) {
this.failoverDelay = failoverDelay;
}
public Duration getSwitchBackDelay() {

View File

@ -83,7 +83,7 @@ final class PulsarPropertiesMapper {
map.from(connectionDetails::getBrokerUrl).to(autoClusterFailoverBuilder::primary);
map.from(secondaryAuths::keySet).as(ArrayList::new).to(autoClusterFailoverBuilder::secondary);
map.from(failoverProperties::getFailoverPolicy).to(autoClusterFailoverBuilder::failoverPolicy);
map.from(failoverProperties::getFailOverDelay).to(timeoutProperty(autoClusterFailoverBuilder::failoverDelay));
map.from(failoverProperties::getFailoverDelay).to(timeoutProperty(autoClusterFailoverBuilder::failoverDelay));
map.from(failoverProperties::getSwitchBackDelay)
.to(timeoutProperty(autoClusterFailoverBuilder::switchBackDelay));
map.from(failoverProperties::getCheckInterval).to(timeoutProperty(autoClusterFailoverBuilder::checkInterval));

View File

@ -2060,6 +2060,10 @@
"name": "spring.neo4j.uri",
"defaultValue": "bolt://localhost:7687"
},
{
"name": "spring.pulsar.client.failover.failover-policy",
"defaultValue": "order"
},
{
"name": "spring.pulsar.function.enabled",
"type": "java.lang.Boolean",

View File

@ -144,7 +144,7 @@ class PulsarConfigurationTests {
customizeAction.accept(pulsarClientBuilderCustomizer, target);
InOrder ordered = inOrder(target);
ordered.verify(target).serviceUrlProvider(Mockito.any(AutoClusterFailover.class));
assertThat(pulsarProperties.getClient().getFailover().getFailOverDelay())
assertThat(pulsarProperties.getClient().getFailover().getFailoverDelay())
.isEqualTo(Duration.ofSeconds(15));
assertThat(pulsarProperties.getClient().getFailover().getSwitchBackDelay())
.isEqualTo(Duration.ofSeconds(30));

View File

@ -112,7 +112,7 @@ class PulsarPropertiesMapperTests {
properties.getClient().setServiceUrl("https://used.example.com");
properties.getClient().getFailover().setFailoverPolicy(FailoverPolicy.ORDER);
properties.getClient().getFailover().setCheckInterval(Duration.ofSeconds(5));
properties.getClient().getFailover().setFailOverDelay(Duration.ofSeconds(30));
properties.getClient().getFailover().setFailoverDelay(Duration.ofSeconds(30));
properties.getClient().getFailover().setSwitchBackDelay(Duration.ofSeconds(30));
properties.getClient().getFailover().setBackupClusters(List.of(backupCluster1, backupCluster2));
PulsarConnectionDetails connectionDetails = mock(PulsarConnectionDetails.class);

View File

@ -105,7 +105,7 @@ class PulsarPropertiesTests {
Failover failoverProperties = properties.getFailover();
List<BackupCluster> backupClusters = properties.getFailover().getBackupClusters();
assertThat(properties.getServiceUrl()).isEqualTo("my-service-url");
assertThat(failoverProperties.getFailOverDelay()).isEqualTo(Duration.ofMillis(30000));
assertThat(failoverProperties.getFailoverDelay()).isEqualTo(Duration.ofMillis(30000));
assertThat(failoverProperties.getSwitchBackDelay()).isEqualTo(Duration.ofMillis(15000));
assertThat(failoverProperties.getCheckInterval()).isEqualTo(Duration.ofMillis(1000));
assertThat(backupClusters.get(0).getServiceUrl()).isEqualTo("backup-service-url-1");