Skip to content
Merged
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 @@ -16,6 +16,7 @@
import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.annotations.Beta;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -131,9 +132,10 @@ public CompletableFuture<Void> sendEvent(MqttEvent event) {

protected CompletableFuture<SystemTopicClient.Reader<MqttEvent>> createReader() {
CompletableFuture<SystemTopicClient.Reader<MqttEvent>> result = new CompletableFuture<>();
Backoff backoff = new Backoff(1, TimeUnit.SECONDS,
3, TimeUnit.SECONDS,
10, TimeUnit.SECONDS);
Backoff backoff = Backoff.builder()
.initialDelay(Duration.ofSeconds(1))
.mandatoryStop(Duration.ofSeconds(10))
.maxBackoff(Duration.ofSeconds(3)).build();
RetryUtil.retryAsynchronously(systemTopicClient::newReaderAsync, backoff, pulsarService.getExecutor(), result);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.streamnative.pulsar.handlers.mqtt.common.utils.ConfigurationUtils;
import io.streamnative.pulsar.handlers.mqtt.proxy.MQTTProxyConfiguration;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -39,7 +40,6 @@
import org.apache.pulsar.client.util.ScheduledExecutorProvider;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.util.Backoff;
import org.apache.pulsar.common.util.BackoffBuilder;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.metadata.api.MetadataCache;
import org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData;
Expand Down Expand Up @@ -121,7 +121,7 @@ && isLookupMQTTBroker(lookupPair, brokerData.get()))
})
.thenAccept(future::complete)
.exceptionally(e -> {
long nextDelay = Math.min(backoff.next(), remainingTime.get());
long nextDelay = Math.min(backoff.next().toMillis(), remainingTime.get());
// skip retry scheduler when `TooManyRequestsException`
boolean isLookupThrottling = !PulsarClientException.isRetriableError(e.getCause())
|| e.getCause() instanceof PulsarClientException.TooManyRequestsException
Expand All @@ -145,11 +145,10 @@ && isLookupMQTTBroker(lookupPair, brokerData.get()))
public CompletableFuture<InetSocketAddress> findBroker(TopicName topicName) {
CompletableFuture<InetSocketAddress> lookupResult = new CompletableFuture<>();
AtomicLong opTimeoutMs = new AtomicLong(proxyConfig.getLookupOperationTimeoutMs());
Backoff backoff = new BackoffBuilder()
.setInitialTime(100, TimeUnit.MILLISECONDS)
.setMandatoryStop(opTimeoutMs.get() * 2, TimeUnit.MILLISECONDS)
.setMax(proxyConfig.getMaxLookupIntervalMs(), TimeUnit.MILLISECONDS)
.create();
Backoff backoff = Backoff.builder()
.initialDelay(Duration.ofMillis(100))
.mandatoryStop(Duration.ofMillis(opTimeoutMs.get() * 2))
.maxBackoff(Duration.ofMillis(proxyConfig.getMaxLookupIntervalMs())).build();

findBroker(topicName, backoff, opTimeoutMs, lookupResult);
return lookupResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
import org.mockito.Mockito;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;


@Test(enabled = false)
@Ignore
public class AdapterChannelTest extends MQTTTestBase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@
import org.fusesource.mqtt.client.Topic;
import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

/**
* Integration tests for MQTT protocol handler with proxy.
*/
@Slf4j
@Ignore
@Test(enabled = false)
public class ProxyTest extends MQTTTestBase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@
import org.fusesource.mqtt.client.QoS;
import org.fusesource.mqtt.client.Topic;
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

@Test(enabled = false)
@Ignore
public class ProxyMtlsTest extends MQTTTestBase {


Expand Down
Loading