-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-2372: Add Kafka-backed storage of Copycat configs. #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22c1b1e
KAFKA-2372: Add Kafka-backed storage of Copycat configs.
ewencp 449fe60
Minor comment and styling fixes.
ewencp ac9a8f7
Merge remote-tracking branch 'origin/trunk' into kafka-2372-copycat-d…
ewencp 004150b
Address review comments.
ewencp 37c5a42
Expose offsets for configs in KafkConfigStorage.
ewencp 20e5fe5
Move KafkaConfigStorage to the o.a.k.cc.storage package.
ewencp 2a82592
Use connector-specific config commits instead of a single root commit.
ewencp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
86 changes: 86 additions & 0 deletions
86
...untime/src/main/java/org/apache/kafka/copycat/runtime/distributed/ClusterConfigState.java
This file contains hidden or 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,86 @@ | ||
| /** | ||
| * 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.copycat.runtime.distributed; | ||
|
|
||
| import org.apache.kafka.copycat.util.ConnectorTaskId; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * An immutable snapshot of the configuration state of connectors and tasks in a Copycat cluster. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice :) |
||
| */ | ||
| public class ClusterConfigState { | ||
| private Map<String, Integer> rootConfig; | ||
| private Map<String, Map<String, String>> connectorConfigs; | ||
| private Map<ConnectorTaskId, Map<String, String>> taskConfigs; | ||
|
|
||
| public ClusterConfigState(Map<String, Integer> rootConfig, | ||
| Map<String, Map<String, String>> connectorConfigs, | ||
| Map<ConnectorTaskId, Map<String, String>> taskConfigs) { | ||
| this.rootConfig = rootConfig; | ||
| this.connectorConfigs = connectorConfigs; | ||
| this.taskConfigs = taskConfigs; | ||
| } | ||
|
|
||
| /** | ||
| * Get a list of the connectors in this configuration | ||
| */ | ||
| public Collection<String> connectors() { | ||
| return rootConfig.keySet(); | ||
| } | ||
|
|
||
| /** | ||
| * Get the configuration for a connector. | ||
| * @param connector name of the connector | ||
| * @return a map containing configuration parameters | ||
| */ | ||
| public Map<String, String> connectorConfig(String connector) { | ||
| return connectorConfigs.get(connector); | ||
| } | ||
|
|
||
| /** | ||
| * Get the configuration for a task. | ||
| * @param task id of the task | ||
| * @return a map containing configuration parameters | ||
| */ | ||
| public Map<String, String> taskConfig(ConnectorTaskId task) { | ||
| return taskConfigs.get(task); | ||
| } | ||
|
|
||
| /** | ||
| * Get the current set of task IDs for the specified connector. | ||
| * @param connectorName the name of the connector to look up task configs for | ||
| * @return the current set of connector task IDs | ||
| */ | ||
| public Collection<ConnectorTaskId> tasks(String connectorName) { | ||
| Integer numTasks = rootConfig.get(connectorName); | ||
| if (numTasks == null) | ||
| throw new IllegalArgumentException("Connector does not exist in current configuration."); | ||
|
|
||
| List<ConnectorTaskId> taskIds = new ArrayList<>(); | ||
| for (int taskIndex = 0; taskIndex < numTasks; taskIndex++) { | ||
| ConnectorTaskId taskId = new ConnectorTaskId(connectorName, taskIndex); | ||
| taskIds.add(taskId); | ||
| } | ||
| return taskIds; | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it Map [String, String] ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed