use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class TransactionBufferClientTest method setup.
@Override
@BeforeClass(alwaysRun = true)
protected void setup() throws Exception {
setBrokerCount(3);
internalSetup();
String[] brokerServiceUrlArr = getPulsarServiceList().get(0).getBrokerServiceUrl().split(":");
String webServicePort = brokerServiceUrlArr[brokerServiceUrlArr.length - 1];
admin.clusters().createCluster(CLUSTER_NAME, ClusterData.builder().serviceUrl("http://localhost:" + webServicePort).build());
admin.tenants().createTenant("public", new TenantInfoImpl(Sets.newHashSet("appid1"), Sets.newHashSet(CLUSTER_NAME)));
admin.namespaces().createNamespace(namespace, 10);
admin.topics().createPartitionedTopic(partitionedTopicName.getPartitionedTopicName(), partitions);
tbClient = TransactionBufferClientImpl.create(pulsarClient, new HashedWheelTimer(new DefaultThreadFactory("transaction-buffer")));
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class PartitionedSystemTopicTest method testConsumerCreationWhenEnablingTopicPolicy.
@Test(timeOut = 1000 * 60)
public void testConsumerCreationWhenEnablingTopicPolicy() throws Exception {
String tenant = "tenant-" + RandomStringUtils.randomAlphabetic(4).toLowerCase();
admin.tenants().createTenant(tenant, new TenantInfoImpl(Sets.newHashSet(), Sets.newHashSet("test")));
int namespaceCount = 30;
for (int i = 0; i < namespaceCount; i++) {
String ns = tenant + "/ns-" + i;
admin.namespaces().createNamespace(ns, 4);
String topic = ns + "/t1";
admin.topics().createPartitionedTopic(topic, 2);
}
List<CompletableFuture<Consumer<byte[]>>> futureList = new ArrayList<>();
for (int i = 0; i < namespaceCount; i++) {
String topic = tenant + "/ns-" + i + "/t1";
futureList.add(pulsarClient.newConsumer().topic(topic).subscriptionName("sub").subscribeAsync());
}
FutureUtil.waitForAll(futureList).get();
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class AuthenticatedProducerConsumerTest method testAnonymousSyncProducerAndConsumer.
@Test(dataProvider = "batch")
public void testAnonymousSyncProducerAndConsumer(int batchMessageDelayMs) throws Exception {
log.info("-- Starting {} test --", methodName);
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);
internalSetup(authTls);
admin.clusters().createCluster("test", ClusterData.builder().serviceUrl(brokerUrl.toString()).serviceUrlTls(brokerUrlTls.toString()).brokerServiceUrl(pulsar.getBrokerServiceUrl()).brokerServiceUrlTls(pulsar.getBrokerServiceUrlTls()).build());
admin.tenants().createTenant("my-property", new TenantInfoImpl(Sets.newHashSet("anonymousUser"), Sets.newHashSet("test")));
// make a PulsarAdmin instance as "anonymousUser" for http request
admin.close();
admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrl.toString()).build());
admin.namespaces().createNamespace("my-property/my-ns", Sets.newHashSet("test"));
admin.topics().grantPermission("persistent://my-property/my-ns/my-topic", "anonymousUser", EnumSet.allOf(AuthAction.class));
// setup the client
replacePulsarClient(PulsarClient.builder().serviceUrl(pulsar.getBrokerServiceUrl()).operationTimeout(1, TimeUnit.SECONDS));
pulsarClient.newConsumer().topic("persistent://my-property/my-ns/other-topic").subscriptionName("my-subscriber-name").subscribe();
testSyncProducerAndConsumer(batchMessageDelayMs);
log.info("-- Exiting {} test --", methodName);
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class TransactionConsumeTest method setup.
@BeforeMethod(alwaysRun = true)
public void setup() throws Exception {
setBrokerCount(1);
super.internalSetup();
String[] brokerServiceUrlArr = getPulsarServiceList().get(0).getBrokerServiceUrl().split(":");
String webServicePort = brokerServiceUrlArr[brokerServiceUrlArr.length - 1];
admin.clusters().createCluster(CLUSTER_NAME, ClusterData.builder().serviceUrl("http://localhost:" + webServicePort).build());
admin.tenants().createTenant("public", new TenantInfoImpl(Sets.newHashSet(), Sets.newHashSet(CLUSTER_NAME)));
admin.namespaces().createNamespace("public/txn", 10);
admin.topics().createNonPartitionedTopic(CONSUME_TOPIC);
admin.tenants().createTenant(NamespaceName.SYSTEM_NAMESPACE.getTenant(), new TenantInfoImpl(Sets.newHashSet("appid1"), Sets.newHashSet(CLUSTER_NAME)));
admin.namespaces().createNamespace(NamespaceName.SYSTEM_NAMESPACE.toString());
admin.topics().createPartitionedTopic(TopicName.TRANSACTION_COORDINATOR_ASSIGN.toString(), 1);
}
use of org.apache.pulsar.common.policies.data.TenantInfoImpl in project pulsar by apache.
the class TransactionTestBase method setUpBase.
protected void setUpBase(int numBroker, int numPartitionsOfTC, String topic, int numPartitions) throws Exception {
setBrokerCount(numBroker);
internalSetup();
String[] brokerServiceUrlArr = getPulsarServiceList().get(0).getBrokerServiceUrl().split(":");
String webServicePort = brokerServiceUrlArr[brokerServiceUrlArr.length - 1];
admin.clusters().createCluster(CLUSTER_NAME, ClusterData.builder().serviceUrl("http://localhost:" + webServicePort).build());
admin.tenants().createTenant(NamespaceName.SYSTEM_NAMESPACE.getTenant(), new TenantInfoImpl(Sets.newHashSet("appid1"), Sets.newHashSet(CLUSTER_NAME)));
admin.namespaces().createNamespace(NamespaceName.SYSTEM_NAMESPACE.toString());
admin.topics().createPartitionedTopic(TopicName.TRANSACTION_COORDINATOR_ASSIGN.toString(), numPartitionsOfTC);
if (topic != null) {
admin.tenants().createTenant(TENANT, new TenantInfoImpl(Sets.newHashSet("appid1"), Sets.newHashSet(CLUSTER_NAME)));
admin.namespaces().createNamespace(NAMESPACE1);
if (numPartitions == 0) {
admin.topics().createNonPartitionedTopic(topic);
} else {
admin.topics().createPartitionedTopic(topic, numPartitions);
}
}
if (pulsarClient != null) {
pulsarClient.shutdown();
}
pulsarClient = PulsarClient.builder().serviceUrl(getPulsarServiceList().get(0).getBrokerServiceUrl()).statsInterval(0, TimeUnit.SECONDS).enableTransaction(true).build();
}
Aggregations