Does the Cluster-level failover of pulsar have any requirements on the version of pulsar? Is version 2.10 or higher required? 2.9.4 Can it be used? #19818
|
I would like to know if there is a version requirement for the Cluster-level failover function of pulsar? What is the minimum supported version? |
Replies: 5 comments 1 reply
|
Auto cluster failover was introduced in the 2.10 release. It's a client-side feature, so you just need to have the client library to 2.10+, but you can use it with older brokers. |
|
@merlimat I tried to test with pulsar version 2.9.4, client library version 2.10.3, but it didn't work! public class PulsarTest {
public static void main(String[] args) {
String primaryUrl = "pulsar://10.0.87.203:6650";
String secondaryUrl = "pulsar://10.0.88.116:6650";
Map<String, Authentication> m = new HashMap<>();
m.put(secondaryUrl, AuthenticationFactory.token("xxxxx"));
ServiceUrlProvider failover = AutoClusterFailover.builder()
.primary(primaryUrl)
.secondary(List.of(secondaryUrl))
.failoverDelay(10, TimeUnit.SECONDS)
.switchBackDelay(30, TimeUnit.SECONDS)
.checkInterval(1000, TimeUnit.MILLISECONDS)
.secondaryAuthentication(m)
.build();
try {
PulsarClient client = PulsarClient.builder()
.serviceUrlProvider(failover)
.authentication(AuthenticationFactory.token("xxxxx"))
.build();
Producer<String> producer = client.newProducer(Schema.STRING)
.topic("public/default/t1")
.create();
long index = 0;
while (true) {
String msg = new String("hello-" + index);
producer.send(msg);
Thread.sleep(1000);
index = index + 1;
System.out.println(msg + " send ok");
}
} catch (Exception e) {
System.out.println("exit");
e.printStackTrace();
}
}
}Then I shut down all the Broker nodes of the main cluster, and no switchover occurred. Is there something wrong with the code? Or Broker requires special configuration ? |
|
@tianshimoyi Can you provide details log during the tests? |
|
@shoothzj @tisonkun Hi, My steps are as follows:
producer code: public class PulsarTest {
public static void main(String[] args) {
String primaryUrl = "pulsar://10.0.68.235:6650";
String secondaryUrl = "pulsar://10.0.64.134:6650";
Map<String,Authentication> m = new HashMap<>();
m.put(secondaryUrl,AuthenticationFactory.token("xxxx"));
ServiceUrlProvider failover = AutoClusterFailover.builder()
.primary(primaryUrl)
.secondary(List.of(secondaryUrl))
.failoverDelay(10, TimeUnit.SECONDS)
.switchBackDelay(30, TimeUnit.SECONDS)
.checkInterval(1000, TimeUnit.MILLISECONDS)
.secondaryAuthentication(m)
.build();
try {
PulsarClient client = PulsarClient.builder()
.serviceUrlProvider(failover)
.authentication(AuthenticationFactory.token("xxxx"))
.build();
Producer<String> producer = client.newProducer(Schema.STRING)
.topic("public/tcloud-log/test")
.create();
long index = 0;
while (true) {
String msg = "hello-" + index;
producer.send(msg);
Thread.sleep(1000);
index = index + 1;
System.out.println(msg + " send ok");
}
} catch (Exception e) {
System.out.println("exit");
e.printStackTrace();
}
}
}client version: 2.10.3 |


Auto cluster failover was introduced in the 2.10 release. It's a client-side feature, so you just need to have the client library to 2.10+, but you can use it with older brokers.