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));
}
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));
}
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;
}
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");
}
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");
}
Aggregations