Search in sources :

Example 81 with CompletableFuture

use of java.util.concurrent.CompletableFuture in project pulsar by yahoo.

the class BatchMessageTest method testSimpleBatchProducerConsumer.

@Test(dataProvider = "codec")
public void testSimpleBatchProducerConsumer(CompressionType compressionType) throws Exception {
    int numMsgs = 500;
    int numMsgsInBatch = numMsgs / 20;
    final String topicName = "persistent://prop/use/ns-abc/testSimpleBatchProducerConsumer";
    final String subscriptionName = "pc-sub-1" + compressionType.toString();
    Consumer consumer = pulsarClient.subscribe(topicName, subscriptionName);
    consumer.close();
    ProducerConfiguration producerConf = new ProducerConfiguration();
    producerConf.setCompressionType(compressionType);
    producerConf.setBatchingMaxPublishDelay(5000, TimeUnit.MILLISECONDS);
    producerConf.setBatchingMaxMessages(numMsgsInBatch);
    producerConf.setBatchingEnabled(true);
    Producer producer = pulsarClient.createProducer(topicName, producerConf);
    List<CompletableFuture<MessageId>> sendFutureList = Lists.newArrayList();
    for (int i = 0; i < numMsgs; i++) {
        byte[] message = ("msg-" + i).getBytes();
        Message msg = MessageBuilder.create().setContent(message).build();
        sendFutureList.add(producer.sendAsync(msg));
    }
    FutureUtil.waitForAll(sendFutureList).get();
    PersistentTopic topic = (PersistentTopic) pulsar.getBrokerService().getTopicReference(topicName);
    rolloverPerIntervalStats();
    assertTrue(topic.getProducers().values().iterator().next().getStats().msgRateIn > 0.0);
    assertEquals(topic.getPersistentSubscription(subscriptionName).getNumberOfEntriesInBacklog(), numMsgs / numMsgsInBatch);
    consumer = pulsarClient.subscribe(topicName, subscriptionName);
    Message lastunackedMsg = null;
    for (int i = 0; i < numMsgs; i++) {
        Message msg = consumer.receive(5, TimeUnit.SECONDS);
        assertNotNull(msg);
        if (i % 2 == 0) {
            consumer.acknowledgeCumulative(msg);
        } else {
            lastunackedMsg = msg;
        }
    }
    if (lastunackedMsg != null) {
        consumer.acknowledgeCumulative(lastunackedMsg);
    }
    Thread.sleep(100);
    assertEquals(topic.getPersistentSubscription(subscriptionName).getNumberOfEntriesInBacklog(), 0);
    consumer.close();
    producer.close();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Consumer(com.yahoo.pulsar.client.api.Consumer) Producer(com.yahoo.pulsar.client.api.Producer) Message(com.yahoo.pulsar.client.api.Message) PersistentTopic(com.yahoo.pulsar.broker.service.persistent.PersistentTopic) ProducerConfiguration(com.yahoo.pulsar.client.api.ProducerConfiguration) Test(org.testng.annotations.Test)

Example 82 with CompletableFuture

use of java.util.concurrent.CompletableFuture in project pulsar by yahoo.

the class ZookeeperCacheTest method testGlobalZooKeeperCache.

@Test
void testGlobalZooKeeperCache() throws Exception {
    OrderedSafeExecutor executor = new OrderedSafeExecutor(1, "test");
    ScheduledExecutorService scheduledExecutor = new ScheduledThreadPoolExecutor(1);
    MockZooKeeper zkc = MockZooKeeper.newInstance();
    ZooKeeperClientFactory zkClientfactory = new ZooKeeperClientFactory() {

        @Override
        public CompletableFuture<ZooKeeper> create(String serverList, SessionType sessionType, int zkSessionTimeoutMillis) {
            return CompletableFuture.completedFuture(zkc);
        }
    };
    GlobalZooKeeperCache zkCacheService = new GlobalZooKeeperCache(zkClientfactory, -1, "", executor, scheduledExecutor);
    zkCacheService.start();
    zkClient = (MockZooKeeper) zkCacheService.getZooKeeper();
    ZooKeeperDataCache<String> zkCache = new ZooKeeperDataCache<String>(zkCacheService) {

        @Override
        public String deserialize(String key, byte[] content) throws Exception {
            return new String(content);
        }
    };
    // Create callback counter
    AtomicInteger notificationCount = new AtomicInteger(0);
    ZooKeeperCacheListener<String> counter = (path, data, stat) -> {
        notificationCount.incrementAndGet();
    };
    // Register counter twice and unregister once, so callback should be counted correctly
    zkCache.registerListener(counter);
    zkCache.registerListener(counter);
    zkCache.unregisterListener(counter);
    String value = "test";
    zkClient.create("/my_test", value.getBytes(), null, null);
    assertEquals(zkCache.get("/my_test").get(), value);
    String newValue = "test2";
    // case 1: update and create znode directly and verify that the cache is retrieving the correct data
    assertEquals(notificationCount.get(), 0);
    zkClient.setData("/my_test", newValue.getBytes(), -1);
    zkClient.create("/my_test2", value.getBytes(), null, null);
    // Wait for the watch to be triggered
    while (notificationCount.get() < 1) {
        Thread.sleep(1);
    }
    // retrieve the data from the cache and verify it is the updated/new data
    assertEquals(zkCache.get("/my_test").get(), newValue);
    assertEquals(zkCache.get("/my_test2").get(), value);
    // The callback method should be called just only once
    assertEquals(notificationCount.get(), 1);
    // case 2: force the ZooKeeper session to be expired and verify that the data is still accessible
    zkCacheService.process(new WatchedEvent(Event.EventType.None, KeeperState.Expired, null));
    assertEquals(zkCache.get("/my_test").get(), newValue);
    assertEquals(zkCache.get("/my_test2").get(), value);
    // case 3: update the znode directly while the client session is marked as expired. Verify that the new updates
    // is not seen in the cache
    zkClient.create("/other", newValue.getBytes(), null, null);
    zkClient.failNow(Code.SESSIONEXPIRED);
    assertEquals(zkCache.get("/my_test").get(), newValue);
    assertEquals(zkCache.get("/my_test2").get(), value);
    try {
        zkCache.get("/other");
        fail("shuld have thrown exception");
    } catch (Exception e) {
    // Ok
    }
    // case 4: directly delete the znode while the session is not re-connected yet. Verify that the deletion is not
    // seen by the cache
    zkClient.failAfter(-1, Code.OK);
    zkClient.delete("/my_test2", -1);
    zkCacheService.process(new WatchedEvent(Event.EventType.None, KeeperState.SyncConnected, null));
    assertEquals(zkCache.get("/other").get(), newValue);
    // Make sure that the value is now directly from ZK and deleted
    assertFalse(zkCache.get("/my_test2").isPresent());
    // case 5: trigger a ZooKeeper disconnected event and make sure the cache content is not changed.
    zkCacheService.process(new WatchedEvent(Event.EventType.None, KeeperState.Disconnected, null));
    zkClient.create("/other2", newValue.getBytes(), null, null);
    // case 6: trigger a ZooKeeper SyncConnected event and make sure that the cache content is invalidated s.t. we
    // can see the updated content now
    zkCacheService.process(new WatchedEvent(Event.EventType.None, KeeperState.SyncConnected, null));
    // make sure that we get it
    assertEquals(zkCache.get("/other2").get(), newValue);
    zkCacheService.close();
    executor.shutdown();
    // Update shouldn't happen after the last check
    assertEquals(notificationCount.get(), 1);
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Event(org.apache.zookeeper.Watcher.Event) Assert.assertEquals(org.testng.Assert.assertEquals) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) TreeSet(java.util.TreeSet) Lists(com.google.common.collect.Lists) Assert(org.testng.Assert) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AssertJUnit.assertNull(org.testng.AssertJUnit.assertNull) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) KeeperState(org.apache.zookeeper.Watcher.Event.KeeperState) Assert.assertFalse(org.testng.Assert.assertFalse) ZooKeeper(org.apache.zookeeper.ZooKeeper) OrderedSafeExecutor(org.apache.bookkeeper.util.OrderedSafeExecutor) Assert.fail(org.testng.Assert.fail) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MockZooKeeper(org.apache.zookeeper.MockZooKeeper) WatchedEvent(org.apache.zookeeper.WatchedEvent) Sets(com.google.common.collect.Sets) AssertJUnit.assertNotNull(org.testng.AssertJUnit.assertNotNull) Code(org.apache.zookeeper.KeeperException.Code) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MockZooKeeper(org.apache.zookeeper.MockZooKeeper) WatchedEvent(org.apache.zookeeper.WatchedEvent) ZooKeeper(org.apache.zookeeper.ZooKeeper) MockZooKeeper(org.apache.zookeeper.MockZooKeeper) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) OrderedSafeExecutor(org.apache.bookkeeper.util.OrderedSafeExecutor) Test(org.testng.annotations.Test)

Example 83 with CompletableFuture

use of java.util.concurrent.CompletableFuture in project pulsar by yahoo.

the class NamespaceService method searchForCandidateBroker.

private void searchForCandidateBroker(NamespaceBundle bundle, CompletableFuture<LookupResult> lookupFuture, boolean authoritative) {
    String candidateBroker = null;
    try {
        // check if this is Heartbeat or SLAMonitor namespace
        candidateBroker = checkHeartbeatNamespace(bundle);
        if (candidateBroker == null) {
            String broker = getSLAMonitorBrokerName(bundle);
            // checking if the broker is up and running
            if (broker != null && isBrokerActive(broker)) {
                candidateBroker = broker;
            }
        }
        if (candidateBroker == null) {
            if (!this.loadManager.isCentralized() || pulsar.getLeaderElectionService().isLeader()) {
                candidateBroker = getLeastLoadedFromLoadManager(bundle);
            } else {
                if (authoritative) {
                    // leader broker already assigned the current broker as owner
                    candidateBroker = pulsar.getWebServiceAddress();
                } else {
                    // forward to leader broker to make assignment
                    candidateBroker = pulsar.getLeaderElectionService().getCurrentLeader().getServiceUrl();
                }
            }
        }
    } catch (Exception e) {
        LOG.warn("Error when searching for candidate broker to acquire {}: {}", bundle, e.getMessage(), e);
        lookupFuture.completeExceptionally(e);
        return;
    }
    try {
        checkNotNull(candidateBroker);
        if (pulsar.getWebServiceAddress().equals(candidateBroker)) {
            // Load manager decided that the local broker should try to become the owner
            ownershipCache.tryAcquiringOwnership(bundle).thenAccept(ownerInfo -> {
                if (ownerInfo.isDisabled()) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Namespace bundle {} is currently being unloaded", bundle);
                    }
                    lookupFuture.completeExceptionally(new IllegalStateException(String.format("Namespace bundle %s is currently being unloaded", bundle)));
                } else {
                    pulsar.loadNamespaceDestinations(bundle);
                    lookupFuture.complete(new LookupResult(ownerInfo));
                }
            }).exceptionally(exception -> {
                LOG.warn("Failed to acquire ownership for namespace bundle {}: ", bundle, exception.getMessage(), exception);
                lookupFuture.completeExceptionally(new PulsarServerException("Failed to acquire ownership for namespace bundle " + bundle, exception));
                return null;
            });
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Redirecting to broker {} to acquire ownership of bundle {}", candidateBroker, bundle);
            }
            // Now setting the redirect url
            createLookupResult(candidateBroker).thenAccept(lookupResult -> lookupFuture.complete(lookupResult)).exceptionally(ex -> {
                lookupFuture.completeExceptionally(ex);
                return null;
            });
        }
    } catch (Exception e) {
        LOG.warn("Error in trying to acquire namespace bundle ownership for {}: {}", bundle, e.getMessage(), e);
        lookupFuture.completeExceptionally(e);
    }
}
Also used : URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) PulsarService(com.yahoo.pulsar.broker.PulsarService) URI(java.net.URI) LocalPolicies(com.yahoo.pulsar.common.policies.data.LocalPolicies) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) NamespaceBundleFactory.getBundlesData(com.yahoo.pulsar.common.naming.NamespaceBundleFactory.getBundlesData) Set(java.util.Set) StatCallback(org.apache.zookeeper.AsyncCallback.StatCallback) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ObjectMapperFactory(com.yahoo.pulsar.common.util.ObjectMapperFactory) NamespaceIsolationPolicies(com.yahoo.pulsar.common.policies.impl.NamespaceIsolationPolicies) List(java.util.List) NamespaceBundles(com.yahoo.pulsar.common.naming.NamespaceBundles) AdminResource(com.yahoo.pulsar.broker.admin.AdminResource) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LOCAL_POLICIES_ROOT(com.yahoo.pulsar.broker.cache.LocalZooKeeperCacheService.LOCAL_POLICIES_ROOT) PulsarWebResource.joinPath(com.yahoo.pulsar.broker.web.PulsarWebResource.joinPath) AdminResource.jsonMapper(com.yahoo.pulsar.broker.admin.AdminResource.jsonMapper) LoadManager(com.yahoo.pulsar.broker.loadbalance.LoadManager) BundlesData(com.yahoo.pulsar.common.policies.data.BundlesData) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Hashing(com.google.common.hash.Hashing) LookupData(com.yahoo.pulsar.common.lookup.data.LookupData) SimpleLoadManagerImpl(com.yahoo.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) SafeRun.safeRun(org.apache.bookkeeper.mledger.util.SafeRun.safeRun) NamespaceIsolationPolicy(com.yahoo.pulsar.common.policies.NamespaceIsolationPolicy) Lists(com.google.common.collect.Lists) LoadReport(com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport) Deserializer(com.yahoo.pulsar.zookeeper.ZooKeeperCache.Deserializer) Codec(com.yahoo.pulsar.common.util.Codec) NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceBundleFactory(com.yahoo.pulsar.common.naming.NamespaceBundleFactory) BrokerAssignment(com.yahoo.pulsar.common.policies.data.BrokerAssignment) ServiceUnitId(com.yahoo.pulsar.common.naming.ServiceUnitId) Logger(org.slf4j.Logger) KeeperException(org.apache.zookeeper.KeeperException) LookupResult(com.yahoo.pulsar.broker.lookup.LookupResult) PulsarAdmin(com.yahoo.pulsar.client.admin.PulsarAdmin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) NamespaceOwnershipStatus(com.yahoo.pulsar.common.policies.data.NamespaceOwnershipStatus) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) LookupResult(com.yahoo.pulsar.broker.lookup.LookupResult) KeeperException(org.apache.zookeeper.KeeperException) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException)

Example 84 with CompletableFuture

use of java.util.concurrent.CompletableFuture in project pulsar by yahoo.

the class NamespaceService method splitAndOwnBundle.

/**
     * 1. split the given bundle into two bundles 2. assign ownership of both the bundles to current broker 3. update
     * policies with newly created bundles into LocalZK 4. disable original bundle and refresh the cache
     *
     * @param bundle
     * @return
     * @throws Exception
     */
public CompletableFuture<Void> splitAndOwnBundle(NamespaceBundle bundle) throws Exception {
    final CompletableFuture<Void> future = new CompletableFuture<>();
    Pair<NamespaceBundles, List<NamespaceBundle>> splittedBundles = bundleFactory.splitBundles(bundle, 2);
    if (splittedBundles != null) {
        checkNotNull(splittedBundles.getLeft());
        checkNotNull(splittedBundles.getRight());
        checkArgument(splittedBundles.getRight().size() == 2, "bundle has to be split in two bundles");
        NamespaceName nsname = bundle.getNamespaceObject();
        try {
            // take ownership of newly split bundles
            for (NamespaceBundle sBundle : splittedBundles.getRight()) {
                checkNotNull(ownershipCache.tryAcquiringOwnership(sBundle));
            }
            updateNamespaceBundles(nsname, splittedBundles.getLeft(), (rc, path, zkCtx, stat) -> pulsar.getOrderedExecutor().submit(safeRun(() -> {
                if (rc == KeeperException.Code.OK.intValue()) {
                    // disable old bundle
                    try {
                        ownershipCache.disableOwnership(bundle);
                        // invalidate cache as zookeeper has new split
                        // namespace bundle
                        bundleFactory.invalidateBundleCache(nsname);
                        // update bundled_topic cache for load-report-generation
                        pulsar.getBrokerService().refreshTopicToStatsMaps(bundle);
                        loadManager.setLoadReportForceUpdateFlag();
                        future.complete(null);
                    } catch (Exception e) {
                        String msg1 = format("failed to disable bundle %s under namespace [%s] with error %s", nsname.toString(), bundle.toString(), e.getMessage());
                        LOG.warn(msg1, e);
                        future.completeExceptionally(new ServiceUnitNotReadyException(msg1));
                    }
                } else {
                    String msg2 = format("failed to update namespace [%s] policies due to %s", nsname.toString(), KeeperException.create(KeeperException.Code.get(rc)).getMessage());
                    LOG.warn(msg2);
                    future.completeExceptionally(new ServiceUnitNotReadyException(msg2));
                }
            })));
        } catch (Exception e) {
            String msg = format("failed to aquire ownership of split bundle for namespace [%s], %s", nsname.toString(), e.getMessage());
            LOG.warn(msg, e);
            future.completeExceptionally(new ServiceUnitNotReadyException(msg));
        }
    } else {
        String msg = format("bundle %s not found under namespace", bundle.toString());
        future.completeExceptionally(new ServiceUnitNotReadyException(msg));
    }
    return future;
}
Also used : NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) CompletableFuture(java.util.concurrent.CompletableFuture) NamespaceBundles(com.yahoo.pulsar.common.naming.NamespaceBundles) List(java.util.List) KeeperException(org.apache.zookeeper.KeeperException) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException)

Example 85 with CompletableFuture

use of java.util.concurrent.CompletableFuture in project pulsar by yahoo.

the class BrokerService method unloadServiceUnit.

/**
     * Unload all the topic served by the broker service under the given service unit
     *
     * @param serviceUnit
     * @return
     */
public CompletableFuture<Integer> unloadServiceUnit(NamespaceBundle serviceUnit) {
    CompletableFuture<Integer> result = new CompletableFuture<Integer>();
    List<CompletableFuture<Void>> closeFutures = Lists.newArrayList();
    topics.forEach((name, topicFuture) -> {
        DestinationName topicName = DestinationName.get(name);
        if (serviceUnit.includes(topicName)) {
            // Topic needs to be unloaded
            log.info("[{}] Unloading topic", topicName);
            closeFutures.add(topicFuture.thenCompose(Topic::close));
        }
    });
    CompletableFuture<Void> aggregator = FutureUtil.waitForAll(closeFutures);
    aggregator.thenAccept(res -> result.complete(closeFutures.size())).exceptionally(ex -> {
        result.completeExceptionally(ex);
        return null;
    });
    return result;
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) LoggerFactory(org.slf4j.LoggerFactory) NamespaceBundleStats(com.yahoo.pulsar.common.policies.data.loadbalancer.NamespaceBundleStats) Stat(org.apache.zookeeper.data.Stat) Policies(com.yahoo.pulsar.common.policies.data.Policies) EpollMode(io.netty.channel.epoll.EpollMode) PersistencePolicies(com.yahoo.pulsar.common.policies.data.PersistencePolicies) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PersistentOfflineTopicStats(com.yahoo.pulsar.common.policies.data.PersistentOfflineTopicStats) ClusterData(com.yahoo.pulsar.common.policies.data.ClusterData) ManagedLedger(org.apache.bookkeeper.mledger.ManagedLedger) ManagedLedgerConfig(org.apache.bookkeeper.mledger.ManagedLedgerConfig) Map(java.util.Map) ZooKeeperCacheListener(com.yahoo.pulsar.zookeeper.ZooKeeperCacheListener) PulsarService(com.yahoo.pulsar.broker.PulsarService) FieldParser(com.yahoo.pulsar.common.util.FieldParser) PulsarClientImpl(com.yahoo.pulsar.client.impl.PulsarClientImpl) FutureUtil(com.yahoo.pulsar.client.util.FutureUtil) URI(java.net.URI) PulsarClient(com.yahoo.pulsar.client.api.PulsarClient) SystemUtils(org.apache.commons.lang.SystemUtils) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) DigestType(org.apache.bookkeeper.client.BookKeeper.DigestType) PersistenceException(com.yahoo.pulsar.broker.service.BrokerServiceException.PersistenceException) Set(java.util.Set) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) InetSocketAddress(java.net.InetSocketAddress) Executors(java.util.concurrent.Executors) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ObjectMapperFactory(com.yahoo.pulsar.common.util.ObjectMapperFactory) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) Metrics(com.yahoo.pulsar.broker.stats.Metrics) List(java.util.List) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) AdminResource(com.yahoo.pulsar.broker.admin.AdminResource) ClientConfiguration(com.yahoo.pulsar.client.api.ClientConfiguration) PersistentTopic(com.yahoo.pulsar.broker.service.persistent.PersistentTopic) Optional(java.util.Optional) PulsarClientException(com.yahoo.pulsar.client.api.PulsarClientException) ManagedLedgerFactory(org.apache.bookkeeper.mledger.ManagedLedgerFactory) ChannelOption(io.netty.channel.ChannelOption) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) SafeRun.safeRun(org.apache.bookkeeper.mledger.util.SafeRun.safeRun) PersistentTopicStats(com.yahoo.pulsar.common.policies.data.PersistentTopicStats) EpollChannelOption(io.netty.channel.epoll.EpollChannelOption) Lists(com.google.common.collect.Lists) FieldContext(com.yahoo.pulsar.common.configuration.FieldContext) ByteBuf(io.netty.buffer.ByteBuf) EpollServerSocketChannel(io.netty.channel.epoll.EpollServerSocketChannel) RetentionPolicies(com.yahoo.pulsar.common.policies.data.RetentionPolicies) ConcurrentOpenHashSet(com.yahoo.pulsar.common.util.collections.ConcurrentOpenHashSet) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) ConcurrentOpenHashMap(com.yahoo.pulsar.common.util.collections.ConcurrentOpenHashMap) AdaptiveRecvByteBufAllocator(io.netty.channel.AdaptiveRecvByteBufAllocator) NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceBundleFactory(com.yahoo.pulsar.common.naming.NamespaceBundleFactory) PersistentReplicator(com.yahoo.pulsar.broker.service.persistent.PersistentReplicator) ClusterReplicationMetrics(com.yahoo.pulsar.broker.stats.ClusterReplicationMetrics) Logger(org.slf4j.Logger) ZooKeeperDataCache(com.yahoo.pulsar.zookeeper.ZooKeeperDataCache) EventLoopGroup(io.netty.channel.EventLoopGroup) KeeperException(org.apache.zookeeper.KeeperException) Semaphore(java.util.concurrent.Semaphore) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ServerMetadataException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServerMetadataException) IOException(java.io.IOException) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) Field(java.lang.reflect.Field) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) OpenLedgerCallback(org.apache.bookkeeper.mledger.AsyncCallbacks.OpenLedgerCallback) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) PulsarWebResource(com.yahoo.pulsar.broker.web.PulsarWebResource) Closeable(java.io.Closeable) CollectionUtils.isEmpty(org.apache.commons.collections.CollectionUtils.isEmpty) AuthorizationManager(com.yahoo.pulsar.broker.authorization.AuthorizationManager) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService) CompletableFuture(java.util.concurrent.CompletableFuture) DestinationName(com.yahoo.pulsar.common.naming.DestinationName)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)301 Test (org.junit.Test)64 IOException (java.io.IOException)38 List (java.util.List)34 Test (org.testng.annotations.Test)33 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)28 DestinationName (com.yahoo.pulsar.common.naming.DestinationName)26 Logger (org.slf4j.Logger)26 Map (java.util.Map)25 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)25 LoggerFactory (org.slf4j.LoggerFactory)25 PersistentTopic (com.yahoo.pulsar.broker.service.persistent.PersistentTopic)24 ArrayList (java.util.ArrayList)24 ExecutionException (java.util.concurrent.ExecutionException)24 TimeUnit (java.util.concurrent.TimeUnit)24 ByteBuf (io.netty.buffer.ByteBuf)23 CountDownLatch (java.util.concurrent.CountDownLatch)21 PulsarClientException (com.yahoo.pulsar.client.api.PulsarClientException)20 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)20 Consumer (com.yahoo.pulsar.client.api.Consumer)19