Search in sources :

Example 21 with PulsarAdmin

use of org.apache.pulsar.client.admin.PulsarAdmin in project incubator-pulsar by apache.

the class ProxyWithAuthorizationNegTest method createAdminClient.

protected final void createAdminClient() throws Exception {
    Map<String, String> authParams = Maps.newHashMap();
    authParams.put("tlsCertFile", TLS_SUPERUSER_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_SUPERUSER_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    org.apache.pulsar.client.api.ClientConfiguration clientConf = new org.apache.pulsar.client.api.ClientConfiguration();
    clientConf.setStatsInterval(0, TimeUnit.SECONDS);
    clientConf.setTlsTrustCertsFilePath(TLS_BROKER_TRUST_CERT_FILE_PATH);
    clientConf.setTlsAllowInsecureConnection(true);
    clientConf.setAuthentication(authTls);
    clientConf.setUseTls(true);
    admin = spy(new PulsarAdmin(brokerUrlTls, clientConf));
}
Also used : AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Authentication(org.apache.pulsar.client.api.Authentication)

Example 22 with PulsarAdmin

use of org.apache.pulsar.client.admin.PulsarAdmin in project incubator-pulsar by apache.

the class ProxyWithAuthorizationTest method createAdminClient.

protected final void createAdminClient() throws Exception {
    Map<String, String> authParams = Maps.newHashMap();
    authParams.put("tlsCertFile", TLS_SUPERUSER_CLIENT_CERT_FILE_PATH);
    authParams.put("tlsKeyFile", TLS_SUPERUSER_CLIENT_KEY_FILE_PATH);
    Authentication authTls = new AuthenticationTls();
    authTls.configure(authParams);
    org.apache.pulsar.client.api.ClientConfiguration clientConf = new org.apache.pulsar.client.api.ClientConfiguration();
    clientConf.setStatsInterval(0, TimeUnit.SECONDS);
    clientConf.setTlsTrustCertsFilePath(TLS_PROXY_TRUST_CERT_FILE_PATH);
    clientConf.setTlsAllowInsecureConnection(true);
    clientConf.setAuthentication(authTls);
    clientConf.setUseTls(true);
    admin = spy(new PulsarAdmin(brokerUrlTls, clientConf));
}
Also used : AuthenticationTls(org.apache.pulsar.client.impl.auth.AuthenticationTls) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Authentication(org.apache.pulsar.client.api.Authentication)

Example 23 with PulsarAdmin

use of org.apache.pulsar.client.admin.PulsarAdmin in project incubator-pulsar by apache.

the class PulsarService method getAdminClient.

public synchronized PulsarAdmin getAdminClient() throws PulsarServerException {
    if (this.adminClient == null) {
        try {
            String adminApiUrl = webAddress(config);
            this.adminClient = new PulsarAdmin(new URL(adminApiUrl), this.getConfiguration().getBrokerClientAuthenticationPlugin(), this.getConfiguration().getBrokerClientAuthenticationParameters());
            LOG.info("Admin api url: " + adminApiUrl);
        } catch (Exception e) {
            throw new PulsarServerException(e);
        }
    }
    return this.adminClient;
}
Also used : PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) URL(java.net.URL) IOException(java.io.IOException)

Example 24 with PulsarAdmin

use of org.apache.pulsar.client.admin.PulsarAdmin in project incubator-pulsar by apache.

the class PulsarAdminToolTest method nonPersistentTopics.

@Test
void nonPersistentTopics() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    NonPersistentTopics mockTopics = mock(NonPersistentTopics.class);
    when(admin.nonPersistentTopics()).thenReturn(mockTopics);
    CmdNonPersistentTopics topics = new CmdNonPersistentTopics(admin);
    topics.run(split("stats non-persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getStats("non-persistent://myprop/clust/ns1/ds1");
    topics.run(split("stats-internal non-persistent://myprop/clust/ns1/ds1"));
    verify(mockTopics).getInternalStats("non-persistent://myprop/clust/ns1/ds1");
    topics.run(split("create-partitioned-topic non-persistent://myprop/clust/ns1/ds1 --partitions 32"));
    verify(mockTopics).createPartitionedTopic("non-persistent://myprop/clust/ns1/ds1", 32);
    topics.run(split("list myprop/clust/ns1"));
    verify(mockTopics).getList("myprop/clust/ns1");
    topics.run(split("list-in-bundle myprop/clust/ns1 --bundle 0x23d70a30_0x26666658"));
    verify(mockTopics).getListInBundle("myprop/clust/ns1", "0x23d70a30_0x26666658");
}
Also used : NonPersistentTopics(org.apache.pulsar.client.admin.NonPersistentTopics) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Test(org.testng.annotations.Test)

Example 25 with PulsarAdmin

use of org.apache.pulsar.client.admin.PulsarAdmin in project incubator-pulsar by apache.

the class PulsarAdminToolTest method properties.

@Test
void properties() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    Properties mockProperties = mock(Properties.class);
    when(admin.properties()).thenReturn(mockProperties);
    CmdProperties properties = new CmdProperties(admin);
    properties.run(split("list"));
    verify(mockProperties).getProperties();
    PropertyAdmin propertyAdmin = new PropertyAdmin(Lists.newArrayList("role1", "role2"), Sets.newHashSet("use"));
    properties.run(split("create property --admin-roles role1,role2 --allowed-clusters use"));
    verify(mockProperties).createProperty("property", propertyAdmin);
    propertyAdmin = new PropertyAdmin(Lists.newArrayList("role1", "role2"), Sets.newHashSet("usw"));
    properties.run(split("update property --admin-roles role1,role2 --allowed-clusters usw"));
    verify(mockProperties).updateProperty("property", propertyAdmin);
    properties.run(split("get property"));
    verify(mockProperties).getPropertyAdmin("property");
    properties.run(split("delete property"));
    verify(mockProperties).deleteProperty("property");
}
Also used : PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) PropertyAdmin(org.apache.pulsar.common.policies.data.PropertyAdmin) Properties(org.apache.pulsar.client.admin.Properties) Test(org.testng.annotations.Test)

Aggregations

PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)39 URL (java.net.URL)15 Test (org.testng.annotations.Test)14 PulsarService (org.apache.pulsar.broker.PulsarService)12 Authentication (org.apache.pulsar.client.api.Authentication)11 PropertyAdmin (org.apache.pulsar.common.policies.data.PropertyAdmin)11 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)10 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)9 LocalBookkeeperEnsemble (org.apache.pulsar.zookeeper.LocalBookkeeperEnsemble)9 BeforeMethod (org.testng.annotations.BeforeMethod)7 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)6 AuthenticationTls (org.apache.pulsar.client.impl.auth.AuthenticationTls)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 URI (java.net.URI)3 ModularLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.ModularLoadManagerImpl)3 SimpleLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl)3 MalformedURLException (java.net.MalformedURLException)2 Brokers (org.apache.pulsar.client.admin.Brokers)2 ClientConfiguration (org.apache.pulsar.client.api.ClientConfiguration)2