Search in sources :

Example 1 with InactiveTopicPolicies

use of org.apache.pulsar.common.policies.data.InactiveTopicPolicies in project pulsar by apache.

the class InactiveTopicDeleteTest method testTopicPolicyUpdateAndClean.

@Test(timeOut = 20000)
public void testTopicPolicyUpdateAndClean() throws Exception {
    final String namespace = "prop/ns-abc";
    final String namespace2 = "prop/ns-abc2";
    final String namespace3 = "prop/ns-abc3";
    List<String> namespaceList = Arrays.asList(namespace2, namespace3);
    conf.setBrokerDeleteInactiveTopicsEnabled(true);
    conf.setBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds(1000);
    conf.setBrokerDeleteInactiveTopicsMode(InactiveTopicDeleteMode.delete_when_no_subscriptions);
    InactiveTopicPolicies defaultPolicy = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1000, true);
    super.baseSetup();
    for (String ns : namespaceList) {
        admin.namespaces().createNamespace(ns);
        admin.namespaces().setNamespaceReplicationClusters(ns, Sets.newHashSet("test"));
    }
    final String topic = "persistent://prop/ns-abc/testDeletePolicyUpdate";
    final String topic2 = "persistent://prop/ns-abc2/testDeletePolicyUpdate";
    final String topic3 = "persistent://prop/ns-abc3/testDeletePolicyUpdate";
    List<String> topics = Arrays.asList(topic, topic2, topic3);
    for (String tp : topics) {
        admin.topics().createNonPartitionedTopic(tp);
    }
    InactiveTopicPolicies inactiveTopicPolicies = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true);
    admin.namespaces().setInactiveTopicPolicies(namespace, inactiveTopicPolicies);
    inactiveTopicPolicies.setInactiveTopicDeleteMode(InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    admin.namespaces().setInactiveTopicPolicies(namespace2, inactiveTopicPolicies);
    inactiveTopicPolicies.setInactiveTopicDeleteMode(InactiveTopicDeleteMode.delete_when_no_subscriptions);
    admin.namespaces().setInactiveTopicPolicies(namespace3, inactiveTopicPolicies);
    InactiveTopicPolicies policies;
    // wait for zk
    Awaitility.await().until(() -> {
        InactiveTopicPolicies temp = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
        return temp.isDeleteWhileInactive();
    });
    policies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
    Assert.assertTrue(policies.isDeleteWhileInactive());
    assertEquals(policies.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_no_subscriptions);
    assertEquals(policies.getMaxInactiveDurationSeconds(), 1);
    assertEquals(policies, admin.namespaces().getInactiveTopicPolicies(namespace));
    admin.namespaces().removeInactiveTopicPolicies(namespace);
    Awaitility.await().until(() -> {
        InactiveTopicPolicies temp = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
        return temp.getMaxInactiveDurationSeconds() == 1000;
    });
    assertEquals(((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies(), defaultPolicy);
    policies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic2, false).get().get()).getInactiveTopicPolicies();
    Assert.assertTrue(policies.isDeleteWhileInactive());
    assertEquals(policies.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    assertEquals(policies.getMaxInactiveDurationSeconds(), 1);
    assertEquals(policies, admin.namespaces().getInactiveTopicPolicies(namespace2));
    admin.namespaces().removeInactiveTopicPolicies(namespace2);
    Awaitility.await().until(() -> {
        InactiveTopicPolicies temp = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
        return temp.getMaxInactiveDurationSeconds() == 1000;
    });
    assertEquals(((PersistentTopic) pulsar.getBrokerService().getTopic(topic2, false).get().get()).getInactiveTopicPolicies(), defaultPolicy);
}
Also used : PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) Test(org.testng.annotations.Test)

Example 2 with InactiveTopicPolicies

use of org.apache.pulsar.common.policies.data.InactiveTopicPolicies in project pulsar by apache.

the class InactiveTopicDeleteTest method testDeleteWhenNoSubscriptionsWithMultiConfig.

@Test(timeOut = 20000)
public void testDeleteWhenNoSubscriptionsWithMultiConfig() throws Exception {
    final String namespace = "prop/ns-abc";
    final String namespace2 = "prop/ns-abc2";
    final String namespace3 = "prop/ns-abc3";
    List<String> namespaceList = Arrays.asList(namespace2, namespace3);
    conf.setBrokerDeleteInactiveTopicsEnabled(true);
    conf.setBrokerDeleteInactiveTopicsFrequencySeconds(1);
    super.baseSetup();
    for (String ns : namespaceList) {
        admin.namespaces().createNamespace(ns);
        admin.namespaces().setNamespaceReplicationClusters(ns, Sets.newHashSet("test"));
    }
    final String topic = "persistent://prop/ns-abc/testDeleteWhenNoSubscriptionsWithMultiConfig";
    final String topic2 = "persistent://prop/ns-abc2/testDeleteWhenNoSubscriptionsWithMultiConfig";
    final String topic3 = "persistent://prop/ns-abc3/testDeleteWhenNoSubscriptionsWithMultiConfig";
    List<String> topics = Arrays.asList(topic, topic2, topic3);
    // create producer/consumer and close
    Map<String, String> topicToSub = new HashMap<>();
    for (String tp : topics) {
        Producer<byte[]> producer = pulsarClient.newProducer().topic(tp).create();
        String subName = "sub" + System.currentTimeMillis();
        topicToSub.put(tp, subName);
        Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(tp).subscriptionName(subName).subscribe();
        for (int i = 0; i < 10; i++) {
            producer.send("Pulsar".getBytes());
        }
        consumer.close();
        producer.close();
        Thread.sleep(1);
    }
    // namespace use delete_when_no_subscriptions, namespace2 use delete_when_subscriptions_caught_up
    // namespace3 use default:delete_when_no_subscriptions
    InactiveTopicPolicies inactiveTopicPolicies = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true);
    admin.namespaces().setInactiveTopicPolicies(namespace, inactiveTopicPolicies);
    inactiveTopicPolicies.setInactiveTopicDeleteMode(InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    admin.namespaces().setInactiveTopicPolicies(namespace2, inactiveTopicPolicies);
    // wait for zk
    Awaitility.await().until(() -> {
        InactiveTopicPolicies temp = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
        return temp.isDeleteWhileInactive();
    });
    // topic should still exist
    Thread.sleep(2000);
    Assert.assertTrue(admin.topics().getList(namespace).contains(topic));
    Assert.assertTrue(admin.topics().getList(namespace2).contains(topic2));
    Assert.assertTrue(admin.topics().getList(namespace3).contains(topic3));
    // no backlog, trigger delete_when_subscriptions_caught_up
    admin.topics().skipAllMessages(topic2, topicToSub.remove(topic2));
    Awaitility.await().untilAsserted(() -> Assert.assertFalse(admin.topics().getList(namespace2).contains(topic2)));
    // delete subscription, trigger delete_when_no_subscriptions
    for (Map.Entry<String, String> entry : topicToSub.entrySet()) {
        admin.topics().deleteSubscription(entry.getKey(), entry.getValue());
    }
    Awaitility.await().untilAsserted(() -> Assert.assertFalse(admin.topics().getList(namespace).contains(topic)));
    Assert.assertFalse(admin.topics().getList(namespace3).contains(topic3));
}
Also used : HashMap(java.util.HashMap) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 3 with InactiveTopicPolicies

use of org.apache.pulsar.common.policies.data.InactiveTopicPolicies in project pulsar by apache.

the class InactiveTopicDeleteTest method testInactiveTopicApplied.

@Test(timeOut = 30000)
public void testInactiveTopicApplied() throws Exception {
    conf.setSystemTopicEnabled(true);
    conf.setTopicLevelPoliciesEnabled(true);
    super.baseSetup();
    final String namespace = "prop/ns-abc";
    final String topic = "persistent://prop/ns-abc/test-" + UUID.randomUUID();
    pulsarClient.newProducer().topic(topic).create().close();
    // namespace-level default value is null
    assertNull(admin.namespaces().getInactiveTopicPolicies(namespace));
    // topic-level default value is null
    assertNull(admin.topics().getInactiveTopicPolicies(topic));
    // use broker-level by default
    InactiveTopicPolicies brokerLevelPolicy = new InactiveTopicPolicies(conf.getBrokerDeleteInactiveTopicsMode(), conf.getBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds(), conf.isBrokerDeleteInactiveTopicsEnabled());
    Assert.assertEquals(admin.topics().getInactiveTopicPolicies(topic, true), brokerLevelPolicy);
    // set namespace-level policy
    InactiveTopicPolicies namespaceLevelPolicy = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 20, false);
    admin.namespaces().setInactiveTopicPolicies(namespace, namespaceLevelPolicy);
    Awaitility.await().untilAsserted(() -> assertNotNull(admin.namespaces().getInactiveTopicPolicies(namespace)));
    InactiveTopicPolicies policyFromBroker = admin.topics().getInactiveTopicPolicies(topic, true);
    assertEquals(policyFromBroker.getMaxInactiveDurationSeconds(), 20);
    assertFalse(policyFromBroker.isDeleteWhileInactive());
    assertEquals(policyFromBroker.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_no_subscriptions);
    // set topic-level policy
    InactiveTopicPolicies topicLevelPolicy = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_subscriptions_caught_up, 30, false);
    admin.topics().setInactiveTopicPolicies(topic, topicLevelPolicy);
    Awaitility.await().untilAsserted(() -> assertNotNull(admin.topics().getInactiveTopicPolicies(topic)));
    policyFromBroker = admin.topics().getInactiveTopicPolicies(topic, true);
    assertEquals(policyFromBroker.getMaxInactiveDurationSeconds(), 30);
    assertFalse(policyFromBroker.isDeleteWhileInactive());
    assertEquals(policyFromBroker.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    // remove topic-level policy
    admin.topics().removeInactiveTopicPolicies(topic);
    Awaitility.await().untilAsserted(() -> assertEquals(admin.topics().getInactiveTopicPolicies(topic, true), namespaceLevelPolicy));
    // remove namespace-level policy
    admin.namespaces().removeInactiveTopicPolicies(namespace);
    Awaitility.await().untilAsserted(() -> assertEquals(admin.topics().getInactiveTopicPolicies(topic, true), brokerLevelPolicy));
}
Also used : InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) Test(org.testng.annotations.Test)

Example 4 with InactiveTopicPolicies

use of org.apache.pulsar.common.policies.data.InactiveTopicPolicies in project pulsar by apache.

the class InactiveTopicDeleteTest method testTopicLevelInactivePolicyUpdateAndClean.

@Test(timeOut = 30000)
public void testTopicLevelInactivePolicyUpdateAndClean() throws Exception {
    conf.setSystemTopicEnabled(true);
    conf.setTopicLevelPoliciesEnabled(true);
    conf.setBrokerDeleteInactiveTopicsEnabled(true);
    conf.setBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds(1000);
    conf.setBrokerDeleteInactiveTopicsMode(InactiveTopicDeleteMode.delete_when_no_subscriptions);
    InactiveTopicPolicies defaultPolicy = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1000, true);
    super.baseSetup();
    final String namespace = "prop/ns-abc";
    final String topic = "persistent://prop/ns-abc/testTopicLevelInactivePolicy" + UUID.randomUUID().toString();
    final String topic2 = "persistent://prop/ns-abc/testTopicLevelInactivePolicy" + UUID.randomUUID().toString();
    final String topic3 = "persistent://prop/ns-abc/testTopicLevelInactivePolicy" + UUID.randomUUID().toString();
    List<String> topics = Arrays.asList(topic, topic2, topic3);
    for (String tp : topics) {
        admin.topics().createNonPartitionedTopic(tp);
    }
    for (String tp : topics) {
        // wait for cache
        pulsarClient.newConsumer().topic(tp).subscriptionName("my-sub").subscribe().close();
        TopicName topicName = TopicName.get(tp);
    }
    InactiveTopicPolicies inactiveTopicPolicies = new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true);
    admin.topics().setInactiveTopicPolicies(topic, inactiveTopicPolicies);
    inactiveTopicPolicies.setInactiveTopicDeleteMode(InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    admin.topics().setInactiveTopicPolicies(topic2, inactiveTopicPolicies);
    inactiveTopicPolicies.setInactiveTopicDeleteMode(InactiveTopicDeleteMode.delete_when_no_subscriptions);
    admin.topics().setInactiveTopicPolicies(topic3, inactiveTopicPolicies);
    // wait for cache
    Awaitility.await().until(() -> admin.topics().getInactiveTopicPolicies(topic) != null);
    InactiveTopicPolicies policies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
    Assert.assertTrue(policies.isDeleteWhileInactive());
    assertEquals(policies.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_no_subscriptions);
    assertEquals(policies.getMaxInactiveDurationSeconds(), 1);
    assertEquals(policies, admin.topics().getInactiveTopicPolicies(topic));
    admin.topics().removeInactiveTopicPolicies(topic);
    // Only the broker-level policies is set, so after removing the topic-level policies
    // , the topic will use the broker-level policies
    Awaitility.await().untilAsserted(() -> assertEquals(((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies(), defaultPolicy));
    policies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic2, false).get().get()).getInactiveTopicPolicies();
    Assert.assertTrue(policies.isDeleteWhileInactive());
    assertEquals(policies.getInactiveTopicDeleteMode(), InactiveTopicDeleteMode.delete_when_subscriptions_caught_up);
    assertEquals(policies.getMaxInactiveDurationSeconds(), 1);
    assertEquals(policies, admin.topics().getInactiveTopicPolicies(topic2));
    inactiveTopicPolicies.setMaxInactiveDurationSeconds(999);
    // Both broker level and namespace level policies are set, so after removing the topic level policies
    // , the topic will use the namespace level policies
    admin.namespaces().setInactiveTopicPolicies(namespace, inactiveTopicPolicies);
    // wait for zk
    Awaitility.await().until(() -> {
        InactiveTopicPolicies tempPolicies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get()).getInactiveTopicPolicies();
        return inactiveTopicPolicies.equals(tempPolicies);
    });
    admin.topics().removeInactiveTopicPolicies(topic2);
    // The cache has been updated, but the system-event may not be consumed yet
    // ,so wait for topic-policies update event
    Awaitility.await().untilAsserted(() -> {
        InactiveTopicPolicies nsPolicies = ((PersistentTopic) pulsar.getBrokerService().getTopic(topic2, false).get().get()).getInactiveTopicPolicies();
        assertEquals(nsPolicies.getMaxInactiveDurationSeconds(), 999);
    });
}
Also used : PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) TopicName(org.apache.pulsar.common.naming.TopicName) Test(org.testng.annotations.Test)

Example 5 with InactiveTopicPolicies

use of org.apache.pulsar.common.policies.data.InactiveTopicPolicies in project pulsar by apache.

the class PulsarAdminToolTest method topics.

@Test
public void topics() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    Topics mockTopics = mock(Topics.class);
    when(admin.topics()).thenReturn(mockTopics);
    Schemas mockSchemas = mock(Schemas.class);
    when(admin.schemas()).thenReturn(mockSchemas);
    Lookup mockLookup = mock(Lookup.class);
    when(admin.lookups()).thenReturn(mockLookup);
    CmdTopics cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("truncate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).truncate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("delete persistent://myprop/clust/ns1/ds1 -f -d"));
    verify(mockTopics).delete("persistent://myprop/clust/ns1/ds1", true, true);
    cmdTopics.run(split("unload persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).unload("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("permissions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPermissions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("grant-permission persistent://myprop/clust/ns1/ds1 --role admin --actions produce,consume"));
    verify(mockTopics).grantPermission("persistent://myprop/clust/ns1/ds1", "admin", Sets.newHashSet(AuthAction.produce, AuthAction.consume));
    cmdTopics.run(split("revoke-permission persistent://myprop/clust/ns1/ds1 --role admin"));
    verify(mockTopics).revokePermissions("persistent://myprop/clust/ns1/ds1", "admin");
    cmdTopics.run(split("list myprop/clust/ns1"));
    verify(mockTopics).getList("myprop/clust/ns1", null, null);
    cmdTopics.run(split("lookup persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).lookupTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-lookup persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).lookupPartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-lookup persistent://myprop/clust/ns1/ds1 --sort-by-broker"));
    verify(mockLookup).lookupPartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("bundle-range persistent://myprop/clust/ns1/ds1"));
    verify(mockLookup).getBundleRange("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("unsubscribe persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).deleteSubscription("persistent://myprop/clust/ns1/ds1", "sub1", false);
    cmdTopics.run(split("stats persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getStats("persistent://myprop/clust/ns1/ds1", false, false, false);
    cmdTopics.run(split("stats-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInternalStats("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-backlog-quotas persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getBacklogQuotaMap("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -l 10 -p producer_request_hold"));
    verify(mockTopics).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(10).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("set-backlog-quota persistent://myprop/clust/ns1/ds1 -lt 1000 -p producer_request_hold -t message_age"));
    verify(mockTopics).setBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.builder().limitSize(-1).limitTime(1000).retentionPolicy(RetentionPolicy.producer_request_hold).build(), BacklogQuota.BacklogQuotaType.message_age);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.destination_storage);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("remove-backlog-quota persistent://myprop/clust/ns1/ds1 -t message_age"));
    verify(mockTopics).removeBacklogQuota("persistent://myprop/clust/ns1/ds1", BacklogQuota.BacklogQuotaType.message_age);
    cmdTopics.run(split("info-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInternalInfo("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("partitioned-stats persistent://myprop/clust/ns1/ds1 --per-partition"));
    verify(mockTopics).getPartitionedStats("persistent://myprop/clust/ns1/ds1", true, false, false);
    cmdTopics.run(split("partitioned-stats-internal persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPartitionedInternalStats("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("clear-backlog persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).skipAllMessages("persistent://myprop/clust/ns1/ds1", "sub1");
    cmdTopics.run(split("skip persistent://myprop/clust/ns1/ds1 -s sub1 -n 100"));
    verify(mockTopics).skipMessages("persistent://myprop/clust/ns1/ds1", "sub1", 100);
    cmdTopics.run(split("expire-messages persistent://myprop/clust/ns1/ds1 -s sub1 -t 100"));
    verify(mockTopics).expireMessages("persistent://myprop/clust/ns1/ds1", "sub1", 100);
    cmdTopics.run(split("get-subscribe-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getSubscribeRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscribe-rate persistent://myprop/clust/ns1/ds1 -sr 2 -st 60"));
    verify(mockTopics).setSubscribeRate("persistent://myprop/clust/ns1/ds1", new SubscribeRate(2, 60));
    cmdTopics.run(split("remove-subscribe-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscribeRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1 -e"));
    verify(mockTopics).setReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1", true);
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("expire-messages persistent://myprop/clust/ns1/ds1 -s sub1 -p 1:1 -e"));
    verify(mockTopics).expireMessages(eq("persistent://myprop/clust/ns1/ds1"), eq("sub1"), eq(new MessageIdImpl(1, 1, -1)), eq(true));
    cmdTopics.run(split("expire-messages-all-subscriptions persistent://myprop/clust/ns1/ds1 -t 100"));
    verify(mockTopics).expireMessagesForAllSubscriptions("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("create-subscription persistent://myprop/clust/ns1/ds1 -s sub1 --messageId earliest"));
    verify(mockTopics).createSubscription("persistent://myprop/clust/ns1/ds1", "sub1", MessageId.earliest);
    cmdTopics.run(split("create-partitioned-topic persistent://myprop/clust/ns1/ds1 --partitions 32"));
    verify(mockTopics).createPartitionedTopic("persistent://myprop/clust/ns1/ds1", 32, null);
    cmdTopics.run(split("create-missed-partitions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).createMissedPartitions("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("create persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).createNonPartitionedTopic("persistent://myprop/clust/ns1/ds1", new HashMap<>());
    cmdTopics.run(split("list-partitioned-topics myprop/clust/ns1"));
    verify(mockTopics).getPartitionedTopicList("myprop/clust/ns1");
    cmdTopics.run(split("update-partitioned-topic persistent://myprop/clust/ns1/ds1 -p 6"));
    verify(mockTopics).updatePartitionedTopic("persistent://myprop/clust/ns1/ds1", 6, false, false);
    cmdTopics.run(split("get-partitioned-topic-metadata persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPartitionedTopicMetadata("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("delete-partitioned-topic persistent://myprop/clust/ns1/ds1 -d -f"));
    verify(mockTopics).deletePartitionedTopic("persistent://myprop/clust/ns1/ds1", true, true);
    cmdTopics.run(split("peek-messages persistent://myprop/clust/ns1/ds1 -s sub1 -n 3"));
    verify(mockTopics).peekMessages("persistent://myprop/clust/ns1/ds1", "sub1", 3);
    MessageImpl message = mock(MessageImpl.class);
    when(message.getData()).thenReturn(new byte[] {});
    when(message.getMessageId()).thenReturn(new MessageIdImpl(1L, 1L, 1));
    when(mockTopics.examineMessage("persistent://myprop/clust/ns1/ds1", "latest", 1)).thenReturn(message);
    cmdTopics.run(split("examine-messages persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).examineMessage("persistent://myprop/clust/ns1/ds1", "latest", 1);
    cmdTopics.run(split("enable-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("disable-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).enableDeduplication("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-deduplication persistent://myprop/clust/ns1/ds1 --disable"));
    verify(mockTopics).setDeduplicationStatus("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopics).setSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-subscription-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscriptionDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-subscription-types-enabled persistent://myprop/clust/ns1/ds1 -t Shared,Failover"));
    verify(mockTopics).setSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1", Sets.newHashSet(SubscriptionType.Shared, SubscriptionType.Failover));
    cmdTopics.run(split("get-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-subscription-types-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeSubscriptionTypesEnabled("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1 -md 10 -bd 11 -dt 12"));
    verify(mockTopics).setReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(10).dispatchThrottlingRateInByte(11).ratePeriodInSecond(12).build());
    cmdTopics.run(split("remove-replicator-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeReplicatorDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication-enabled persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-deduplication persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getDeduplicationStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-offload-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeOffloadPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-delayed-delivery persistent://myprop/clust/ns1/ds1 -t 10s --enable"));
    verify(mockTopics).setDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", DelayedDeliveryPolicies.builder().tickTime(10000).active(true).build());
    cmdTopics.run(split("remove-delayed-delivery persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-offload-policies persistent://myprop/clust/ns1/ds1 -d s3 -r region -b bucket -e endpoint -m 8 -rb 9 -t 10 -orp tiered-storage-first"));
    OffloadPoliciesImpl offloadPolicies = OffloadPoliciesImpl.create("s3", "region", "bucket", "endpoint", null, null, null, null, 8, 9, 10L, null, OffloadedReadPriority.TIERED_STORAGE_FIRST);
    verify(mockTopics).setOffloadPolicies("persistent://myprop/clust/ns1/ds1", offloadPolicies);
    cmdTopics.run(split("get-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).removeMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1 -m 999"));
    verify(mockTopics).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("set-max-unacked-messages-per-consumer persistent://myprop/clust/ns1/ds1 -m 999"));
    verify(mockTopics, times(2)).setMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", 999);
    cmdTopics.run(split("get-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("get-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics, times(2)).removeMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-publish-rate persistent://myprop/clust/ns1/ds1 -m 100 -b 10240"));
    verify(mockTopics).setPublishRate("persistent://myprop/clust/ns1/ds1", new PublishRate(100, 10240L));
    cmdTopics.run(split("remove-publish-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removePublishRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("set-max-unacked-messages-per-subscription persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics, times(2)).setMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getCompactionThreshold("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-compaction-threshold persistent://myprop/clust/ns1/ds1 -t 10k"));
    verify(mockTopics).setCompactionThreshold("persistent://myprop/clust/ns1/ds1", 10 * 1024);
    cmdTopics.run(split("remove-compaction-threshold persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeCompactionThreshold("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-max-message-size persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxMessageSize("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1 -c 5"));
    verify(mockTopics).setMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1", 5);
    cmdTopics.run(split("remove-max-consumers-per-subscription persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxConsumersPerSubscription("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-message-size persistent://myprop/clust/ns1/ds1 -m 99"));
    verify(mockTopics).setMaxMessageSize("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-message-by-id persistent://myprop/clust/ns1/ds1 -l 10 -e 2"));
    verify(mockTopics).getMessageById("persistent://myprop/clust/ns1/ds1", 10, 2);
    cmdTopics.run(split("get-dispatch-rate persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getDispatchRate("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("remove-dispatch-rate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDispatchRate("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-dispatch-rate persistent://myprop/clust/ns1/ds1 -md -1 -bd -1 -dt 2"));
    verify(mockTopics).setDispatchRate("persistent://myprop/clust/ns1/ds1", DispatchRate.builder().dispatchThrottlingRateInMsg(-1).dispatchThrottlingRateInByte(-1).ratePeriodInSecond(2).build());
    cmdTopics.run(split("get-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxProducers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-producers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxProducers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-producers persistent://myprop/clust/ns1/ds1 -p 99"));
    verify(mockTopics).setMaxProducers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxConsumers("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-max-consumers persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxConsumers("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-consumers persistent://myprop/clust/ns1/ds1 -c 99"));
    verify(mockTopics).setMaxConsumers("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("remove-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-deduplication-snapshot-interval persistent://myprop/clust/ns1/ds1 -i 99"));
    verify(mockTopics).setDeduplicationSnapshotInterval("persistent://myprop/clust/ns1/ds1", 99);
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("remove-inactive-topic-policies persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-inactive-topic-policies persistent://myprop/clust/ns1/ds1" + " -e -t 1s -m delete_when_no_subscriptions"));
    verify(mockTopics).setInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", new InactiveTopicPolicies(InactiveTopicDeleteMode.delete_when_no_subscriptions, 1, true));
    cmdTopics.run(split("get-max-subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-max-subscriptions persistent://myprop/clust/ns1/ds1 -m 100"));
    verify(mockTopics).setMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1", 100);
    cmdTopics.run(split("remove-max-subscriptions persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMaxSubscriptionsPerTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("get-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getPersistence("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-persistence persistent://myprop/clust/ns1/ds1 -e 2 -w 1 -a 1 -r 100.0"));
    verify(mockTopics).setPersistence("persistent://myprop/clust/ns1/ds1", new PersistencePolicies(2, 1, 1, 100.0d));
    cmdTopics.run(split("remove-persistence persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removePersistence("persistent://myprop/clust/ns1/ds1");
    // range of +/- 1 second of the expected timestamp
    class TimestampMatcher implements ArgumentMatcher<Long> {

        @Override
        public boolean matches(Long timestamp) {
            long expectedTimestamp = System.currentTimeMillis() - (1 * 60 * 1000);
            if (timestamp < (expectedTimestamp + 1000) && timestamp > (expectedTimestamp - 1000)) {
                return true;
            }
            return false;
        }
    }
    cmdTopics.run(split("reset-cursor persistent://myprop/clust/ns1/ds1 -s sub1 -t 1m"));
    verify(mockTopics).resetCursor(eq("persistent://myprop/clust/ns1/ds1"), eq("sub1"), longThat(new TimestampMatcher()));
    when(mockTopics.terminateTopicAsync("persistent://myprop/clust/ns1/ds1")).thenReturn(CompletableFuture.completedFuture(new MessageIdImpl(1L, 1L, 1)));
    cmdTopics.run(split("terminate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).terminateTopicAsync("persistent://myprop/clust/ns1/ds1");
    Map<Integer, MessageId> results = new HashMap<>();
    results.put(0, new MessageIdImpl(1, 1, 0));
    when(mockTopics.terminatePartitionedTopic("persistent://myprop/clust/ns1/ds1")).thenReturn(results);
    cmdTopics.run(split("partitioned-terminate persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).terminatePartitionedTopic("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("compact persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).triggerCompaction("persistent://myprop/clust/ns1/ds1");
    when(mockTopics.compactionStatus("persistent://myprop/clust/ns1/ds1")).thenReturn(new LongRunningProcessStatus());
    cmdTopics.run(split("compaction-status persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).compactionStatus("persistent://myprop/clust/ns1/ds1");
    PersistentTopicInternalStats stats = new PersistentTopicInternalStats();
    stats.ledgers = new ArrayList<>();
    stats.ledgers.add(newLedger(0, 10, 1000));
    stats.ledgers.add(newLedger(1, 10, 2000));
    stats.ledgers.add(newLedger(2, 10, 3000));
    when(mockTopics.getInternalStats("persistent://myprop/clust/ns1/ds1", false)).thenReturn(stats);
    cmdTopics.run(split("offload persistent://myprop/clust/ns1/ds1 -s 1k"));
    verify(mockTopics).triggerOffload("persistent://myprop/clust/ns1/ds1", new MessageIdImpl(2, 0, -1));
    when(mockTopics.offloadStatus("persistent://myprop/clust/ns1/ds1")).thenReturn(new OffloadProcessStatusImpl());
    cmdTopics.run(split("offload-status persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).offloadStatus("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("last-message-id persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getLastMessageId(eq("persistent://myprop/clust/ns1/ds1"));
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getMessageTTL("persistent://myprop/clust/ns1/ds1", false);
    cmdTopics.run(split("set-message-ttl persistent://myprop/clust/ns1/ds1 -t 10"));
    verify(mockTopics).setMessageTTL("persistent://myprop/clust/ns1/ds1", 10);
    cmdTopics.run(split("remove-message-ttl persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeMessageTTL("persistent://myprop/clust/ns1/ds1");
    cmdTopics.run(split("set-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1 -d"));
    verify(mockTopics).setReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1", false);
    cmdTopics.run(split("get-replicated-subscription-status persistent://myprop/clust/ns1/ds1 -s sub1"));
    verify(mockTopics).getReplicatedSubscriptionStatus("persistent://myprop/clust/ns1/ds1", "sub1");
    // cmd with option cannot be executed repeatedly.
    cmdTopics = new CmdTopics(() -> admin);
    cmdTopics.run(split("get-max-unacked-messages-on-subscription persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxUnackedMessagesOnSubscription("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("reset-cursor persistent://myprop/clust/ns1/ds2 -s sub1 -m 1:1 -e"));
    verify(mockTopics).resetCursor(eq("persistent://myprop/clust/ns1/ds2"), eq("sub1"), eq(new MessageIdImpl(1, 1, -1)), eq(true));
    cmdTopics.run(split("get-maxProducers persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxProducers("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-maxProducers persistent://myprop/clust/ns1/ds1 -p 3"));
    verify(mockTopics).setMaxProducers("persistent://myprop/clust/ns1/ds1", 3);
    cmdTopics.run(split("remove-maxProducers persistent://myprop/clust/ns1/ds2"));
    verify(mockTopics).removeMaxProducers("persistent://myprop/clust/ns1/ds2");
    cmdTopics.run(split("get-message-ttl persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMessageTTL("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-offload-policies persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getOffloadPolicies("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-max-unacked-messages-on-consumer persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxUnackedMessagesOnConsumer("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-inactive-topic-policies persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getInactiveTopicPolicies("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-delayed-delivery persistent://myprop/clust/ns1/ds1 --applied"));
    verify(mockTopics).getDelayedDeliveryPolicy("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-max-consumers persistent://myprop/clust/ns1/ds1 -ap"));
    verify(mockTopics).getMaxConsumers("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("get-replication-clusters persistent://myprop/clust/ns1/ds1 --applied"));
    verify(mockTopics).getReplicationClusters("persistent://myprop/clust/ns1/ds1", true);
    cmdTopics.run(split("set-replication-clusters persistent://myprop/clust/ns1/ds1 -c test"));
    verify(mockTopics).setReplicationClusters("persistent://myprop/clust/ns1/ds1", Lists.newArrayList("test"));
    cmdTopics.run(split("remove-replication-clusters persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).removeReplicationClusters("persistent://myprop/clust/ns1/ds1");
}
Also used : PersistencePolicies(org.apache.pulsar.common.policies.data.PersistencePolicies) HashMap(java.util.HashMap) OffloadProcessStatusImpl(org.apache.pulsar.client.admin.internal.OffloadProcessStatusImpl) ArgumentMatcher(org.mockito.ArgumentMatcher) PersistentTopicInternalStats(org.apache.pulsar.common.policies.data.PersistentTopicInternalStats) Lookup(org.apache.pulsar.client.admin.Lookup) NonPersistentTopics(org.apache.pulsar.client.admin.NonPersistentTopics) Topics(org.apache.pulsar.client.admin.Topics) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) LongRunningProcessStatus(org.apache.pulsar.client.admin.LongRunningProcessStatus) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) PublishRate(org.apache.pulsar.common.policies.data.PublishRate) Schemas(org.apache.pulsar.client.admin.Schemas) OffloadPoliciesImpl(org.apache.pulsar.common.policies.data.OffloadPoliciesImpl) SubscribeRate(org.apache.pulsar.common.policies.data.SubscribeRate) InactiveTopicPolicies(org.apache.pulsar.common.policies.data.InactiveTopicPolicies) MessageImpl(org.apache.pulsar.client.impl.MessageImpl) MessageId(org.apache.pulsar.client.api.MessageId) Test(org.testng.annotations.Test)

Aggregations

InactiveTopicPolicies (org.apache.pulsar.common.policies.data.InactiveTopicPolicies)22 Test (org.testng.annotations.Test)14 RetentionPolicies (org.apache.pulsar.common.policies.data.RetentionPolicies)8 TopicName (org.apache.pulsar.common.naming.TopicName)5 CompletableFuture (java.util.concurrent.CompletableFuture)4 PersistentTopic (org.apache.pulsar.broker.service.persistent.PersistentTopic)4 PersistencePolicies (org.apache.pulsar.common.policies.data.PersistencePolicies)4 HashMap (java.util.HashMap)3 WebTarget (javax.ws.rs.client.WebTarget)3 Lookup (org.apache.pulsar.client.admin.Lookup)3 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)3 PublishRate (org.apache.pulsar.common.policies.data.PublishRate)3 SubscribeRate (org.apache.pulsar.common.policies.data.SubscribeRate)3 Map (java.util.Map)2 MockedPulsarServiceBaseTest (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)2 Schemas (org.apache.pulsar.client.admin.Schemas)2 PersistentTopicInternalStats (org.apache.pulsar.common.policies.data.PersistentTopicInternalStats)2 Policies (org.apache.pulsar.common.policies.data.Policies)2 EmptyLookupResultException (io.streamnative.pulsar.handlers.amqp.common.exception.EmptyLookupResultException)1 NamespaceNotFoundException (io.streamnative.pulsar.handlers.amqp.common.exception.NamespaceNotFoundException)1