You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Status

Current stateUnder Discussion

Discussion thread: here 

JIRA: Unable to render Jira issues macro, execution error.

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

Motivation

The TaskMetadata class in KafkaStreams is used for encoding information about a particular task, such as its offsets, topic partitions, and taskId. For some reason, the taskId is stored and exposed as a String object, rather than using the actual TaskId class. We should move towards using TaskId here, since that's literally what it is, and because if/when we add additional fields to the TaskId it will become more and more unwieldy to parse the string encoding in order to extract the actual information about the task.

Public Interfaces

New interface added to the public API:

TaskId
package org.apache.kafka.streams.processor;

/**
 * A basic wrapper class for task metadata
 */
public interface TaskIdMetadata {
    /**
     * @return The ID of the topic group, ie the subtopology that this task executes
     */
    int topicGroupId();

    /**
     * @return The ID number of the partition.
     */
    int partition();
}

"New" class that implements the public interface but is itself internal:

TaskId
package org.apache.streams.processor.internals;

class TaskId implements TaskIdMetadata {
    // This is just the existing TaskId class & implementation, but
    // moved to the internals package
}


TaskMetadata
class TaskMetadata {

    private final TaskIdMetadata taskId;

    @Deprecated
    public String taskId() {
        return taskId.toString();
    }

    // New API
    public TaskIdMetadata taskIdMetadata() {
        return taskId;
    }
}

Proposed Changes

To migrate from the String to TaskIdMetadata, we'll need to deprecate the existing getter method and add a new one.

Since the actual existing TaskId class is not really a public API, and currently has a handful of public utility methods, we don't want to explicitly pull this into into the public API. Instead, we'll introduce a new TaskIdMetadata interface in the public API that's implemented by the current TaskId class, and move the TaskId class to an internal package to clarify that it's not a public.

Compatibility, Deprecation, and Migration Plan

The TaskMetadata#taskId() method will be deprecated and removed in a future release.

Rejected Alternatives

N/A


  • No labels