...
Overall, topic IDs provide a safer way for brokers to replicate topics without any chance of incorrectly interacting with stale topics with the same name. By preventing such scenarios, we can simplify a number of other interactions such as topic deletes which are currently more complicated and problematic than necessary.
Public Interfaces
...
Uuid
A new UUID Uuid class will be exposed under /org/apache/kafka/common
/* * This class defines an immutable universally unique identifier (UUIDUuid). It represents a 128-bit value. * More specifically, the random UUIDsUuids in this class are variant 2 (Leach-Salz) version 4 UUIDsUuids. * This definition is very similar to java.util.UUID. One notable difference is that the The toString() method prints
* using the base64 string encoding. Likewise, the fromString method expects a base64 string encoding. */ public class UUIDUuid { /** * A UUIDUuid where all bits are zero. It represents a null or empty UUIDUuid. */ public static final UUIDUuid ZERO_UUID /** * Constructs a 128-bit type 4 UUIDUuid where the first long represents the the most significant 64 bits * and the second long represents the least significant 64 bits. */ public UUIDUuid(long mostSigBits, long leastSigBits) /** * Static factory to retrieve a type 4 (pseudo randomly generated) UUIDUuid. */ public static UUIDUuid randomUUIDrandomUuid()
/** * Returns the most significant bits of the UUIDUuid's 128 bit value. */ public long getMostSignificantBits() /** * Returns the least significant bits of the UUIDUuid's 128 bit value. */ public long getLeastSignificantBits() /** * Returns true iff the obj is another UUIDUuid with the same value. */ public boolean equals(Object obj) /** * Returns a hash code for this UUIDUuid */ public int hashCode() /** * Returns a base64 string encoding of the UUIDUuid. */ public String toString()/** * Creates a UUIDUuid based on a base64 string encoding used in the toString() method. */ public static UUIDUuid fromString(String str)
}
Additionally, it may be dangerous to use older versions of Kafka tools with new broker versions when using their --zookeeper
flags. Use of older tools in this way is not supported today.
...
The protocol for CreateTopicsResponse will also need a slight modification.
CreateTopicsResponse v7
|
Describe Topics
There are two use cases we want to support. 1) Obtaining topic IDs when asking to describe topics and 2) supplying topic IDs to get a description of the topics
...
/**
* A unique identifier for the topic.
*/
public UUID topicId()
MetadataResponse v10
|
When topic IDs are supported, the response will contain both the topic name and the topic ID.
...
ID will be checked first, but if the value is the default zero UUID, topic name will be used instead. If an ID is specified and the ID does not exist, the request will fail regardless of allow_auto_topic_creation.
If the topic ID is not found, the request will return an UNKNOWN_TOPIC_ID
error for the topic indicating the topic ID did not exist. The check for the topic ID will occur before checking authorization on the topic. Thus, topic IDs are not considered sensitive information.
MetadataRequest v10
|
DeleteTopics
It will be useful for the AdminClient to be able to specify a list of topic Ids to delete to ensure the correct topics are being deleted. New methods will need to be added to the Admin interface and KafkaAdminClient
...
DeleteTopics Request and Response should be modified.
DeleteTopicsRequest v6
|
Like the MetadataRequst, ID will be checked first, but if the value is the default zero UUID, topic name will be used instead. If an ID is specified and the ID does not exist, the request will return UNKNOWN_TOPIC_ID
error for the topic indicating the topic ID did not exist. The check for the topic ID will occur before checking authorization on the topic. Thus, topic IDs are not considered sensitive information.
DeleteTopicsResponse v6
|
Although only topic ID or only topic name are included in the request, if topic Ids are supported, the response will contain both the name and the ID.
...