Java Code Examples for org.apache.pulsar.broker.ServiceConfiguration#setManagedLedgerDefaultWriteQuorum()
The following examples show how to use
org.apache.pulsar.broker.ServiceConfiguration#setManagedLedgerDefaultWriteQuorum() .
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: BrokerBookieIsolationTest.java From pulsar with Apache License 2.0 | 4 votes |
@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)); }