TaskId

TaskId takes the following to be created:

  • Topic group ID

  • Assigned partition ID

TaskId is created when:

When requested for a textual representation (toString), TaskId simply returns the topic group ID and the assigned partition ID separated by _ (underscore), e.g. 0_0.

import org.apache.kafka.streams.processor.TaskId
val topicGroupId = 0
val partition = 0
val tid = new TaskId(topicGroupId, partition)
scala> println(tid)
0_0

Creating TaskId from Textual Representation — parse Factory Method

TaskId parse(final String taskIdStr)

parse creates a TaskId from the given textual representation.

parse throws a TaskIdFormatException if the given taskIdStr is of incorrect format.

import org.apache.kafka.streams.processor.TaskId
val incorrectTaskId = "hello_world"
scala> TaskId.parse(incorrectTaskId)
org.apache.kafka.streams.errors.TaskIdFormatException: Task id cannot be parsed correctly from hello_world
  at org.apache.kafka.streams.processor.TaskId.parse(TaskId.java:58)
  ... 36 elided
Note

parse is used when:

Serializing TaskId — writeTo Method

void writeTo(final ByteBuffer buf)
void writeTo(final DataOutputStream out)

writeTo simply writes the topicGroupId and the partition out to the given output (either buf or out).

Note

writeTo is used when:

Creating TaskId from Encoded Representation (Deserialization) — readFrom Factory Method

TaskId readFrom(final ByteBuffer buf)
TaskId readFrom(final DataInputStream in)

readFrom simply creates a TaskId from (the numbers) from the given input (either buf or in).

Note

readFrom is used when:

results matching ""

    No results matching ""