forked from apache/kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAFKA-12849: KIP-744 TaskMetadata ThreadMetadata StreamsMetadata as A…
…PI (apache#10840) Implementation of KIP-744. Creates new Interfaces for TaskMetadata, ThreadMetadata, and StreamsMetadata, providing internal implementations for each of them. Deprecates current TaskMetadata, ThreadMetadata under o.a.k.s.processor, and SreamsMetadata under a.o.k.s.state. Updates references on internal classes from deprecated classes to new interfaces. Deprecates methods on KafkaStreams returning deprecated ThreadMeatada and StreamsMetadata, and provides new ones returning the new interfaces. Update Javadocs referencing to deprecated classes and methods to point to the right ones. Co-authored-by: Bruno Cadonna <[email protected]> Reviewers: Anna Sophie Blee-Goldman <[email protected]>, Bruno Cadonna <[email protected]>
- Loading branch information
Showing
38 changed files
with
1,473 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
streams/src/main/java/org/apache/kafka/streams/StreamsMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kafka.streams; | ||
|
||
import org.apache.kafka.common.TopicPartition; | ||
import org.apache.kafka.streams.state.HostInfo; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Metadata of a Kafka Streams client. | ||
*/ | ||
public interface StreamsMetadata { | ||
|
||
/** | ||
* The value of {@link StreamsConfig#APPLICATION_SERVER_CONFIG} configured for the Streams | ||
* client. | ||
* | ||
* @return {@link HostInfo} corresponding to the Streams client | ||
*/ | ||
HostInfo hostInfo(); | ||
|
||
/** | ||
* Names of the state stores assigned to active tasks of the Streams client. | ||
* | ||
* @return names of the state stores assigned to active tasks | ||
*/ | ||
Set<String> stateStoreNames(); | ||
|
||
/** | ||
* Source topic partitions of the active tasks of the Streams client. | ||
* | ||
* @return source topic partitions of the active tasks | ||
*/ | ||
Set<TopicPartition> topicPartitions(); | ||
|
||
/** | ||
* Changelog topic partitions for the state stores the standby tasks of the Streams client replicates. | ||
* | ||
* @return set of changelog topic partitions of the standby tasks | ||
*/ | ||
Set<TopicPartition> standbyTopicPartitions(); | ||
|
||
/** | ||
* Names of the state stores assigned to standby tasks of the Streams client. | ||
* | ||
* @return names of the state stores assigned to standby tasks | ||
*/ | ||
Set<String> standbyStateStoreNames(); | ||
|
||
/** | ||
* Host where the Streams client runs. | ||
* | ||
* This method is equivalent to {@code StreamsMetadata.hostInfo().host();} | ||
* | ||
* @return the host where the Streams client runs | ||
*/ | ||
String host(); | ||
|
||
/** | ||
* Port on which the Streams client listens. | ||
* | ||
* This method is equivalent to {@code StreamsMetadata.hostInfo().port();} | ||
* | ||
* @return the port on which Streams client listens | ||
*/ | ||
int port(); | ||
|
||
/** | ||
* Compares the specified object with this StreamsMetadata. Returns {@code true} if and only if the specified object is | ||
* also a StreamsMetadata and for both {@code hostInfo()} are equal, and {@code stateStoreNames()}, {@code topicPartitions()}, | ||
* {@code standbyStateStoreNames()}, and {@code standbyTopicPartitions()} contain the same elements. | ||
* | ||
* @return {@code true} if this object is the same as the obj argument; {@code false} otherwise. | ||
*/ | ||
boolean equals(Object o); | ||
|
||
/** | ||
* Returns the hash code value for this TaskMetadata. The hash code of a list is defined to be the result of the following calculation: | ||
* <pre> | ||
* {@code | ||
* Objects.hash(hostInfo(), stateStoreNames(), topicPartitions(), standbyStateStoreNames(), standbyTopicPartitions()); | ||
* } | ||
* </pre> | ||
* | ||
* @return a hash code value for this object. | ||
*/ | ||
int hashCode(); | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
streams/src/main/java/org/apache/kafka/streams/TaskMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kafka.streams; | ||
|
||
import org.apache.kafka.common.TopicPartition; | ||
import org.apache.kafka.streams.processor.TaskId; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
|
||
/** | ||
* Metadata of a task. | ||
*/ | ||
public interface TaskMetadata { | ||
|
||
/** | ||
* Task ID of the task. | ||
* | ||
* @return task ID consisting of subtopology and partition ID | ||
*/ | ||
TaskId taskId(); | ||
|
||
/** | ||
* Source topic partitions of the task. | ||
* | ||
* @return source topic partitions | ||
*/ | ||
Set<TopicPartition> topicPartitions(); | ||
|
||
/** | ||
* Offsets of the source topic partitions committed so far by the task. | ||
* | ||
* @return map from source topic partitions to committed offsets | ||
*/ | ||
Map<TopicPartition, Long> committedOffsets(); | ||
|
||
/** | ||
* End offsets of the source topic partitions of the task. | ||
* | ||
* @return map source topic partition to end offsets | ||
*/ | ||
Map<TopicPartition, Long> endOffsets(); | ||
|
||
/** | ||
* Time task idling started. If the task is not currently idling it will return empty. | ||
* | ||
* @return time when task idling started, empty {@code Optional} if the task is currently not idling | ||
*/ | ||
Optional<Long> timeCurrentIdlingStarted(); | ||
|
||
/** | ||
* Compares the specified object with this TaskMetadata. Returns {@code true} if and only if the specified object is | ||
* also a TaskMetadata and both {@code taskId()} and {@code topicPartitions()} are equal. | ||
* | ||
* @return {@code true} if this object is the same as the obj argument; {@code false} otherwise. | ||
*/ | ||
boolean equals(final Object o); | ||
|
||
/** | ||
* Returns the hash code value for this TaskMetadata. The hash code of a list is defined to be the result of the following calculation: | ||
* <pre> | ||
* {@code | ||
* Objects.hash(taskId(), topicPartitions()); | ||
* } | ||
* </pre> | ||
* | ||
* @return a hash code value for this object. | ||
*/ | ||
int hashCode(); | ||
|
||
} |
Oops, something went wrong.