Search in sources :

Example 1 with JAVA_INSTANCE_JAR_PROPERTY

use of org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY in project pulsar by yahoo.

the class AbstractPulsarE2ETest method setup.

@BeforeMethod(alwaysRun = true)
public void setup(Method method) throws Exception {
    log.info("--- Setting up method {} ---", method.getName());
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();
    config = spy(ServiceConfiguration.class);
    config.setClusterName("use");
    Set<String> superUsers = Sets.newHashSet("superUser", "admin");
    config.setSuperUserRoles(superUsers);
    config.setWebServicePort(Optional.of(0));
    config.setWebServicePortTls(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerShutdownTimeoutMs(0L);
    config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d));
    config.setBrokerServicePort(Optional.of(0));
    config.setBrokerServicePortTls(Optional.of(0));
    config.setLoadManagerClassName(SimpleLoadManagerImpl.class.getName());
    config.setTlsAllowInsecureConnection(true);
    config.setAdvertisedAddress("localhost");
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    config.setAuthenticationEnabled(true);
    config.setAuthenticationProviders(providers);
    config.setAuthorizationEnabled(true);
    config.setAuthorizationProvider(PulsarAuthorizationProvider.class.getName());
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + "," + "tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTlsEnabled(true);
    config.setAllowAutoTopicCreationType("non-partitioned");
    System.setProperty(JAVA_INSTANCE_JAR_PROPERTY, FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    functionsWorkerService = createPulsarFunctionWorker(config);
    // populate builtin connectors folder
    if (Arrays.asList(method.getAnnotation(Test.class).groups()).contains("builtin")) {
        File connectorsDir = new File(workerConfig.getConnectorsDirectory());
        File file = getPulsarIODataGeneratorNar();
        Files.copy(file.toPath(), new File(connectorsDir, file.getName()).toPath());
        file = getPulsarIOBatchDataGeneratorNar();
        Files.copy(file.toPath(), new File(connectorsDir, file.getName()).toPath());
    }
    Optional<WorkerService> functionWorkerService = Optional.of(functionsWorkerService);
    pulsar = new PulsarService(config, workerConfig, functionWorkerService, (exitCode) -> {
    });
    pulsar.start();
    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    admin = spy(PulsarAdmin.builder().serviceHttpUrl(pulsar.getWebServiceAddressTls()).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true).authentication(authTls).build());
    brokerStatsClient = admin.brokerStats();
    primaryHost = String.format("http://%s:%d", "localhost", pulsar.getListenPortHTTP().get());
    // update cluster metadata
    ClusterData clusterData = ClusterData.builder().serviceUrl(pulsar.getBrokerServiceUrlTls()).build();
    admin.clusters().updateCluster(config.getClusterName(), clusterData);
    ClientBuilder clientBuilder = PulsarClient.builder().serviceUrl(this.workerConfig.getPulsarServiceUrl());
    if (isNotBlank(workerConfig.getBrokerClientAuthenticationPlugin()) && isNotBlank(workerConfig.getBrokerClientAuthenticationParameters())) {
        clientBuilder.enableTls(workerConfig.isUseTls());
        clientBuilder.allowTlsInsecureConnection(workerConfig.isTlsAllowInsecureConnection());
        clientBuilder.authentication(workerConfig.getBrokerClientAuthenticationPlugin(), workerConfig.getBrokerClientAuthenticationParameters());
    }
    if (pulsarClient != null) {
        pulsarClient.close();
    }
    pulsarClient = clientBuilder.build();
    TenantInfo propAdmin = TenantInfo.builder().adminRoles(Collections.singleton("superUser")).allowedClusters(Collections.singleton("use")).build();
    admin.tenants().updateTenant(tenant, propAdmin);
    assertTrue(getPulsarIODataGeneratorNar().exists(), "pulsar-io-data-generator.nar file " + getPulsarIODataGeneratorNar().getAbsolutePath() + " doesn't exist.");
    assertTrue(getPulsarIOBatchDataGeneratorNar().exists(), "pulsar-io-batch-data-generator.nar file " + getPulsarIOBatchDataGeneratorNar().getAbsolutePath() + " doesn't exist.");
    assertTrue(getPulsarApiExamplesJar().exists(), "pulsar-functions-api-examples.jar file " + getPulsarApiExamplesJar().getAbsolutePath() + " doesn't exist.");
    // setting up simple web server to test submitting function via URL
    fileServer = new FileServer();
    fileServer.serveFile("/pulsar-io-data-generator.nar", getPulsarIODataGeneratorNar());
    fileServer.serveFile("/pulsar-io-batch-data-generator.nar", getPulsarIOBatchDataGeneratorNar());
    fileServer.serveFile("/pulsar-functions-api-examples.jar", getPulsarApiExamplesJar());
    fileServer.start();
    Awaitility.await().until(() -> functionsWorkerService.getLeaderService().isLeader());
}
Also used : Arrays(java.util.Arrays) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AfterMethod(org.testng.annotations.AfterMethod) PulsarWorkerService(org.apache.pulsar.functions.worker.PulsarWorkerService) Map(java.util.Map) ThreadRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactoryConfig) Method(java.lang.reflect.Method) PulsarFunctionLocalRunTest.getPulsarIODataGeneratorNar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarIODataGeneratorNar) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) WorkerConfig(org.apache.pulsar.functions.worker.WorkerConfig) Sets(com.google.common.collect.Sets) FutureUtil(org.apache.pulsar.common.util.FutureUtil) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ServiceConfigurationUtils(org.apache.pulsar.broker.ServiceConfigurationUtils) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) Optional(java.util.Optional) Awaitility(org.awaitility.Awaitility) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) DataProvider(org.testng.annotations.DataProvider) HashMap(java.util.HashMap) PulsarFunctionLocalRunTest.getPulsarApiExamplesJar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarApiExamplesJar) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Mockito.spy(org.mockito.Mockito.spy) HashSet(java.util.HashSet) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) PulsarFunctionLocalRunTest.getPulsarIOBatchDataGeneratorNar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarIOBatchDataGeneratorNar) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) PulsarFunctionTestTemporaryDirectory(org.apache.pulsar.functions.worker.PulsarFunctionTestTemporaryDirectory) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JAVA_INSTANCE_JAR_PROPERTY(org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) IOException(java.io.IOException) PulsarService(org.apache.pulsar.broker.PulsarService) File(java.io.File) FileServer(org.apache.pulsar.functions.worker.FileServer) Authentication(org.apache.pulsar.client.api.Authentication) Assert.assertTrue(org.testng.Assert.assertTrue) WorkerService(org.apache.pulsar.functions.worker.WorkerService) BrokerStats(org.apache.pulsar.client.admin.BrokerStats) Collections(java.util.Collections) HashMap(java.util.HashMap) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) PulsarWorkerService(org.apache.pulsar.functions.worker.PulsarWorkerService) WorkerService(org.apache.pulsar.functions.worker.WorkerService) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) PulsarService(org.apache.pulsar.broker.PulsarService) Test(org.testng.annotations.Test) Authentication(org.apache.pulsar.client.api.Authentication) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) File(java.io.File) FileServer(org.apache.pulsar.functions.worker.FileServer) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with JAVA_INSTANCE_JAR_PROPERTY

use of org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY in project incubator-pulsar by apache.

the class PulsarFunctionPublishTest method setup.

@BeforeMethod
void setup(Method method) throws Exception {
    log.info("--- Setting up method {} ---", method.getName());
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();
    config = spy(ServiceConfiguration.class);
    config.setClusterName("use");
    Set<String> superUsers = Sets.newHashSet("superUser", "admin");
    config.setSuperUserRoles(superUsers);
    config.setWebServicePort(Optional.of(0));
    config.setWebServicePortTls(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerShutdownTimeoutMs(0L);
    config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d));
    config.setBrokerServicePort(Optional.of(0));
    config.setBrokerServicePortTls(Optional.of(0));
    config.setLoadManagerClassName(SimpleLoadManagerImpl.class.getName());
    config.setTlsAllowInsecureConnection(true);
    config.setAdvertisedAddress("localhost");
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    config.setAuthenticationEnabled(true);
    config.setAuthenticationProviders(providers);
    config.setAuthorizationEnabled(true);
    config.setAuthorizationProvider(PulsarAuthorizationProvider.class.getName());
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + "," + "tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTlsEnabled(true);
    config.setAllowAutoTopicCreationType("non-partitioned");
    functionsWorkerService = createPulsarFunctionWorker(config);
    Optional<WorkerService> functionWorkerService = Optional.of(functionsWorkerService);
    pulsar = new PulsarService(config, workerConfig, functionWorkerService, (exitCode) -> {
    });
    pulsar.start();
    String brokerServiceUrl = pulsar.getWebServiceAddressTls();
    urlTls = new URL(brokerServiceUrl);
    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerServiceUrl).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true).authentication(authTls).build());
    brokerStatsClient = admin.brokerStats();
    primaryHost = pulsar.getWebServiceAddress();
    // update cluster metadata
    ClusterData clusterData = ClusterData.builder().serviceUrl(urlTls.toString()).build();
    admin.clusters().updateCluster(config.getClusterName(), clusterData);
    ClientBuilder clientBuilder = PulsarClient.builder().serviceUrl(this.workerConfig.getPulsarServiceUrl());
    if (isNotBlank(workerConfig.getBrokerClientAuthenticationPlugin()) && isNotBlank(workerConfig.getBrokerClientAuthenticationParameters())) {
        clientBuilder.enableTls(workerConfig.isUseTls());
        clientBuilder.allowTlsInsecureConnection(workerConfig.isTlsAllowInsecureConnection());
        clientBuilder.authentication(workerConfig.getBrokerClientAuthenticationPlugin(), workerConfig.getBrokerClientAuthenticationParameters());
    }
    if (pulsarClient != null) {
        pulsarClient.close();
    }
    pulsarClient = clientBuilder.build();
    TenantInfo propAdmin = TenantInfo.builder().adminRoles(Collections.singleton("superUser")).allowedClusters(Collections.singleton("use")).build();
    admin.tenants().updateTenant(tenant, propAdmin);
    System.setProperty(JAVA_INSTANCE_JAR_PROPERTY, FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    while (!functionsWorkerService.getLeaderService().isLeader()) {
        Thread.sleep(1000);
    }
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) URL(java.net.URL) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) Producer(org.apache.pulsar.client.api.Producer) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AfterMethod(org.testng.annotations.AfterMethod) Map(java.util.Map) NamespaceBuilder(org.apache.distributedlog.api.namespace.NamespaceBuilder) MockedPulsarServiceBaseTest.retryStrategically(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.retryStrategically) FunctionConfig(org.apache.pulsar.common.functions.FunctionConfig) URI(java.net.URI) ThreadRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactoryConfig) Method(java.lang.reflect.Method) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) Sets(com.google.common.collect.Sets) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) FutureUtil(org.apache.pulsar.common.util.FutureUtil) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ServiceConfigurationUtils(org.apache.pulsar.broker.ServiceConfigurationUtils) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) Optional(java.util.Optional) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) DataProvider(org.testng.annotations.DataProvider) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) PulsarFunctionLocalRunTest.getPulsarApiExamplesJar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarApiExamplesJar) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) HashSet(java.util.HashSet) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) Lists(com.google.common.collect.Lists) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) Assert(org.testng.Assert) DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) LinkedList(java.util.LinkedList) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) JAVA_INSTANCE_JAR_PROPERTY(org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) PulsarService(org.apache.pulsar.broker.PulsarService) File(java.io.File) Schema(org.apache.pulsar.client.api.Schema) TimeUnit(java.util.concurrent.TimeUnit) Namespace(org.apache.distributedlog.api.namespace.Namespace) FunctionStatsImpl(org.apache.pulsar.common.policies.data.FunctionStatsImpl) Authentication(org.apache.pulsar.client.api.Authentication) BrokerStats(org.apache.pulsar.client.admin.BrokerStats) Collections(java.util.Collections) HashMap(java.util.HashMap) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) URL(java.net.URL) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) PulsarService(org.apache.pulsar.broker.PulsarService) Authentication(org.apache.pulsar.client.api.Authentication) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with JAVA_INSTANCE_JAR_PROPERTY

use of org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY in project incubator-pulsar by apache.

the class AbstractPulsarE2ETest method setup.

@BeforeMethod(alwaysRun = true)
public void setup(Method method) throws Exception {
    log.info("--- Setting up method {} ---", method.getName());
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();
    config = spy(ServiceConfiguration.class);
    config.setClusterName("use");
    Set<String> superUsers = Sets.newHashSet("superUser", "admin");
    config.setSuperUserRoles(superUsers);
    config.setWebServicePort(Optional.of(0));
    config.setWebServicePortTls(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerShutdownTimeoutMs(0L);
    config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d));
    config.setBrokerServicePort(Optional.of(0));
    config.setBrokerServicePortTls(Optional.of(0));
    config.setLoadManagerClassName(SimpleLoadManagerImpl.class.getName());
    config.setTlsAllowInsecureConnection(true);
    config.setAdvertisedAddress("localhost");
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    config.setAuthenticationEnabled(true);
    config.setAuthenticationProviders(providers);
    config.setAuthorizationEnabled(true);
    config.setAuthorizationProvider(PulsarAuthorizationProvider.class.getName());
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + "," + "tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTlsEnabled(true);
    config.setAllowAutoTopicCreationType("non-partitioned");
    System.setProperty(JAVA_INSTANCE_JAR_PROPERTY, FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    functionsWorkerService = createPulsarFunctionWorker(config);
    // populate builtin connectors folder
    if (Arrays.asList(method.getAnnotation(Test.class).groups()).contains("builtin")) {
        File connectorsDir = new File(workerConfig.getConnectorsDirectory());
        File file = getPulsarIODataGeneratorNar();
        Files.copy(file.toPath(), new File(connectorsDir, file.getName()).toPath());
        file = getPulsarIOBatchDataGeneratorNar();
        Files.copy(file.toPath(), new File(connectorsDir, file.getName()).toPath());
    }
    Optional<WorkerService> functionWorkerService = Optional.of(functionsWorkerService);
    pulsar = new PulsarService(config, workerConfig, functionWorkerService, (exitCode) -> {
    });
    pulsar.start();
    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    admin = spy(PulsarAdmin.builder().serviceHttpUrl(pulsar.getWebServiceAddressTls()).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true).authentication(authTls).build());
    brokerStatsClient = admin.brokerStats();
    primaryHost = String.format("http://%s:%d", "localhost", pulsar.getListenPortHTTP().get());
    // update cluster metadata
    ClusterData clusterData = ClusterData.builder().serviceUrl(pulsar.getBrokerServiceUrlTls()).build();
    admin.clusters().updateCluster(config.getClusterName(), clusterData);
    ClientBuilder clientBuilder = PulsarClient.builder().serviceUrl(this.workerConfig.getPulsarServiceUrl());
    if (isNotBlank(workerConfig.getBrokerClientAuthenticationPlugin()) && isNotBlank(workerConfig.getBrokerClientAuthenticationParameters())) {
        clientBuilder.enableTls(workerConfig.isUseTls());
        clientBuilder.allowTlsInsecureConnection(workerConfig.isTlsAllowInsecureConnection());
        clientBuilder.authentication(workerConfig.getBrokerClientAuthenticationPlugin(), workerConfig.getBrokerClientAuthenticationParameters());
    }
    if (pulsarClient != null) {
        pulsarClient.close();
    }
    pulsarClient = clientBuilder.build();
    TenantInfo propAdmin = TenantInfo.builder().adminRoles(Collections.singleton("superUser")).allowedClusters(Collections.singleton("use")).build();
    admin.tenants().updateTenant(tenant, propAdmin);
    assertTrue(getPulsarIODataGeneratorNar().exists(), "pulsar-io-data-generator.nar file " + getPulsarIODataGeneratorNar().getAbsolutePath() + " doesn't exist.");
    assertTrue(getPulsarIOBatchDataGeneratorNar().exists(), "pulsar-io-batch-data-generator.nar file " + getPulsarIOBatchDataGeneratorNar().getAbsolutePath() + " doesn't exist.");
    assertTrue(getPulsarApiExamplesJar().exists(), "pulsar-functions-api-examples.jar file " + getPulsarApiExamplesJar().getAbsolutePath() + " doesn't exist.");
    // setting up simple web server to test submitting function via URL
    fileServer = new FileServer();
    fileServer.serveFile("/pulsar-io-data-generator.nar", getPulsarIODataGeneratorNar());
    fileServer.serveFile("/pulsar-io-batch-data-generator.nar", getPulsarIOBatchDataGeneratorNar());
    fileServer.serveFile("/pulsar-functions-api-examples.jar", getPulsarApiExamplesJar());
    fileServer.start();
    Awaitility.await().until(() -> functionsWorkerService.getLeaderService().isLeader());
}
Also used : Arrays(java.util.Arrays) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AfterMethod(org.testng.annotations.AfterMethod) PulsarWorkerService(org.apache.pulsar.functions.worker.PulsarWorkerService) Map(java.util.Map) ThreadRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactoryConfig) Method(java.lang.reflect.Method) PulsarFunctionLocalRunTest.getPulsarIODataGeneratorNar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarIODataGeneratorNar) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) WorkerConfig(org.apache.pulsar.functions.worker.WorkerConfig) Sets(com.google.common.collect.Sets) FutureUtil(org.apache.pulsar.common.util.FutureUtil) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ServiceConfigurationUtils(org.apache.pulsar.broker.ServiceConfigurationUtils) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) Optional(java.util.Optional) Awaitility(org.awaitility.Awaitility) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) DataProvider(org.testng.annotations.DataProvider) HashMap(java.util.HashMap) PulsarFunctionLocalRunTest.getPulsarApiExamplesJar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarApiExamplesJar) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Mockito.spy(org.mockito.Mockito.spy) HashSet(java.util.HashSet) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) PulsarFunctionLocalRunTest.getPulsarIOBatchDataGeneratorNar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarIOBatchDataGeneratorNar) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) PulsarFunctionTestTemporaryDirectory(org.apache.pulsar.functions.worker.PulsarFunctionTestTemporaryDirectory) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) Logger(org.slf4j.Logger) Files(java.nio.file.Files) JAVA_INSTANCE_JAR_PROPERTY(org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) IOException(java.io.IOException) PulsarService(org.apache.pulsar.broker.PulsarService) File(java.io.File) FileServer(org.apache.pulsar.functions.worker.FileServer) Authentication(org.apache.pulsar.client.api.Authentication) Assert.assertTrue(org.testng.Assert.assertTrue) WorkerService(org.apache.pulsar.functions.worker.WorkerService) BrokerStats(org.apache.pulsar.client.admin.BrokerStats) Collections(java.util.Collections) HashMap(java.util.HashMap) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) PulsarWorkerService(org.apache.pulsar.functions.worker.PulsarWorkerService) WorkerService(org.apache.pulsar.functions.worker.WorkerService) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) PulsarService(org.apache.pulsar.broker.PulsarService) Test(org.testng.annotations.Test) Authentication(org.apache.pulsar.client.api.Authentication) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) File(java.io.File) FileServer(org.apache.pulsar.functions.worker.FileServer) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with JAVA_INSTANCE_JAR_PROPERTY

use of org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY in project pulsar by yahoo.

the class PulsarFunctionPublishTest method setup.

@BeforeMethod
void setup(Method method) throws Exception {
    log.info("--- Setting up method {} ---", method.getName());
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();
    config = spy(ServiceConfiguration.class);
    config.setClusterName("use");
    Set<String> superUsers = Sets.newHashSet("superUser", "admin");
    config.setSuperUserRoles(superUsers);
    config.setWebServicePort(Optional.of(0));
    config.setWebServicePortTls(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerShutdownTimeoutMs(0L);
    config.setLoadBalancerOverrideBrokerNicSpeedGbps(Optional.of(1.0d));
    config.setBrokerServicePort(Optional.of(0));
    config.setBrokerServicePortTls(Optional.of(0));
    config.setLoadManagerClassName(SimpleLoadManagerImpl.class.getName());
    config.setTlsAllowInsecureConnection(true);
    config.setAdvertisedAddress("localhost");
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    config.setAuthenticationEnabled(true);
    config.setAuthenticationProviders(providers);
    config.setAuthorizationEnabled(true);
    config.setAuthorizationProvider(PulsarAuthorizationProvider.class.getName());
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + "," + "tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTlsEnabled(true);
    config.setAllowAutoTopicCreationType("non-partitioned");
    functionsWorkerService = createPulsarFunctionWorker(config);
    Optional<WorkerService> functionWorkerService = Optional.of(functionsWorkerService);
    pulsar = new PulsarService(config, workerConfig, functionWorkerService, (exitCode) -> {
    });
    pulsar.start();
    String brokerServiceUrl = pulsar.getWebServiceAddressTls();
    urlTls = new URL(brokerServiceUrl);
    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerServiceUrl).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true).authentication(authTls).build());
    brokerStatsClient = admin.brokerStats();
    primaryHost = pulsar.getWebServiceAddress();
    // update cluster metadata
    ClusterData clusterData = ClusterData.builder().serviceUrl(urlTls.toString()).build();
    admin.clusters().updateCluster(config.getClusterName(), clusterData);
    ClientBuilder clientBuilder = PulsarClient.builder().serviceUrl(this.workerConfig.getPulsarServiceUrl());
    if (isNotBlank(workerConfig.getBrokerClientAuthenticationPlugin()) && isNotBlank(workerConfig.getBrokerClientAuthenticationParameters())) {
        clientBuilder.enableTls(workerConfig.isUseTls());
        clientBuilder.allowTlsInsecureConnection(workerConfig.isTlsAllowInsecureConnection());
        clientBuilder.authentication(workerConfig.getBrokerClientAuthenticationPlugin(), workerConfig.getBrokerClientAuthenticationParameters());
    }
    if (pulsarClient != null) {
        pulsarClient.close();
    }
    pulsarClient = clientBuilder.build();
    TenantInfo propAdmin = TenantInfo.builder().adminRoles(Collections.singleton("superUser")).allowedClusters(Collections.singleton("use")).build();
    admin.tenants().updateTenant(tenant, propAdmin);
    System.setProperty(JAVA_INSTANCE_JAR_PROPERTY, FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    while (!functionsWorkerService.getLeaderService().isLeader()) {
        Thread.sleep(1000);
    }
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) URL(java.net.URL) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) Producer(org.apache.pulsar.client.api.Producer) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AfterMethod(org.testng.annotations.AfterMethod) Map(java.util.Map) NamespaceBuilder(org.apache.distributedlog.api.namespace.NamespaceBuilder) MockedPulsarServiceBaseTest.retryStrategically(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.retryStrategically) FunctionConfig(org.apache.pulsar.common.functions.FunctionConfig) URI(java.net.URI) ThreadRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactoryConfig) Method(java.lang.reflect.Method) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) Sets(com.google.common.collect.Sets) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) FutureUtil(org.apache.pulsar.common.util.FutureUtil) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ServiceConfigurationUtils(org.apache.pulsar.broker.ServiceConfigurationUtils) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) Optional(java.util.Optional) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) DataProvider(org.testng.annotations.DataProvider) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) PulsarFunctionLocalRunTest.getPulsarApiExamplesJar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarApiExamplesJar) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) HashSet(java.util.HashSet) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) Lists(com.google.common.collect.Lists) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) Assert(org.testng.Assert) DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) LinkedList(java.util.LinkedList) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) JAVA_INSTANCE_JAR_PROPERTY(org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) PulsarService(org.apache.pulsar.broker.PulsarService) File(java.io.File) Schema(org.apache.pulsar.client.api.Schema) TimeUnit(java.util.concurrent.TimeUnit) Namespace(org.apache.distributedlog.api.namespace.Namespace) FunctionStatsImpl(org.apache.pulsar.common.policies.data.FunctionStatsImpl) Authentication(org.apache.pulsar.client.api.Authentication) BrokerStats(org.apache.pulsar.client.admin.BrokerStats) Collections(java.util.Collections) HashMap(java.util.HashMap) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) URL(java.net.URL) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) PulsarService(org.apache.pulsar.broker.PulsarService) Authentication(org.apache.pulsar.client.api.Authentication) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with JAVA_INSTANCE_JAR_PROPERTY

use of org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY in project pulsar by apache.

the class PulsarFunctionPublishTest method setup.

@BeforeMethod
void setup(Method method) throws Exception {
    log.info("--- Setting up method {} ---", method.getName());
    // Start local bookkeeper ensemble
    bkEnsemble = new LocalBookkeeperEnsemble(3, 0, () -> 0);
    bkEnsemble.start();
    config = spy(ServiceConfiguration.class);
    config.setClusterName("use");
    Set<String> superUsers = Sets.newHashSet("superUser", "admin");
    config.setSuperUserRoles(superUsers);
    config.setWebServicePort(Optional.of(0));
    config.setWebServicePortTls(Optional.of(0));
    config.setZookeeperServers("127.0.0.1" + ":" + bkEnsemble.getZookeeperPort());
    config.setBrokerShutdownTimeoutMs(0L);
    config.setBrokerServicePort(Optional.of(0));
    config.setBrokerServicePortTls(Optional.of(0));
    config.setLoadManagerClassName(SimpleLoadManagerImpl.class.getName());
    config.setTlsAllowInsecureConnection(true);
    config.setAdvertisedAddress("localhost");
    Set<String> providers = new HashSet<>();
    providers.add(AuthenticationProviderTls.class.getName());
    config.setAuthenticationEnabled(true);
    config.setAuthenticationProviders(providers);
    config.setAuthorizationEnabled(true);
    config.setAuthorizationProvider(PulsarAuthorizationProvider.class.getName());
    config.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH);
    config.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH);
    config.setTlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientAuthenticationPlugin(AuthenticationTls.class.getName());
    config.setBrokerClientAuthenticationParameters("tlsCertFile:" + TLS_CLIENT_CERT_FILE_PATH + "," + "tlsKeyFile:" + TLS_CLIENT_KEY_FILE_PATH);
    config.setBrokerClientTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH);
    config.setBrokerClientTlsEnabled(true);
    config.setAllowAutoTopicCreationType("non-partitioned");
    functionsWorkerService = createPulsarFunctionWorker(config);
    Optional<WorkerService> functionWorkerService = Optional.of(functionsWorkerService);
    pulsar = new PulsarService(config, workerConfig, functionWorkerService, (exitCode) -> {
    });
    pulsar.start();
    String brokerServiceUrl = pulsar.getWebServiceAddressTls();
    urlTls = new URL(brokerServiceUrl);
    Map<String, String> authParams = new HashMap<>();
    authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerServiceUrl).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(true).authentication(authTls).build());
    brokerStatsClient = admin.brokerStats();
    primaryHost = pulsar.getWebServiceAddress();
    // update cluster metadata
    ClusterData clusterData = ClusterData.builder().serviceUrl(urlTls.toString()).build();
    admin.clusters().updateCluster(config.getClusterName(), clusterData);
    ClientBuilder clientBuilder = PulsarClient.builder().serviceUrl(this.workerConfig.getPulsarServiceUrl());
    if (isNotBlank(workerConfig.getBrokerClientAuthenticationPlugin()) && isNotBlank(workerConfig.getBrokerClientAuthenticationParameters())) {
        clientBuilder.enableTls(workerConfig.isUseTls());
        clientBuilder.allowTlsInsecureConnection(workerConfig.isTlsAllowInsecureConnection());
        clientBuilder.authentication(workerConfig.getBrokerClientAuthenticationPlugin(), workerConfig.getBrokerClientAuthenticationParameters());
    }
    if (pulsarClient != null) {
        pulsarClient.close();
    }
    pulsarClient = clientBuilder.build();
    TenantInfo propAdmin = TenantInfo.builder().adminRoles(Collections.singleton("superUser")).allowedClusters(Collections.singleton("use")).build();
    admin.tenants().updateTenant(tenant, propAdmin);
    System.setProperty(JAVA_INSTANCE_JAR_PROPERTY, FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    while (!functionsWorkerService.getLeaderService().isLeader()) {
        Thread.sleep(1000);
    }
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) URL(java.net.URL) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) Producer(org.apache.pulsar.client.api.Producer) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AfterMethod(org.testng.annotations.AfterMethod) Map(java.util.Map) NamespaceBuilder(org.apache.distributedlog.api.namespace.NamespaceBuilder) MockedPulsarServiceBaseTest.retryStrategically(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest.retryStrategically) FunctionConfig(org.apache.pulsar.common.functions.FunctionConfig) URI(java.net.URI) ThreadRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactoryConfig) Method(java.lang.reflect.Method) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) Sets(com.google.common.collect.Sets) Consumer(org.apache.pulsar.client.api.Consumer) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) FutureUtil(org.apache.pulsar.common.util.FutureUtil) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) ServiceConfigurationUtils(org.apache.pulsar.broker.ServiceConfigurationUtils) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) Optional(java.util.Optional) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) DataProvider(org.testng.annotations.DataProvider) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) PulsarFunctionLocalRunTest.getPulsarApiExamplesJar(org.apache.pulsar.functions.worker.PulsarFunctionLocalRunTest.getPulsarApiExamplesJar) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Message(org.apache.pulsar.client.api.Message) Mockito.spy(org.mockito.Mockito.spy) HashSet(java.util.HashSet) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) Lists(com.google.common.collect.Lists) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) Assert(org.testng.Assert) DistributedLogConfiguration(org.apache.distributedlog.DistributedLogConfiguration) LinkedList(java.util.LinkedList) PulsarClient(org.apache.pulsar.client.api.PulsarClient) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) JAVA_INSTANCE_JAR_PROPERTY(org.apache.pulsar.functions.utils.functioncache.FunctionCacheEntry.JAVA_INSTANCE_JAR_PROPERTY) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) PulsarService(org.apache.pulsar.broker.PulsarService) File(java.io.File) Schema(org.apache.pulsar.client.api.Schema) TimeUnit(java.util.concurrent.TimeUnit) Namespace(org.apache.distributedlog.api.namespace.Namespace) FunctionStatsImpl(org.apache.pulsar.common.policies.data.FunctionStatsImpl) Authentication(org.apache.pulsar.client.api.Authentication) BrokerStats(org.apache.pulsar.client.admin.BrokerStats) Collections(java.util.Collections) HashMap(java.util.HashMap) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) LocalBookkeeperEnsemble(org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble) URL(java.net.URL) AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) PulsarService(org.apache.pulsar.broker.PulsarService) Authentication(org.apache.pulsar.client.api.Authentication) PulsarAuthorizationProvider(org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider) HashSet(java.util.HashSet) AuthenticationProviderTls(org.apache.pulsar.broker.authentication.AuthenticationProviderTls) ClientBuilder(org.apache.pulsar.client.api.ClientBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Sets (com.google.common.collect.Sets)6 File (java.io.File)6 Method (java.lang.reflect.Method)6 Collections (java.util.Collections)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Optional (java.util.Optional)6 Set (java.util.Set)6 StringUtils.isNotBlank (org.apache.commons.lang3.StringUtils.isNotBlank)6 PulsarService (org.apache.pulsar.broker.PulsarService)6 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)6 ServiceConfigurationUtils (org.apache.pulsar.broker.ServiceConfigurationUtils)6 AuthenticationProviderTls (org.apache.pulsar.broker.authentication.AuthenticationProviderTls)6 PulsarAuthorizationProvider (org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider)6 SimpleLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl)6 BrokerStats (org.apache.pulsar.client.admin.BrokerStats)6 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)6 Authentication (org.apache.pulsar.client.api.Authentication)6 ClientBuilder (org.apache.pulsar.client.api.ClientBuilder)6