[pulsar-broker] Fix: unblock stuck thread on update-partition api
package org.apache.pulsar.broker.admin.impl;
import static org.apache.pulsar.broker.cache.ConfigurationCacheService.POLICIES;
+import static org.apache.pulsar.broker.resources.PulsarResources.DEFAULT_OPERATION_TIMEOUT_SEC;
import static org.apache.pulsar.common.util.Codec.decode;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.zafarkhaja.semver.Version;
@@ -483,7 +484,7 @@ public class PersistentTopicsBase extends AdminResource {
throw new RestException(Status.FORBIDDEN, "Local cluster is not part of replicate cluster list");
}
try {
- createSubscriptions(topicName, numPartitions).get();
+ createSubscriptions(topicName, numPartitions).get(DEFAULT_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS);
} catch (Exception e) {
if (e.getCause() instanceof RestException) {
throw (RestException) e.getCause();
@@ -512,7 +513,7 @@ public class PersistentTopicsBase extends AdminResource {
return null;
});
try {
- updatePartition.get();
+ updatePartition.get(DEFAULT_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("{} Failed to update number of partitions in zk for topic {} and partitions {}",
clientAppId(), topicName, numPartitions, e);
@@ -529,8 +530,8 @@ public class PersistentTopicsBase extends AdminResource {
throw new RestException(Status.NOT_ACCEPTABLE, "Number of partitions should be more than 0");
}
try {
- tryCreatePartitionsAsync(numPartitions).get();
- updatePartitionedTopic(topicName, numPartitions).get();
+ tryCreatePartitionsAsync(numPartitions).get(DEFAULT_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS);
+ updatePartitionedTopic(topicName, numPartitions).get(DEFAULT_OPERATION_TIMEOUT_SEC, TimeUnit.SECONDS);
} catch (Exception e) {
if (e.getCause() instanceof RestException) {
throw (RestException) e.getCause();
