org.apache.pulsar.common.policies.data.ClusterData Java Examples
The following examples show how to use
org.apache.pulsar.common.policies.data.ClusterData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClustersImpl.java From pulsar with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<ClusterData> getClusterAsync(String cluster) { WebTarget path = adminClusters.path(cluster); final CompletableFuture<ClusterData> future = new CompletableFuture<>(); asyncGetRequest(path, new InvocationCallback<ClusterData>() { @Override public void completed(ClusterData clusterData) { future.complete(clusterData); } @Override public void failed(Throwable throwable) { future.completeExceptionally(getApiException(throwable.getCause())); } }); return future; }
Example #2
Source File: IncrementPartitionsTest.java From pulsar with Apache License 2.0 | 6 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); super.internalSetup(); // create otherbroker to test redirect on calls that need // namespace ownership mockPulsarSetup = new MockedPulsarService(this.conf); mockPulsarSetup.setup(); // Setup namespaces admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("use")); admin.tenants().createTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/use/ns1"); }
Example #3
Source File: EnvironmentCacheServiceImpl.java From pulsar-manager with Apache License 2.0 | 6 votes |
private String getServiceUrl(String environment, String cluster, int numReloads) { // if there is a cluster specified, lookup the cluster. Map<String, ClusterData> clusters = environments.get(environment); ClusterData clusterData; if (null == clusters) { clusterData = reloadCluster(environment, cluster); } else { clusterData = clusters.get(cluster); if (clusterData == null) { clusterData = reloadCluster(environment, cluster); } } if (null == clusterData) { // no environment and no cluster throw new RuntimeException( "No cluster '" + cluster + "' found in environment '" + environment + "'"); } return clusterData.getServiceUrl(); }
Example #4
Source File: AdminApiTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testCreateAndDeleteNamespaceWithBundles() throws Exception { admin.clusters().createCluster("usw", new ClusterData()); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test", "usw")); admin.tenants().updateTenant("prop-xyz", tenantInfo); String ns = "prop-xyz/ns-" + System.nanoTime(); admin.namespaces().createNamespace(ns, 24); admin.namespaces().deleteNamespace(ns); // Re-create and re-delete admin.namespaces().createNamespace(ns, 32); admin.namespaces().deleteNamespace(ns); }
Example #5
Source File: ClustersServiceImplTest.java From pulsar-manager with Apache License 2.0 | 6 votes |
@Test public void clusterServiceImplTest() throws PulsarAdminException { Mockito.when(pulsarAdminService.clusters("http://localhost:8080")).thenReturn(clusters); Mockito.when(pulsarAdminService.clusters("http://localhost:8080").getClusters()).thenReturn(Arrays.asList("standalone")); ClusterData standaloneClusterData = new ClusterData("http://broker-1:8080", null, "pulsar://broker-1:6650", null); Mockito.when(pulsarAdminService.clusters("http://localhost:8080").getCluster("standalone")).thenReturn(standaloneClusterData); Map<String, Object> brokerEntity = Maps.newHashMap(); brokerEntity.put("broker", "broker-1:8080"); brokerEntity.put("failureDomain", null); List<Map<String, Object>> brokersArray = new ArrayList<>(); brokersArray.add(brokerEntity); Map<String, Object> brokersMap = new HashMap<>(); brokersMap.put("isPage", false); brokersMap.put("total", brokersArray.size()); brokersMap.put("data", brokersArray); brokersMap.put("pageNum", 1); brokersMap.put("pageSize", brokersArray.size()); Mockito.when(brokersService.getBrokersList(1, 1, "standalone", "http://localhost:8080")).thenReturn(brokersMap); Map<String, Object> result = clustersService.getClustersList(1, 1, "http://localhost:8080", null); Assert.assertEquals("[{cluster=standalone, serviceUrlTls=null, brokers=1, serviceUrl=http://broker-1:8080, " + "brokerServiceUrlTls=null, brokerServiceUrl=pulsar://broker-1:6650}]", result.get("data").toString()); Assert.assertEquals(1, result.get("total")); Assert.assertEquals(1, result.get("pageSize")); }
Example #6
Source File: AdminApiKeyStoreTlsAuthTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test public void testAuthorizedUserAsOriginalPrincipal() throws Exception { try (PulsarAdmin admin = buildAdminClient()) { admin.clusters().createCluster("test", new ClusterData(brokerUrl.toString())); admin.tenants().createTenant("tenant1", new TenantInfo(ImmutableSet.of("proxy", "user1"), ImmutableSet.of("test"))); admin.namespaces().createNamespace("tenant1/ns1"); } WebTarget root = buildWebClient(); Assert.assertEquals(ImmutableSet.of("tenant1/ns1"), root.path("/admin/v2/namespaces").path("tenant1") .request(MediaType.APPLICATION_JSON) .header("X-Original-Principal", "user1") .get(new GenericType<List<String>>() {})); }
Example #7
Source File: PulsarWebResource.java From pulsar with Apache License 2.0 | 6 votes |
/** * Check if the cluster exists and redirect the call to the owning cluster * * @param cluster * Cluster name * @throws Exception * In case the redirect happens */ protected void validateClusterOwnership(String cluster) throws WebApplicationException { try { ClusterData differentClusterData = getClusterDataIfDifferentCluster(pulsar(), cluster, clientAppId()).get(); if (differentClusterData != null) { URI redirect = getRedirectionUrl(differentClusterData); // redirect to the cluster requested if (log.isDebugEnabled()) { log.debug("[{}] Redirecting the rest call to {}: cluster={}", clientAppId(), redirect, cluster); } throw new WebApplicationException(Response.temporaryRedirect(redirect).build()); } } catch (WebApplicationException wae) { throw wae; } catch (Exception e) { if (e.getCause() instanceof WebApplicationException) { throw (WebApplicationException) e.getCause(); } throw new RestException(Status.SERVICE_UNAVAILABLE, String .format("Failed to validate Cluster configuration : cluster=%s emsg=%s", cluster, e.getMessage())); } }
Example #8
Source File: ZooKeeperSessionExpireRecoveryTest.java From pulsar with Apache License 2.0 | 6 votes |
/** * Verify we are able to recover when receiving a SessionExpired event on global ZK session */ @Test public void testSessionExpired() throws Exception { admin.clusters().createCluster("my-cluster", new ClusterData("test-url")); assertTrue(Sets.newHashSet(admin.clusters().getClusters()).contains("my-cluster")); mockZooKeeper.failConditional(Code.SESSIONEXPIRED, (op, path) -> { return op == MockZooKeeper.Op.CREATE && path.equals("/admin/clusters/my-cluster-2"); }); assertTrue(Sets.newHashSet(admin.clusters().getClusters()).contains("my-cluster")); try { admin.clusters().createCluster("my-cluster-2", new ClusterData("test-url")); fail("Should have failed, because global zk is down"); } catch (PulsarAdminException e) { // Ok } admin.clusters().createCluster("cluster-2", new ClusterData("test-url")); }
Example #9
Source File: KeyStoreTlsProducerConsumerTestWithAuth.java From pulsar with Apache License 2.0 | 6 votes |
protected void internalSetUpForNamespace() throws Exception { Map<String, String> authParams = new HashMap<>(); authParams.put(AuthenticationKeyStoreTls.KEYSTORE_PATH, CLIENT_KEYSTORE_FILE_PATH); authParams.put(AuthenticationKeyStoreTls.KEYSTORE_PW, CLIENT_KEYSTORE_PW); if (admin != null) { admin.close(); } admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrlTls.toString()) .useKeyStoreTls(true) .tlsTrustStorePath(BROKER_TRUSTSTORE_FILE_PATH) .tlsTrustStorePassword(BROKER_TRUSTSTORE_PW) .allowTlsInsecureConnection(false) .authentication(AuthenticationKeyStoreTls.class.getName(), authParams).build()); admin.clusters().createCluster(clusterName, new ClusterData(brokerUrl.toString(), brokerUrlTls.toString(), pulsar.getBrokerServiceUrl(), pulsar.getBrokerServiceUrlTls())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use"))); admin.namespaces().createNamespace("my-property/my-ns"); }
Example #10
Source File: TlsProducerConsumerBase.java From pulsar with Apache License 2.0 | 6 votes |
protected void internalSetUpForNamespace() throws Exception { Map<String, String> authParams = new HashMap<>(); authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH); authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH); if (admin != null) { admin.close(); } admin = spy(PulsarAdmin.builder().serviceHttpUrl(brokerUrlTls.toString()) .tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).allowTlsInsecureConnection(false) .authentication(AuthenticationTls.class.getName(), authParams).build()); admin.clusters().createCluster(clusterName, new ClusterData(brokerUrl.toString(), brokerUrlTls.toString(), pulsar.getBrokerServiceUrl(), pulsar.getBrokerServiceUrlTls())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use"))); admin.namespaces().createNamespace("my-property/my-ns"); }
Example #11
Source File: AuthenticatedProducerConsumerTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test(dataProvider = "batch") public void testBasicCryptSyncProducerAndConsumer(int batchMessageDelayMs) throws Exception { log.info("-- Starting {} test --", methodName); AuthenticationBasic authPassword = new AuthenticationBasic(); authPassword.configure("{\"userId\":\"superUser\",\"password\":\"supepass\"}"); internalSetup(authPassword); admin.clusters().createCluster("test", new ClusterData(brokerUrl.toString())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet(), Sets.newHashSet("test"))); admin.namespaces().createNamespace("my-property/my-ns", Sets.newHashSet("test")); testSyncProducerAndConsumer(batchMessageDelayMs); log.info("-- Exiting {} test --", methodName); }
Example #12
Source File: V1_AdminApiTest2.java From pulsar with Apache License 2.0 | 6 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); super.internalSetup(); // create otherbroker to test redirect on calls that need // namespace ownership mockPulsarSetup = new MockedPulsarService(this.conf); mockPulsarSetup.setup(); // Setup namespaces admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("use")); admin.tenants().createTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/use/ns1"); }
Example #13
Source File: SystemTopicBasedTopicPoliciesServiceTest.java From pulsar with Apache License 2.0 | 6 votes |
private void prepareData() throws PulsarAdminException { admin.clusters().createCluster("test", new ClusterData(pulsar.getBrokerServiceUrl())); admin.tenants().createTenant("system-topic", new TenantInfo(Sets.newHashSet(), Sets.newHashSet("test"))); admin.namespaces().createNamespace(NAMESPACE1); admin.namespaces().createNamespace(NAMESPACE2); admin.namespaces().createNamespace(NAMESPACE3); admin.lookups().lookupTopic(TOPIC1.toString()); admin.lookups().lookupTopic(TOPIC2.toString()); admin.lookups().lookupTopic(TOPIC3.toString()); admin.lookups().lookupTopic(TOPIC4.toString()); admin.lookups().lookupTopic(TOPIC5.toString()); admin.lookups().lookupTopic(TOPIC6.toString()); systemTopicFactory = new NamespaceEventsSystemTopicFactory(pulsarClient); systemTopicBasedTopicPoliciesService = (SystemTopicBasedTopicPoliciesService) pulsar.getTopicPoliciesService(); }
Example #14
Source File: AdminApiTest2.java From pulsar with Apache License 2.0 | 6 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); super.internalSetup(); // create otherbroker to test redirect on calls that need // namespace ownership mockPulsarSetup = new MockedPulsarService(this.conf); mockPulsarSetup.setup(); // Setup namespaces admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); admin.tenants().createTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/ns1", Sets.newHashSet("test")); }
Example #15
Source File: AuthenticatedProducerConsumerTest.java From pulsar with Apache License 2.0 | 6 votes |
@Test(dataProvider = "batch") public void testBasicArp1SyncProducerAndConsumer(int batchMessageDelayMs) throws Exception { log.info("-- Starting {} test --", methodName); AuthenticationBasic authPassword = new AuthenticationBasic(); authPassword.configure("{\"userId\":\"superUser2\",\"password\":\"superpassword\"}"); internalSetup(authPassword); admin.clusters().createCluster("test", new ClusterData(brokerUrl.toString())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet(), Sets.newHashSet("test"))); admin.namespaces().createNamespace("my-property/my-ns", Sets.newHashSet("test")); testSyncProducerAndConsumer(batchMessageDelayMs); log.info("-- Exiting {} test --", methodName); }
Example #16
Source File: NamespacesBase.java From pulsar with Apache License 2.0 | 6 votes |
/** * It validates that peer-clusters can't coexist in replication-clusters * * @param clusterName: * given cluster whose peer-clusters can't be present into replication-cluster list * @param replicationClusters: * replication-cluster list */ private void validatePeerClusterConflict(String clusterName, Set<String> replicationClusters) { try { ClusterData clusterData = clustersCache().get(path("clusters", clusterName)).orElseThrow( () -> new RestException(Status.PRECONDITION_FAILED, "Invalid replication cluster " + clusterName)); Set<String> peerClusters = clusterData.getPeerClusterNames(); if (peerClusters != null && !peerClusters.isEmpty()) { SetView<String> conflictPeerClusters = Sets.intersection(peerClusters, replicationClusters); if (!conflictPeerClusters.isEmpty()) { log.warn("[{}] {}'s peer cluster can't be part of replication clusters {}", clientAppId(), clusterName, conflictPeerClusters); throw new RestException(Status.CONFLICT, String.format("%s's peer-clusters %s can't be part of replication-clusters %s", clusterName, conflictPeerClusters, replicationClusters)); } } } catch (RestException re) { throw re; } catch (Exception e) { log.warn("[{}] Failed to get cluster-data for {}", clientAppId(), clusterName, e); } }
Example #17
Source File: AdminApiTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); conf.setBrokerServicePortTls(Optional.of(0)); conf.setWebServicePortTls(Optional.of(0)); conf.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH); conf.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH); conf.setMessageExpiryCheckIntervalInMinutes(1); conf.setSubscriptionExpiryCheckIntervalInMinutes(1); conf.setBrokerDeleteInactiveTopicsEnabled(false); super.internalSetup(); bundleFactory = new NamespaceBundleFactory(pulsar, Hashing.crc32()); adminTls = spy(PulsarAdmin.builder().tlsTrustCertsFilePath(TLS_SERVER_CERT_FILE_PATH) .serviceHttpUrl(brokerUrlTls.toString()).build()); // create otherbroker to test redirect on calls that need // namespace ownership mockPulsarSetup = new MockedPulsarService(this.conf); mockPulsarSetup.setup(); otherPulsar = mockPulsarSetup.getPulsar(); otheradmin = mockPulsarSetup.getAdmin(); // Setup namespaces admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); admin.tenants().createTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/ns1", Sets.newHashSet("test")); }
Example #18
Source File: AdminApiDelayedDelivery.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); admin.tenants().createTenant("delayed-delivery-messages", tenantInfo); }
Example #19
Source File: V1_AdminApiTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); conf.setBrokerServicePortTls(Optional.of(0)); conf.setWebServicePortTls(Optional.of(0)); conf.setTlsCertificateFilePath(TLS_SERVER_CERT_FILE_PATH); conf.setTlsKeyFilePath(TLS_SERVER_KEY_FILE_PATH); super.internalSetup(); bundleFactory = new NamespaceBundleFactory(pulsar, Hashing.crc32()); adminTls = spy(PulsarAdmin.builder().tlsTrustCertsFilePath(TLS_SERVER_CERT_FILE_PATH) .serviceHttpUrl(brokerUrlTls.toString()).build()); // create otherbroker to test redirect on calls that need // namespace ownership mockPulsarSetup = new MockedPulsarService(this.conf); mockPulsarSetup.setup(); otherPulsar = mockPulsarSetup.getPulsar(); otheradmin = mockPulsarSetup.getAdmin(); // Setup namespaces admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("use")); admin.tenants().createTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/use/ns1"); }
Example #20
Source File: AdminApiSchemaValidationEnforced.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test")); admin.tenants().createTenant("schema-validation-enforced", tenantInfo); }
Example #21
Source File: SchemaDeleteTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override protected void setup() throws Exception { super.internalSetup(); this.conf.setBrokerDeleteInactiveTopicsFrequencySeconds(5); admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("test"))); admin.namespaces().createNamespace("my-property/my-ns", Sets.newHashSet("test")); }
Example #22
Source File: AdminApiKeyStoreTlsAuthTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testSuperUserCanListTenants() throws Exception { try (PulsarAdmin admin = buildAdminClient()) { admin.clusters().createCluster("test", new ClusterData(brokerUrl.toString())); admin.tenants().createTenant("tenant1", new TenantInfo(ImmutableSet.of("foobar"), ImmutableSet.of("test"))); Assert.assertEquals(ImmutableSet.of("tenant1"), admin.tenants().getTenants()); } }
Example #23
Source File: NamespaceService.java From pulsar with Apache License 2.0 | 5 votes |
public PulsarClientImpl getNamespaceClient(ClusterData cluster) { PulsarClientImpl client = namespaceClients.get(cluster); if (client != null) { return client; } return namespaceClients.computeIfAbsent(cluster, key -> { try { ClientBuilder clientBuilder = PulsarClient.builder() .enableTcpNoDelay(false) .statsInterval(0, TimeUnit.SECONDS); if (pulsar.getConfiguration().isAuthenticationEnabled()) { clientBuilder.authentication(pulsar.getConfiguration().getBrokerClientAuthenticationPlugin(), pulsar.getConfiguration().getBrokerClientAuthenticationParameters()); } if (pulsar.getConfiguration().isTlsEnabled()) { clientBuilder .serviceUrl(isNotBlank(cluster.getBrokerServiceUrlTls()) ? cluster.getBrokerServiceUrlTls() : cluster.getServiceUrlTls()) .enableTls(true) .tlsTrustCertsFilePath(pulsar.getConfiguration().getBrokerClientTrustCertsFilePath()) .allowTlsInsecureConnection(pulsar.getConfiguration().isTlsAllowInsecureConnection()); } else { clientBuilder.serviceUrl(isNotBlank(cluster.getBrokerServiceUrl()) ? cluster.getBrokerServiceUrl() : cluster.getServiceUrl()); } // Share all the IO threads across broker and client connections ClientConfigurationData conf = ((ClientBuilderImpl) clientBuilder).getClientConfigurationData(); return new PulsarClientImpl(conf, (EventLoopGroup)pulsar.getBrokerService().executor()); } catch (Exception e) { throw new RuntimeException(e); } }); }
Example #24
Source File: AdminApiTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testTopicBundleRangeLookup() throws PulsarAdminException, PulsarServerException, Exception { admin.clusters().createCluster("usw", new ClusterData()); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test", "usw")); admin.tenants().updateTenant("prop-xyz", tenantInfo); admin.namespaces().createNamespace("prop-xyz/getBundleNs", 100); assertEquals(admin.namespaces().getPolicies("prop-xyz/getBundleNs").bundles.numBundles, 100); // (1) create a topic final String topicName = "persistent://prop-xyz/getBundleNs/topic1"; String bundleRange = admin.lookups().getBundleRange(topicName); assertEquals(bundleRange, pulsar.getNamespaceService().getBundle(TopicName.get(topicName)).getBundleRange()); }
Example #25
Source File: RawReaderTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("test", new ClusterData(pulsar.getWebServiceAddress())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("test"))); admin.namespaces().createNamespace("my-property/my-ns", Sets.newHashSet("test")); }
Example #26
Source File: AdminApiTlsAuthTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { conf.setLoadBalancerEnabled(true); conf.setBrokerServicePortTls(Optional.of(0)); conf.setWebServicePortTls(Optional.of(0)); conf.setTlsCertificateFilePath(getTLSFile("broker.cert")); conf.setTlsKeyFilePath(getTLSFile("broker.key-pk8")); conf.setTlsTrustCertsFilePath(getTLSFile("ca.cert")); conf.setAuthenticationEnabled(true); conf.setAuthenticationProviders( ImmutableSet.of("org.apache.pulsar.broker.authentication.AuthenticationProviderTls")); conf.setSuperUserRoles(ImmutableSet.of("admin", "superproxy")); conf.setProxyRoles(ImmutableSet.of("proxy", "superproxy")); conf.setAuthorizationEnabled(true); conf.setBrokerClientAuthenticationPlugin("org.apache.pulsar.client.impl.auth.AuthenticationTls"); conf.setBrokerClientAuthenticationParameters( String.format("tlsCertFile:%s,tlsKeyFile:%s", getTLSFile("admin.cert"), getTLSFile("admin.key-pk8"))); conf.setBrokerClientTrustCertsFilePath(getTLSFile("ca.cert")); conf.setBrokerClientTlsEnabled(true); super.internalSetup(); PulsarAdmin admin = buildAdminClient("admin"); admin.clusters().createCluster("test", new ClusterData(brokerUrl.toString())); admin.close(); }
Example #27
Source File: SchemaTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); // Setup namespaces admin.clusters().createCluster(CLUSTER_NAME, new ClusterData(pulsar.getBrokerServiceUrl())); TenantInfo tenantInfo = new TenantInfo(); tenantInfo.setAllowedClusters(Collections.singleton(CLUSTER_NAME)); admin.tenants().createTenant(PUBLIC_TENANT, tenantInfo); }
Example #28
Source File: CompactionTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use"))); admin.namespaces().createNamespace("my-property/use/my-ns"); compactionScheduler = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("compaction-%d").setDaemon(true).build()); bk = pulsar.getBookKeeperClientFactory().create(this.conf, null, Optional.empty(), null); }
Example #29
Source File: CompactorTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use"))); admin.namespaces().createNamespace("my-property/use/my-ns"); compactionScheduler = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("compactor").setDaemon(true).build()); }
Example #30
Source File: CompactedTopicTest.java From pulsar with Apache License 2.0 | 5 votes |
@BeforeMethod @Override public void setup() throws Exception { super.internalSetup(); admin.clusters().createCluster("use", new ClusterData(pulsar.getWebServiceAddress())); admin.tenants().createTenant("my-property", new TenantInfo(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet("use"))); admin.namespaces().createNamespace("my-property/use/my-ns"); }