Browse Source

MINOR: Make some constructors in admin package public

Add a public create API that takes a Properties instance.

Make the constructors for TopicDescription, TopicListing
and TopicPartitionInfo public to enable AdminClient
users to write better tests.

Author: Colin P. Mccabe <cmccabe@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #3070 from cmccabe/publicapi
pull/3079/head
Colin P. Mccabe 8 years ago committed by Ismael Juma
parent
commit
c36b5b7f6e
  1. 13
      clients/src/main/java/org/apache/kafka/clients/admin/AdminClient.java
  2. 2
      clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
  3. 2
      clients/src/main/java/org/apache/kafka/clients/admin/TopicDescription.java
  4. 2
      clients/src/main/java/org/apache/kafka/clients/admin/TopicListing.java
  5. 2
      clients/src/main/java/org/apache/kafka/clients/admin/TopicPartitionInfo.java

13
clients/src/main/java/org/apache/kafka/clients/admin/AdminClient.java

@ -22,6 +22,7 @@ import org.apache.kafka.common.annotation.InterfaceStability; @@ -22,6 +22,7 @@ import org.apache.kafka.common.annotation.InterfaceStability;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
/**
* The public interface for the {@link KafkaAdminClient}, which supports managing and inspecting topics,
@ -31,6 +32,16 @@ import java.util.Map; @@ -31,6 +32,16 @@ import java.util.Map;
*/
@InterfaceStability.Unstable
public abstract class AdminClient implements AutoCloseable {
/**
* Create a new AdminClient with the given configuration.
*
* @param props The configuration.
* @return The new KafkaAdminClient.
*/
public static AdminClient create(Properties props) {
return KafkaAdminClient.createInternal(new AdminClientConfig(props));
}
/**
* Create a new AdminClient with the given configuration.
*
@ -38,7 +49,7 @@ public abstract class AdminClient implements AutoCloseable { @@ -38,7 +49,7 @@ public abstract class AdminClient implements AutoCloseable {
* @return The new KafkaAdminClient.
*/
public static AdminClient create(Map<String, Object> conf) {
return KafkaAdminClient.create(new AdminClientConfig(conf));
return KafkaAdminClient.createInternal(new AdminClientConfig(conf));
}
/**

2
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java

@ -238,7 +238,7 @@ public class KafkaAdminClient extends AdminClient { @@ -238,7 +238,7 @@ public class KafkaAdminClient extends AdminClient {
return throwable.getClass().getSimpleName();
}
static KafkaAdminClient create(AdminClientConfig config) {
static KafkaAdminClient createInternal(AdminClientConfig config) {
Metadata metadata = null;
Metrics metrics = null;
NetworkClient networkClient = null;

2
clients/src/main/java/org/apache/kafka/clients/admin/TopicDescription.java

@ -29,7 +29,7 @@ public class TopicDescription { @@ -29,7 +29,7 @@ public class TopicDescription {
private final boolean internal;
private final NavigableMap<Integer, TopicPartitionInfo> partitions;
TopicDescription(String name, boolean internal,
public TopicDescription(String name, boolean internal,
NavigableMap<Integer, TopicPartitionInfo> partitions) {
this.name = name;
this.internal = internal;

2
clients/src/main/java/org/apache/kafka/clients/admin/TopicListing.java

@ -24,7 +24,7 @@ public class TopicListing { @@ -24,7 +24,7 @@ public class TopicListing {
private final String name;
private final boolean internal;
TopicListing(String name, boolean internal) {
public TopicListing(String name, boolean internal) {
this.name = name;
this.internal = internal;
}

2
clients/src/main/java/org/apache/kafka/clients/admin/TopicPartitionInfo.java

@ -28,7 +28,7 @@ public class TopicPartitionInfo { @@ -28,7 +28,7 @@ public class TopicPartitionInfo {
private final List<Node> replicas;
private final List<Node> isr;
TopicPartitionInfo(int partition, Node leader, List<Node> replicas, List<Node> isr) {
public TopicPartitionInfo(int partition, Node leader, List<Node> replicas, List<Node> isr) {
this.partition = partition;
this.leader = leader;
this.replicas = replicas;

Loading…
Cancel
Save