Search in sources :

Example 6 with LocalBookkeeperEnsemble

use of org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble in project incubator-pulsar by apache.

the class AdvertisedAddressTest method setup.

@BeforeMethod
public void setup() throws Exception {
    bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 5001);
    bkEnsemble.start();
    ServiceConfiguration config = new ServiceConfiguration();
    config.setZookeeperServers("127.0.0.1" + ":" + ZOOKEEPER_PORT);
    config.setWebServicePort(BROKER_WEBSERVICE_PORT);
    config.setClusterName("usc");
    config.setAdvertisedAddress("localhost");
    config.setBrokerServicePort(BROKER_SERVICE_PORT);
    config.setAdvertisedAddress(advertisedAddress);
    config.setManagedLedgerMaxEntriesPerLedger(5);
    config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
    pulsar = new PulsarService(config);
    pulsar.start();
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with LocalBookkeeperEnsemble

use of org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble in project incubator-pulsar by apache.

the class BrokerBkEnsemblesTests method setup.

@BeforeMethod
void setup() throws Exception {
    try {
        // start local bookie and zookeeper
        bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, 5001);
        bkEnsemble.start();
        // start pulsar service
        config = new ServiceConfiguration();
        config.setZookeeperServers("127.0.0.1" + ":" + ZOOKEEPER_PORT);
        config.setAdvertisedAddress("localhost");
        config.setWebServicePort(BROKER_WEBSERVICE_PORT);
        config.setClusterName("usc");
        config.setBrokerServicePort(BROKER_SERVICE_PORT);
        config.setAuthorizationEnabled(false);
        config.setAuthenticationEnabled(false);
        config.setManagedLedgerMaxEntriesPerLedger(5);
        config.setManagedLedgerMinLedgerRolloverTimeMinutes(0);
        config.setAdvertisedAddress("127.0.0.1");
        pulsar = new PulsarService(config);
        pulsar.start();
        adminUrl = new URL("http://127.0.0.1" + ":" + BROKER_WEBSERVICE_PORT);
        admin = new PulsarAdmin(adminUrl, (Authentication) null);
        admin.clusters().createCluster("usc", new ClusterData(adminUrl.toString()));
        admin.properties().createProperty("prop", new PropertyAdmin(Lists.newArrayList("appid1"), Sets.newHashSet("usc")));
    } catch (Throwable t) {
        LOG.error("Error setting up broker test", t);
        Assert.fail("Broker test setup failed");
    }
}
Also used : ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) PropertyAdmin(org.apache.pulsar.common.policies.data.PropertyAdmin) Authentication(org.apache.pulsar.client.api.Authentication) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) URL(java.net.URL) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with LocalBookkeeperEnsemble

use of org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble in project incubator-pulsar by apache.

the class SLAMonitoringTest method setup.

@BeforeClass
void setup() throws Exception {
    log.info("---- Initializing SLAMonitoringTest -----");
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, PortManager.nextFreePort());
    bkEnsemble.start();
    // start brokers
    for (int i = 0; i < BROKER_COUNT; i++) {
        brokerWebServicePorts[i] = PortManager.nextFreePort();
        brokerNativeBrokerPorts[i] = PortManager.nextFreePort();
        ServiceConfiguration config = new ServiceConfiguration();
        config.setBrokerServicePort(brokerNativeBrokerPorts[i]);
        config.setClusterName("my-cluster");
        config.setAdvertisedAddress("localhost");
        config.setWebServicePort(brokerWebServicePorts[i]);
        config.setZookeeperServers("127.0.0.1" + ":" + ZOOKEEPER_PORT);
        config.setBrokerServicePort(brokerNativeBrokerPorts[i]);
        config.setDefaultNumberOfNamespaceBundles(1);
        config.setLoadBalancerEnabled(false);
        configurations[i] = config;
        pulsarServices[i] = new PulsarService(config);
        pulsarServices[i].start();
        brokerUrls[i] = new URL("http://127.0.0.1" + ":" + brokerWebServicePorts[i]);
        pulsarAdmins[i] = new PulsarAdmin(brokerUrls[i], (Authentication) null);
    }
    Thread.sleep(100);
    createProperty(pulsarAdmins[BROKER_COUNT - 1]);
    for (int i = 0; i < BROKER_COUNT; i++) {
        String topic = String.format("%s/%s/%s:%s", NamespaceService.SLA_NAMESPACE_PROPERTY, "my-cluster", pulsarServices[i].getAdvertisedAddress(), brokerWebServicePorts[i]);
        pulsarAdmins[0].namespaces().createNamespace(topic);
    }
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Authentication(org.apache.pulsar.client.api.Authentication) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with LocalBookkeeperEnsemble

use of org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble in project incubator-pulsar by apache.

the class LocalBookkeeperEnsembleTest method testStartStop.

@Test
void testStartStop() throws Exception {
    final int numBk = 1;
    final int zkPort = PortManager.nextFreePort();
    final int bkPort = PortManager.nextFreePort();
    // Start local Bookies/ZooKeepers and confirm that they are running at specified ports
    LocalBookkeeperEnsemble ensemble = new LocalBookkeeperEnsemble(numBk, zkPort, bkPort);
    ensemble.start();
    assertTrue(ensemble.getZkServer().isRunning());
    assertEquals(ensemble.getZkServer().getClientPort(), zkPort);
    assertTrue(ensemble.getZkClient().getState().isConnected());
    assertTrue(ensemble.getBookies()[0].isRunning());
    assertEquals(ensemble.getBookies()[0].getLocalAddress().getPort(), bkPort);
    // Stop local Bookies/ZooKeepers and confirm that they are correctly closed
    ensemble.stop();
    assertFalse(ensemble.getZkServer().isRunning());
    assertFalse(ensemble.getZkClient().getState().isConnected());
    assertFalse(ensemble.getBookies()[0].isRunning());
}
Also used : LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) Test(org.testng.annotations.Test)

Example 10 with LocalBookkeeperEnsemble

use of org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble in project incubator-pulsar by apache.

the class AntiAffinityNamespaceGroupTest method setup.

@BeforeMethod
void setup() throws Exception {
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, ZOOKEEPER_PORT, PortManager.nextFreePort());
    bkEnsemble.start();
    // Start broker 1
    ServiceConfiguration config1 = new ServiceConfiguration();
    config1.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
    config1.setClusterName("use");
    config1.setWebServicePort(PRIMARY_BROKER_WEBSERVICE_PORT);
    config1.setZookeeperServers("127.0.0.1" + ":" + ZOOKEEPER_PORT);
    config1.setBrokerServicePort(PRIMARY_BROKER_PORT);
    config1.setFailureDomainsEnabled(true);
    config1.setLoadBalancerEnabled(true);
    config1.setAdvertisedAddress("localhost");
    createCluster(bkEnsemble.getZkClient(), config1);
    pulsar1 = new PulsarService(config1);
    pulsar1.start();
    primaryHost = String.format("%s:%d", "localhost", PRIMARY_BROKER_WEBSERVICE_PORT);
    url1 = new URL("http://127.0.0.1" + ":" + PRIMARY_BROKER_WEBSERVICE_PORT);
    admin1 = new PulsarAdmin(url1, (Authentication) null);
    // Start broker 2
    ServiceConfiguration config2 = new ServiceConfiguration();
    config2.setLoadManagerClassName(ModularLoadManagerImpl.class.getName());
    config2.setClusterName("use");
    config2.setWebServicePort(SECONDARY_BROKER_WEBSERVICE_PORT);
    config2.setZookeeperServers("127.0.0.1" + ":" + ZOOKEEPER_PORT);
    config2.setBrokerServicePort(SECONDARY_BROKER_PORT);
    config2.setFailureDomainsEnabled(true);
    pulsar2 = new PulsarService(config2);
    secondaryHost = String.format("%s:%d", "localhost", SECONDARY_BROKER_WEBSERVICE_PORT);
    pulsar2.start();
    url2 = new URL("http://127.0.0.1" + ":" + SECONDARY_BROKER_WEBSERVICE_PORT);
    admin2 = new PulsarAdmin(url2, (Authentication) null);
    primaryLoadManager = (ModularLoadManagerImpl) getField(pulsar1.getLoadManager().get(), "loadManager");
    secondaryLoadManager = (ModularLoadManagerImpl) getField(pulsar2.getLoadManager().get(), "loadManager");
    nsFactory = new NamespaceBundleFactory(pulsar1, Hashing.crc32());
    Thread.sleep(100);
}
Also used : ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Authentication(org.apache.pulsar.client.api.Authentication) NamespaceBundleFactory(org.apache.pulsar.common.naming.NamespaceBundleFactory) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ModularLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl) URL(java.net.URL) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

LocalBookkeeperEnsemble (org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble)13 PulsarService (org.apache.pulsar.broker.PulsarService)10 URL (java.net.URL)9 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)9 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)8 Authentication (org.apache.pulsar.client.api.Authentication)8 BeforeMethod (org.testng.annotations.BeforeMethod)7 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)4 PropertyAdmin (org.apache.pulsar.common.policies.data.PropertyAdmin)4 Test (org.testng.annotations.Test)3 ModularLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl)2 SimpleLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl)2 NamespaceBundleFactory (org.apache.pulsar.common.naming.NamespaceBundleFactory)2 File (java.io.File)1 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)1 WorkerConfig (org.apache.pulsar.functions.worker.WorkerConfig)1 WorkerService (org.apache.pulsar.functions.worker.WorkerService)1 ZookeeperServerTest (org.apache.pulsar.zookeeper.ZookeeperServerTest)1 Agent (org.aspectj.weaver.loadtime.Agent)1 BeforeClass (org.testng.annotations.BeforeClass)1