Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current state: Under Discussion

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Classes in org.apache.kafka.common.requests are not considered part of the supported public API. Unfortunately the DescribeLogDirsResponse.LogDirInfo class from this package is used as the declared return type of the all() and values() methods of DescribeLogDirsResult, which is in the public API. Furthermore the DescribeLogDirsResponse.ReplicaInfo and Errors classes are reachable from the public API of LogDirInfo.

...

That warning notwithstanding, this KIP proposes to follow the former route, preferring client compatibility.

Public Interfaces

The existing DescribeLogDirsResult methods values() and all() will be deprecated and DescribeLogDirsResult will get two new methods:

...

Code Block
languagejava
linenumberstrue
public class LogDirDescription {
    private final Map<TopicPartition, ReplicaInfo> replicaInfos;
    private final Errors error;

    LogDirDescription(Errors error, Map<TopicPartition, ReplicaInfo> replicaInfos) {
        this.replicaInfos = replicaInfos;
    }

    /**
     * A KafkaStorageException if this log directory is offline, 
     * possibly some other exception if there were problems describing the log directory
     * or null if the directory is online.
     */
    public ApiException error() {
        // ...
    }

    /** 
     * A map from topic partition to replica information for that partition 
     * in this log directory.
     */
    public Map<TopicPartition, ReplicaInfo> repliaInfos() {
        return unmodifiableMap(replicaInfos);
    }

    @Override
    public String toString() {
	// ...
    }
}
public class ReplicaInfo {

    private final long size;
    private final long offsetLag;
    private final boolean isFuture;

    public ReplicaInfo(long size, long offsetLag, boolean isFuture) {
        this.size = size;
        this.offsetLag = offsetLag;
        this.isFuture = isFuture;
    }

    /** 
     * The total size of the log segments in this replica in bytes. 
     */
    public long size() {
        return size;
    } 

    /**
     * The lag of the log's LEO with respect to the partition's 
     * high watermark (if it is the current log for the partition)
     * or the current replica's LEO (if it is the {@linkplain #isFuture() future log}
     * for the partition).
     */
    public long offsetLag() {
        return offsetLag;
    }

    /**
     * Whether this replica has been created by a AlterReplicaLogDirsRequest
     * but not yet replaced the current replica on the broker.
     * @return true if this log is created by AlterReplicaLogDirsRequest and will replace the current log of the replica in the future.
    public boolean isFuture() {
        return isFuture;
    }

    @Override
    public String toString() {
        // ...
    }


Proposed Changes

In addition to that's described in the changes to the public interface, the kafka.admin.LogDirsCommand  will be fixed to use the new methods.

Compatibility, Deprecation, and Migration Plan

This change is source and binary compatible.

Rejected Alternatives