yanshuchong opened a new issue #8681:
URL: https://github.com/apache/pulsar/issues/8681


   pulsar.version =  2.6.1
                <dependency>
                        <groupId>org.apache.pulsar</groupId>
                        <artifactId>pulsar-client</artifactId>
                        <version>${pulsar.version}</version>
                </dependency>
   
                <dependency>
                        <groupId>org.apache.pulsar</groupId>
                        <artifactId>pulsar-client-admin-original</artifactId>
                        <version>${pulsar.version}</version>
                        <scope>test</scope>
                </dependency>
   
   
        sample in pulsar website
      https://pulsar.apache.org/docs/en/admin-api-overview/
   
   String url = "http://localhost:8080,localhost:8081,localhost:8082";;
   // Pass auth-plugin class fully-qualified name if Pulsar-security enabled
   String authPluginClassName = "com.org.MyAuthPluginClass";
   // Pass auth-param if auth-plugin class requires it
   String authParams = "param1=value1";
   boolean useTls = false;
   boolean tlsAllowInsecureConnection = false;
   String tlsTrustCertsFilePath = null;
   PulsarAdmin admin = PulsarAdmin.builder()
   .authentication(authPluginClassName,authParams)
   .serviceHttpUrl(url)
   .tlsTrustCertsFilePath(tlsTrustCertsFilePath)
   .allowTlsInsecureConnection(tlsAllowInsecureConnection)
   .build();
   
   
   MY TEST CODE:
   
           PulsarAdminBuilder pulsarAdminBuilder = PulsarAdmin.builder()
               
.serviceHttpUrl("http://host-10-33-50-71:8080,host-10-33-50-144:8080,host-10-33-50-88:8080";);
   
           Map<String, String> authParams = Maps.newHashMap();
           authParams.put("saslJaasClientSectionName", "PulsarClient");
           authParams.put("serverType", "broker");
   
           Authentication saslAuth = 
AuthenticationFactory.create(AuthenticationSasl.class.getName(), authParams);
           // Authentication saslAuth =
           // 
AuthenticationFactory.create("org.apache.pulsar.client.impl.auth.AuthenticationSasl",
 authParams);
   
           clientBuilder.authentication(saslAuth);
           pulsarAdminBuilder.authentication(saslAuth);
   
           client = clientBuilder.build();
   
           adminClient = pulsarAdminBuilder.build();
   
           boolean batchingEnabled = true;
           boolean blockIfQueueFull = true;
           int batchingMaxPublishDelayMs = 1000;
           int pendingQueueSize = 1000;
   
           producerBuilder = client.newProducer()
               .enableBatching(batchingEnabled)
               .batchingMaxPublishDelay(batchingMaxPublishDelayMs, 
TimeUnit.MILLISECONDS)
               .blockIfQueueFull(blockIfQueueFull)
               .maxPendingMessages(pendingQueueSize);
   
           try {
               // Create namespace and set the configuration
               String tenant = "wangxiaotong";
               String cluster = "pulsar-cluster-1";
   
               System.out.println(adminClient.clusters().getClusters());
   
               System.out.println("init");
               List<String> tenants = adminClient.tenants().getTenants();
               System.out.println(tenants);
   
               if (!tenants.contains(tenant)) {
                   try {
                       adminClient.tenants()
                           .createTenant(tenant, new 
TenantInfo(Collections.emptySet(), Sets.newHashSet(cluster)));
                   } catch (ConflictException e) {
                       e.printStackTrace();
                   }
               }
   
           } catch (PulsarAdminException e) {
               throw new IOException(e);
           }
   
   
![image](https://user-images.githubusercontent.com/6071261/100095316-3f2f4780-2e95-11eb-9f1b-d1825d9ba1ad.png)
   
   
   and target.getUri().getHost() will return null
   
   
   
![image](https://user-images.githubusercontent.com/6071261/100095343-4bb3a000-2e95-11eb-85f6-c9acf6b67e86.png)
   
   
   then PulsarSaslClient will throw IllegalArgumentException
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to