You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/05/26 01:28:48 UTC

[GitHub] [kafka] mjsax commented on a change in pull request #10755: MINOR: deprecate TaskMetadata constructor and add KIP-740 notes to upgrade guide

mjsax commented on a change in pull request #10755:
URL: https://github.com/apache/kafka/pull/10755#discussion_r639338584



##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/TaskMetadata.java
##########
@@ -40,6 +40,18 @@
 
     private final Optional<Long> timeCurrentIdlingStarted;
 
+    /**
+     * @deprecated since 3.0, please use {@link #TaskMetadata(TaskId, Set, Map, Map, Optional) instead}
+     */
+    @Deprecated
+    public TaskMetadata(final String taskId,
+                        final Set<TopicPartition> topicPartitions,
+                        final Map<TopicPartition, Long> committedOffsets,
+                        final Map<TopicPartition, Long> endOffsets,
+                        final Optional<Long> timeCurrentIdlingStarted) {
+        this(TaskId.parse(taskId), topicPartitions, committedOffsets, endOffsets, timeCurrentIdlingStarted);
+    }
+
     public TaskMetadata(final TaskId taskId,

Review comment:
       Should we make this protected and add a internal "impl" class? (And also mark as non-public so we can eventually move to an interface?)

##########
File path: docs/streams/upgrade-guide.html
##########
@@ -117,6 +117,14 @@ <h3><a id="streams_api_changes_300" href="#streams_api_changes_300">Streams API
     <p>
         We removed the default implementation of <code>RocksDBConfigSetter#close()</code>.
     </p>
+
+    <p>
+        The public <code>topicGroupId</code> and <code>partition</code> fields on TaskId have been deprecated and replaced with getters, please migrate to using the new <code>TaskId.subtopology()</code>
+        and <code>TaskId.partition()</code> APIs instead. Also, the <code>TaskId#readFrom</code> and <code>TaskId#writeTo</code> methods have been deprecated and will be removed, as they were never intended
+        for public use to begin with. Finally, we have deprecated the <code>TaskMetadata.taskId()</code> method as well as the <code>TaskMetadata</code>constructor. These have been replaced with APIs that

Review comment:
       nit: remove `to begin with` ?

##########
File path: docs/streams/upgrade-guide.html
##########
@@ -117,6 +117,14 @@ <h3><a id="streams_api_changes_300" href="#streams_api_changes_300">Streams API
     <p>
         We removed the default implementation of <code>RocksDBConfigSetter#close()</code>.
     </p>
+
+    <p>
+        The public <code>topicGroupId</code> and <code>partition</code> fields on TaskId have been deprecated and replaced with getters, please migrate to using the new <code>TaskId.subtopology()</code>
+        and <code>TaskId.partition()</code> APIs instead. Also, the <code>TaskId#readFrom</code> and <code>TaskId#writeTo</code> methods have been deprecated and will be removed, as they were never intended
+        for public use to begin with. Finally, we have deprecated the <code>TaskMetadata.taskId()</code> method as well as the <code>TaskMetadata</code>constructor. These have been replaced with APIs that
+        better represent the task id as an actual <code>TaskId</code> object instead of a String. Please migrate to the new <code>TaskMetadata#getTaskId</code> method and the new constructor which accepts

Review comment:
       `and the new constructor`
   
   I thought that the constructor was never intended for public usage. Should we not hide the new constructor?

##########
File path: docs/streams/upgrade-guide.html
##########
@@ -117,6 +117,14 @@ <h3><a id="streams_api_changes_300" href="#streams_api_changes_300">Streams API
     <p>
         We removed the default implementation of <code>RocksDBConfigSetter#close()</code>.
     </p>
+
+    <p>
+        The public <code>topicGroupId</code> and <code>partition</code> fields on TaskId have been deprecated and replaced with getters, please migrate to using the new <code>TaskId.subtopology()</code>
+        and <code>TaskId.partition()</code> APIs instead. Also, the <code>TaskId#readFrom</code> and <code>TaskId#writeTo</code> methods have been deprecated and will be removed, as they were never intended
+        for public use to begin with. Finally, we have deprecated the <code>TaskMetadata.taskId()</code> method as well as the <code>TaskMetadata</code>constructor. These have been replaced with APIs that

Review comment:
       missing blank `<code>TaskMetadata</code>constructor` 

##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/TaskId.java
##########
@@ -80,6 +83,35 @@ public String toString() {
         return namedTopology != null ? namedTopology + "_" + topicGroupId + "_" + partition : topicGroupId + "_" + partition;
     }
 
+    /**
+     * @throws TaskIdFormatException if the taskIdStr is not a valid {@link TaskId}
+     */
+    public static TaskId parse(final String taskIdStr) {

Review comment:
       If it was removed (and release in 2.8), why add it back? Seems we don't need it?

##########
File path: streams/src/main/java/org/apache/kafka/streams/processor/TaskId.java
##########
@@ -80,6 +83,35 @@ public String toString() {
         return namedTopology != null ? namedTopology + "_" + topicGroupId + "_" + partition : topicGroupId + "_" + partition;
     }
 
+    /**
+     * @throws TaskIdFormatException if the taskIdStr is not a valid {@link TaskId}
+     */
+    public static TaskId parse(final String taskIdStr) {
+        final int firstIndex = taskIdStr.indexOf('_');

Review comment:
       I guess I missed the "name topology" change. What is a topology name? How to set it? And do we ensure that we don't allow `_` in its name?

##########
File path: docs/streams/upgrade-guide.html
##########
@@ -117,6 +117,14 @@ <h3><a id="streams_api_changes_300" href="#streams_api_changes_300">Streams API
     <p>
         We removed the default implementation of <code>RocksDBConfigSetter#close()</code>.
     </p>
+
+    <p>
+        The public <code>topicGroupId</code> and <code>partition</code> fields on TaskId have been deprecated and replaced with getters, please migrate to using the new <code>TaskId.subtopology()</code>

Review comment:
       Add a hint that `topicGroupId` is renamed to `subTopologyId()` ( I know about the change and was first confused reading the sentence)




-- 
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:
users@infra.apache.org