Search in sources :

Example 6 with LocalZooKeeperCacheService

use of org.apache.pulsar.broker.cache.LocalZooKeeperCacheService in project incubator-pulsar by apache.

the class ServerCnxTest method setup.

@BeforeMethod
public void setup() throws Exception {
    svcConfig = spy(new ServiceConfiguration());
    pulsar = spy(new PulsarService(svcConfig));
    doReturn(new DefaultSchemaRegistryService()).when(pulsar).getSchemaRegistryService();
    svcConfig.setKeepAliveIntervalSeconds(inSec(1, TimeUnit.SECONDS));
    svcConfig.setBacklogQuotaCheckEnabled(false);
    doReturn(svcConfig).when(pulsar).getConfiguration();
    doReturn("use").when(svcConfig).getClusterName();
    mlFactoryMock = mock(ManagedLedgerFactory.class);
    doReturn(mlFactoryMock).when(pulsar).getManagedLedgerFactory();
    ZooKeeper mockZk = createMockZooKeeper();
    doReturn(mockZk).when(pulsar).getZkClient();
    doReturn(createMockBookKeeper(mockZk)).when(pulsar).getBookKeeperClient();
    configCacheService = mock(ConfigurationCacheService.class);
    ZooKeeperDataCache<Policies> zkDataCache = mock(ZooKeeperDataCache.class);
    doReturn(Optional.empty()).when(zkDataCache).get(anyObject());
    doReturn(zkDataCache).when(configCacheService).policiesCache();
    doReturn(configCacheService).when(pulsar).getConfigurationCache();
    LocalZooKeeperCacheService zkCache = mock(LocalZooKeeperCacheService.class);
    doReturn(CompletableFuture.completedFuture(Optional.empty())).when(zkDataCache).getAsync(any());
    doReturn(zkDataCache).when(zkCache).policiesCache();
    doReturn(configCacheService).when(pulsar).getConfigurationCache();
    doReturn(zkCache).when(pulsar).getLocalZkCacheService();
    brokerService = spy(new BrokerService(pulsar));
    doReturn(brokerService).when(pulsar).getBrokerService();
    namespaceService = mock(NamespaceService.class);
    doReturn(namespaceService).when(pulsar).getNamespaceService();
    doReturn(true).when(namespaceService).isServiceUnitOwned(any(NamespaceBundle.class));
    doReturn(true).when(namespaceService).isServiceUnitActive(any(TopicName.class));
    setupMLAsyncCallbackMocks();
    clientChannelHelper = new ClientChannelHelper();
}
Also used : NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) Policies(org.apache.pulsar.common.policies.data.Policies) DefaultSchemaRegistryService(org.apache.pulsar.broker.service.schema.DefaultSchemaRegistryService) ClientChannelHelper(org.apache.pulsar.broker.service.utils.ClientChannelHelper) TopicName(org.apache.pulsar.common.naming.TopicName) ZooKeeper(org.apache.zookeeper.ZooKeeper) MockedPulsarServiceBaseTest.createMockZooKeeper(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.createMockZooKeeper) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarService(org.apache.pulsar.broker.PulsarService) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) ManagedLedgerFactory(org.apache.bookkeeper.mledger.ManagedLedgerFactory) ConfigurationCacheService(org.apache.pulsar.broker.cache.ConfigurationCacheService) LocalZooKeeperCacheService(org.apache.pulsar.broker.cache.LocalZooKeeperCacheService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with LocalZooKeeperCacheService

use of org.apache.pulsar.broker.cache.LocalZooKeeperCacheService in project incubator-pulsar by apache.

the class NamespaceBundleTest method getNamespaceBundleFactory.

@SuppressWarnings("unchecked")
private NamespaceBundleFactory getNamespaceBundleFactory() {
    PulsarService pulsar = mock(PulsarService.class);
    LocalZooKeeperCacheService localZkCache = mock(LocalZooKeeperCacheService.class);
    ZooKeeperDataCache<LocalPolicies> poilciesCache = mock(ZooKeeperDataCache.class);
    when(pulsar.getLocalZkCacheService()).thenReturn(localZkCache);
    when(localZkCache.policiesCache()).thenReturn(poilciesCache);
    doNothing().when(poilciesCache).registerListener(any());
    return NamespaceBundleFactory.createFactory(pulsar, Hashing.crc32());
}
Also used : PulsarService(org.apache.pulsar.broker.PulsarService) LocalPolicies(org.apache.pulsar.common.policies.data.LocalPolicies) LocalZooKeeperCacheService(org.apache.pulsar.broker.cache.LocalZooKeeperCacheService)

Aggregations

LocalZooKeeperCacheService (org.apache.pulsar.broker.cache.LocalZooKeeperCacheService)7 PulsarService (org.apache.pulsar.broker.PulsarService)6 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)4 ConfigurationCacheService (org.apache.pulsar.broker.cache.ConfigurationCacheService)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)3 MockedPulsarServiceBaseTest.createMockZooKeeper (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.createMockZooKeeper)3 NamespaceService (org.apache.pulsar.broker.namespace.NamespaceService)3 NamespaceBundle (org.apache.pulsar.common.naming.NamespaceBundle)3 TopicName (org.apache.pulsar.common.naming.TopicName)3 LocalPolicies (org.apache.pulsar.common.policies.data.LocalPolicies)3 Policies (org.apache.pulsar.common.policies.data.Policies)3 ZooKeeper (org.apache.zookeeper.ZooKeeper)3 InetSocketAddress (java.net.InetSocketAddress)2 LocalZooKeeperCache (org.apache.pulsar.zookeeper.LocalZooKeeperCache)2 ByteBuf (io.netty.buffer.ByteBuf)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 IOException (java.io.IOException)1 BrokerService (org.apache.pulsar.broker.service.BrokerService)1 DefaultSchemaRegistryService (org.apache.pulsar.broker.service.schema.DefaultSchemaRegistryService)1