Search in sources :

Example 1 with ConfigurationCacheService

use of com.yahoo.pulsar.broker.cache.ConfigurationCacheService in project pulsar by yahoo.

the class PulsarService method startZkCacheService.

private void startZkCacheService() throws PulsarServerException {
    LOG.info("starting configuration cache service");
    this.localZkCache = new LocalZooKeeperCache(getZkClient(), getOrderedExecutor());
    this.globalZkCache = new GlobalZooKeeperCache(getZooKeeperClientFactory(), (int) config.getZooKeeperSessionTimeoutMillis(), config.getGlobalZookeeperServers(), getOrderedExecutor(), this.executor);
    try {
        this.globalZkCache.start();
    } catch (IOException e) {
        throw new PulsarServerException(e);
    }
    this.configurationCacheService = new ConfigurationCacheService(getGlobalZkCache());
    this.localZkCacheService = new LocalZooKeeperCacheService(getLocalZkCache(), this.configurationCacheService);
}
Also used : GlobalZooKeeperCache(com.yahoo.pulsar.zookeeper.GlobalZooKeeperCache) LocalZooKeeperCache(com.yahoo.pulsar.zookeeper.LocalZooKeeperCache) ConfigurationCacheService(com.yahoo.pulsar.broker.cache.ConfigurationCacheService) IOException(java.io.IOException) LocalZooKeeperCacheService(com.yahoo.pulsar.broker.cache.LocalZooKeeperCacheService)

Example 2 with ConfigurationCacheService

use of com.yahoo.pulsar.broker.cache.ConfigurationCacheService in project pulsar by yahoo.

the class WebSocketService method start.

public void start() throws PulsarServerException, PulsarClientException, MalformedURLException, ServletException, DeploymentException {
    if (isNotBlank(config.getGlobalZookeeperServers())) {
        this.globalZkCache = new GlobalZooKeeperCache(getZooKeeperClientFactory(), (int) config.getZooKeeperSessionTimeoutMillis(), config.getGlobalZookeeperServers(), this.orderedExecutor, this.executor);
        try {
            this.globalZkCache.start();
        } catch (IOException e) {
            throw new PulsarServerException(e);
        }
        this.configurationCacheService = new ConfigurationCacheService(getGlobalZkCache());
        log.info("Global Zookeeper cache started");
    }
    // start authorizationManager
    if (config.isAuthorizationEnabled()) {
        if (configurationCacheService == null) {
            throw new PulsarServerException("Failed to initialize authorization manager due to empty GlobalZookeeperServers");
        }
        authorizationManager = new AuthorizationManager(this.config, configurationCacheService);
    }
    // start authentication service
    authenticationService = new AuthenticationService(this.config);
    log.info("Pulsar WebSocket Service started");
}
Also used : PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) GlobalZooKeeperCache(com.yahoo.pulsar.zookeeper.GlobalZooKeeperCache) ConfigurationCacheService(com.yahoo.pulsar.broker.cache.ConfigurationCacheService) IOException(java.io.IOException) AuthorizationManager(com.yahoo.pulsar.broker.authorization.AuthorizationManager) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService)

Example 3 with ConfigurationCacheService

use of com.yahoo.pulsar.broker.cache.ConfigurationCacheService in project pulsar by yahoo.

the class DiscoveryService method start.

/**
     * Starts discovery service by initializing zookkeeper and server
     * @throws Exception
     */
public void start() throws Exception {
    discoveryProvider = new BrokerDiscoveryProvider(this.config, getZooKeeperClientFactory());
    this.configurationCacheService = new ConfigurationCacheService(discoveryProvider.globalZkCache);
    ServiceConfiguration serviceConfiguration = createServiceConfiguration(config);
    authenticationService = new AuthenticationService(serviceConfiguration);
    authorizationManager = new AuthorizationManager(serviceConfiguration, configurationCacheService);
    startServer();
}
Also used : ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) ConfigurationCacheService(com.yahoo.pulsar.broker.cache.ConfigurationCacheService) AuthorizationManager(com.yahoo.pulsar.broker.authorization.AuthorizationManager) AuthenticationService(com.yahoo.pulsar.broker.authentication.AuthenticationService)

Example 4 with ConfigurationCacheService

use of com.yahoo.pulsar.broker.cache.ConfigurationCacheService in project pulsar by yahoo.

the class ServerCnxTest method testNonExistentTopic.

@SuppressWarnings("unchecked")
@Test(timeOut = 30000)
public void testNonExistentTopic() throws Exception {
    ZooKeeperDataCache<Policies> zkDataCache = mock(ZooKeeperDataCache.class);
    ConfigurationCacheService configCacheService = mock(ConfigurationCacheService.class);
    doReturn(configCacheService).when(pulsar).getConfigurationCache();
    doReturn(zkDataCache).when(configCacheService).policiesCache();
    doReturn(CompletableFuture.completedFuture(Optional.empty())).when(zkDataCache).getAsync(matches(".*nonexistent.*"));
    AuthorizationManager authorizationManager = spy(new AuthorizationManager(svcConfig, configCacheService));
    doReturn(authorizationManager).when(brokerService).getAuthorizationManager();
    doReturn(true).when(brokerService).isAuthorizationEnabled();
    doReturn(false).when(authorizationManager).isSuperUser(Mockito.anyString());
    // Test producer creation
    resetChannel();
    setChannelConnected();
    ByteBuf newProducerCmd = Commands.newProducer(nonExistentTopicName, 1, /* producer id */
    1, /* request id */
    "prod-name");
    channel.writeInbound(newProducerCmd);
    assertTrue(getResponse() instanceof CommandError);
    channel.finish();
    // Test consumer creation
    resetChannel();
    setChannelConnected();
    ByteBuf newSubscribeCmd = //
    Commands.newSubscribe(//
    nonExistentTopicName, successSubName, 1, /* consumer id */
    1, /* request id */
    SubType.Exclusive, 0, "test");
    channel.writeInbound(newSubscribeCmd);
    assertTrue(getResponse() instanceof CommandError);
}
Also used : Policies(com.yahoo.pulsar.common.policies.data.Policies) ConfigurationCacheService(com.yahoo.pulsar.broker.cache.ConfigurationCacheService) AuthorizationManager(com.yahoo.pulsar.broker.authorization.AuthorizationManager) CommandError(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandError) ByteBuf(io.netty.buffer.ByteBuf) Test(org.testng.annotations.Test)

Aggregations

ConfigurationCacheService (com.yahoo.pulsar.broker.cache.ConfigurationCacheService)4 AuthorizationManager (com.yahoo.pulsar.broker.authorization.AuthorizationManager)3 AuthenticationService (com.yahoo.pulsar.broker.authentication.AuthenticationService)2 GlobalZooKeeperCache (com.yahoo.pulsar.zookeeper.GlobalZooKeeperCache)2 IOException (java.io.IOException)2 PulsarServerException (com.yahoo.pulsar.broker.PulsarServerException)1 ServiceConfiguration (com.yahoo.pulsar.broker.ServiceConfiguration)1 LocalZooKeeperCacheService (com.yahoo.pulsar.broker.cache.LocalZooKeeperCacheService)1 CommandError (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandError)1 Policies (com.yahoo.pulsar.common.policies.data.Policies)1 LocalZooKeeperCache (com.yahoo.pulsar.zookeeper.LocalZooKeeperCache)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.testng.annotations.Test)1