Java Code Examples for org.apache.pulsar.broker.ServiceConfiguration#setManagedLedgerMinLedgerRolloverTimeMinutes()

The following examples show how to use org.apache.pulsar.broker.ServiceConfiguration#setManagedLedgerMinLedgerRolloverTimeMinutes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvertisedAddressTest.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void setup() throws Exception {
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();

    ServiceConfiguration config = new ServiceConfiguration();
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setWebServicePort(Optional.ofNullable(0));
    config.setClusterName("usc");
    config.setAdvertisedAddress("localhost");
    config.setBrokerServicePort(Optional.ofNullable(0));
    config.setAdvertisedAddress(advertisedAddress);
    config.setManagedLedgerMaxEntriesPerLedger(5);
    config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
    pulsar = new PulsarService(config);
    pulsar.start();
}
 
Example 2
Source File: BkEnsemblesTestBase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
protected void setup() throws Exception {
    try {
        // start local bookie and zookeeper
        bkEnsemble = new LocalBookkeeperEnsemble(numberOfBookies, 0, () -> 0);
        bkEnsemble.start();

        // start pulsar service
        config = new ServiceConfiguration();
        config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
        config.setAdvertisedAddress("localhost");
        config.setWebServicePort(Optional.of(0));
        config.setClusterName("usc");
        config.setBrokerServicePort(Optional.of(0));
        config.setAuthorizationEnabled(false);
        config.setAuthenticationEnabled(false);
        config.setManagedLedgerMaxEntriesPerLedger(5);
        config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
        config.setAdvertisedAddress("127.0.0.1");
        config.setAllowAutoTopicCreationType("non-partitioned");

        pulsar = new PulsarService(config);
        pulsar.start();

        admin = PulsarAdmin.builder().serviceHttpUrl(pulsar.getWebServiceAddress()).build();

        admin.clusters().createCluster("usc", new ClusterData(pulsar.getWebServiceAddress()));
        admin.tenants().createTenant("prop",
                new TenantInfo(Sets.newHashSet("appid1"), Sets.newHashSet("usc")));
    } catch (Throwable t) {
        log.error("Error setting up broker test", t);
        Assert.fail("Broker test setup failed");
    }
}
 
Example 3
Source File: MaxMessageSizeTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
void setup() {
    try {
        bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
        ServerConfiguration conf = new ServerConfiguration();
        conf.setNettyMaxFrameSizeBytes(10 * 1024 * 1024);
        bkEnsemble.startStandalone(conf, false);

        configuration = new ServiceConfiguration();
        configuration.setZookeeperServers("127.0.0.1:" + bkEnsemble.getZookeeperPort());
        configuration.setAdvertisedAddress("localhost");
        configuration.setWebServicePort(Optional.of(0));
        configuration.setClusterName("max_message_test");
        configuration.setBrokerServicePort(Optional.of(0));
        configuration.setAuthorizationEnabled(false);
        configuration.setAuthenticationEnabled(false);
        configuration.setManagedLedgerMaxEntriesPerLedger(5);
        configuration.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
        configuration.setMaxMessageSize(10 * 1024 * 1024);

        pulsar = new PulsarService(configuration);
        pulsar.start();

        String url = "http://127.0.0.1:" + pulsar.getListenPortHTTP().get();
        admin = PulsarAdmin.builder().serviceHttpUrl(url).build();
        admin.clusters().createCluster("max_message_test", new ClusterData(url));
        admin.tenants()
             .createTenant("test", new TenantInfo(Sets.newHashSet("appid1"), Sets.newHashSet("max_message_test")));
        admin.namespaces().createNamespace("test/message", Sets.newHashSet("max_message_test"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: BacklogQuotaManagerTest.java    From pulsar with Apache License 2.0 4 votes vote down vote up
@BeforeMethod
void setup() throws Exception {
    try {
        // start local bookie and zookeeper
        bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
        bkEnsemble.start();

        // start pulsar service
        config = new ServiceConfiguration();
        config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
        config.setAdvertisedAddress("localhost");
        config.setWebServicePort(Optional.ofNullable(0));
        config.setClusterName("usc");
        config.setBrokerServicePort(Optional.ofNullable(0));
        config.setAuthorizationEnabled(false);
        config.setAuthenticationEnabled(false);
        config.setBacklogQuotaCheckIntervalInSeconds(TIME_TO_CHECK_BACKLOG_QUOTA);
        config.setManagedLedgerMaxEntriesPerLedger(MAX_ENTRIES_PER_LEDGER);
        config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
        config.setAllowAutoTopicCreationType("non-partitioned");

        pulsar = new PulsarService(config);
        pulsar.start();

        adminUrl = new URL("http://127.0.0.1" + ":" + pulsar.getListenPortHTTP().get());
        admin = PulsarAdmin.builder().serviceHttpUrl(adminUrl.toString()).build();

        admin.clusters().createCluster("usc", new ClusterData(adminUrl.toString()));
        admin.tenants().createTenant("prop",
                new TenantInfo(Sets.newHashSet("appid1"), Sets.newHashSet("usc")));
        admin.namespaces().createNamespace("prop/ns-quota");
        admin.namespaces().setNamespaceReplicationClusters("prop/ns-quota", Sets.newHashSet("usc"));
        admin.namespaces().createNamespace("prop/quotahold");
        admin.namespaces().setNamespaceReplicationClusters("prop/quotahold", Sets.newHashSet("usc"));
        admin.namespaces().createNamespace("prop/quotaholdasync");
        admin.namespaces().setNamespaceReplicationClusters("prop/quotaholdasync", Sets.newHashSet("usc"));
    } catch (Throwable t) {
        LOG.error("Error setting up broker test", t);
        fail("Broker test setup failed");
    }
}
 
Example 5
Source File: BrokerBookieIsolationTest.java    From pulsar with Apache License 2.0 4 votes vote down vote up
@Test
public void testDeleteIsolationGroup() throws Exception {

    final String tenant1 = "tenant1";
    final String cluster = "use";
    final String ns2 = String.format("%s/%s/%s", tenant1, cluster, "ns2");
    final String ns3 = String.format("%s/%s/%s", tenant1, cluster, "ns3");

    final String brokerBookkeeperClientIsolationGroups = "default-group";
    final String tenantNamespaceIsolationGroupsPrimary = "tenant1-isolation-primary";
    final String tenantNamespaceIsolationGroupsSecondary = "tenant1-isolation=secondary";

    BookieServer[] bookies = bkEnsemble.getBookies();
    ZooKeeper zkClient = bkEnsemble.getZkClient();

    Set<BookieSocketAddress> defaultBookies = Sets.newHashSet(bookies[0].getLocalAddress(),
            bookies[1].getLocalAddress());
    Set<BookieSocketAddress> isolatedBookies = Sets.newHashSet(bookies[2].getLocalAddress(),
            bookies[3].getLocalAddress());

    setDefaultIsolationGroup(brokerBookkeeperClientIsolationGroups, zkClient, defaultBookies);
    // primary group empty
    setDefaultIsolationGroup(tenantNamespaceIsolationGroupsPrimary, zkClient, Sets.newHashSet());
    setDefaultIsolationGroup(tenantNamespaceIsolationGroupsSecondary, zkClient, isolatedBookies);

    ServiceConfiguration config = new ServiceConfiguration();
    config.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
    config.setClusterName(cluster);
    config.setWebServicePort(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerServicePort(Optional.of(0));
    config.setAdvertisedAddress("localhost");
    config.setBookkeeperClientIsolationGroups(brokerBookkeeperClientIsolationGroups);

    config.setManagedLedgerDefaultEnsembleSize(2);
    config.setManagedLedgerDefaultWriteQuorum(2);
    config.setManagedLedgerDefaultAckQuorum(2);
    config.setAllowAutoTopicCreationType("non-partitioned");

    config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
    pulsarService = new PulsarService(config);
    pulsarService.start();

    PulsarAdmin admin = PulsarAdmin.builder().serviceHttpUrl(pulsarService.getWebServiceAddress()).build();

    ClusterData clusterData = new ClusterData(pulsarService.getWebServiceAddress());
    admin.clusters().createCluster(cluster, clusterData);
    TenantInfo tenantInfo = new TenantInfo(null, Sets.newHashSet(cluster));
    admin.tenants().createTenant(tenant1, tenantInfo);
    admin.namespaces().createNamespace(ns2);
    admin.namespaces().createNamespace(ns3);

    // (1) set affinity-group
    admin.namespaces().setBookieAffinityGroup(ns2, new BookieAffinityGroupData(
            tenantNamespaceIsolationGroupsPrimary, tenantNamespaceIsolationGroupsSecondary));
    admin.namespaces().setBookieAffinityGroup(ns3, new BookieAffinityGroupData(
            tenantNamespaceIsolationGroupsPrimary, tenantNamespaceIsolationGroupsSecondary));

    // (2) get affinity-group
    assertEquals(admin.namespaces().getBookieAffinityGroup(ns2), new BookieAffinityGroupData(
            tenantNamespaceIsolationGroupsPrimary, tenantNamespaceIsolationGroupsSecondary));
    assertEquals(admin.namespaces().getBookieAffinityGroup(ns3), new BookieAffinityGroupData(
            tenantNamespaceIsolationGroupsPrimary, tenantNamespaceIsolationGroupsSecondary));

    // (3) delete affinity-group
    admin.namespaces().deleteBookieAffinityGroup(ns2);

    try {
        admin.namespaces().getBookieAffinityGroup(ns2);
        fail("should have fail due to affinity-group not present");
    } catch (NotFoundException e) {
        // Ok
    }

    assertEquals(admin.namespaces().getBookieAffinityGroup(ns3), new BookieAffinityGroupData(
            tenantNamespaceIsolationGroupsPrimary, tenantNamespaceIsolationGroupsSecondary));

}