Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-12-12 Thread via GitHub


gharris1727 merged PR #14293:
URL: https://github.com/apache/kafka/pull/14293


-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-12-12 Thread via GitHub


gharris1727 commented on PR #14293:
URL: https://github.com/apache/kafka/pull/14293#issuecomment-1852872688

   Test failures appear unrelated, and the mirror and runtime tests pass 
locally.


-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-12-05 Thread via GitHub


C0urante commented on code in PR #14293:
URL: https://github.com/apache/kafka/pull/14293#discussion_r1416019825


##
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/DedicatedMirrorIntegrationTest.java:
##
@@ -314,6 +356,23 @@ private  void 
awaitConnectorTasksStart(final MirrorMa
 }, MM_START_UP_TIMEOUT_MS, "Tasks for connector " + 
clazz.getSimpleName() + " for MirrorMaker instances did not transition to 
running in time");
 }
 
+private  void 
awaitConnectorConfiguration(MirrorMaker mm, Class clazz, SourceAndTarget 
sourceAndTarget, Predicate> predicate) throws 
InterruptedException {
+String connName = clazz.getSimpleName();
+waitForCondition(() -> {
+try {
+FutureCallback>> cb = 
new FutureCallback<>();
+herder(mm, sourceAndTarget).tasksConfig(connName, cb);

Review Comment:
   Ah, very nice. Good call on end-to-end testing 👍 



##
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/DedicatedMirrorIntegrationTest.java:
##
@@ -314,6 +356,23 @@ private  void 
awaitConnectorTasksStart(final MirrorMa
 }, MM_START_UP_TIMEOUT_MS, "Tasks for connector " + 
clazz.getSimpleName() + " for MirrorMaker instances did not transition to 
running in time");
 }
 
+private  void 
awaitConnectorConfiguration(MirrorMaker mm, Class clazz, SourceAndTarget 
sourceAndTarget, Predicate> predicate) throws 
InterruptedException {
+String connName = clazz.getSimpleName();
+waitForCondition(() -> {
+try {
+FutureCallback>> cb = 
new FutureCallback<>();
+herder(mm, sourceAndTarget).tasksConfig(connName, cb);

Review Comment:
   Ah, very nice. Good call on end-to-end testing 👍 



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-12-04 Thread via GitHub


gharris1727 commented on code in PR #14293:
URL: https://github.com/apache/kafka/pull/14293#discussion_r1414605900


##
connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/DedicatedMirrorIntegrationTest.java:
##
@@ -314,6 +356,23 @@ private  void 
awaitConnectorTasksStart(final MirrorMa
 }, MM_START_UP_TIMEOUT_MS, "Tasks for connector " + 
clazz.getSimpleName() + " for MirrorMaker instances did not transition to 
running in time");
 }
 
+private  void 
awaitConnectorConfiguration(MirrorMaker mm, Class clazz, SourceAndTarget 
sourceAndTarget, Predicate> predicate) throws 
InterruptedException {
+String connName = clazz.getSimpleName();
+waitForCondition(() -> {
+try {
+FutureCallback>> cb = 
new FutureCallback<>();
+herder(mm, sourceAndTarget).tasksConfig(connName, cb);

Review Comment:
   I think I was doing a sort of "end-to-end-test" that verified that both the 
new configuration got applied to the connector, and that internal forwarding 
took place for the task configurations. I realize now that the method name 
doesn't match this implementation, so i renamed it to match.



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-12-04 Thread via GitHub


C0urante commented on code in PR #14293:
URL: https://github.com/apache/kafka/pull/14293#discussion_r1414541177


##
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorHerder.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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.connect.mirror;
+
+import org.apache.kafka.common.utils.Time;
+import 
org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy;
+import org.apache.kafka.connect.runtime.Worker;
+import org.apache.kafka.connect.runtime.distributed.DistributedConfig;
+import org.apache.kafka.connect.runtime.distributed.DistributedHerder;
+import org.apache.kafka.connect.runtime.distributed.NotLeaderException;
+import org.apache.kafka.connect.runtime.rest.RestClient;
+import org.apache.kafka.connect.storage.ConfigBackingStore;
+import org.apache.kafka.connect.storage.StatusBackingStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.kafka.connect.mirror.MirrorMaker.CONNECTOR_CLASSES;
+
+public class MirrorHerder extends DistributedHerder {
+
+private static final Logger log = 
LoggerFactory.getLogger(MirrorHerder.class);
+
+private final MirrorMakerConfig config;
+private final SourceAndTarget sourceAndTarget;
+private boolean wasLeader;
+
+public MirrorHerder(MirrorMakerConfig mirrorConfig, SourceAndTarget 
sourceAndTarget, DistributedConfig config, Time time, Worker worker, String 
kafkaClusterId, StatusBackingStore statusBackingStore, ConfigBackingStore 
configBackingStore, String restUrl, RestClient restClient, 
ConnectorClientConfigOverridePolicy connectorClientConfigOverridePolicy, 
List restNamespace, AutoCloseable... uponShutdown) {
+super(config, time, worker, kafkaClusterId, statusBackingStore, 
configBackingStore, restUrl, restClient, connectorClientConfigOverridePolicy, 
restNamespace, uponShutdown);
+this.config = mirrorConfig;
+this.sourceAndTarget = sourceAndTarget;
+}
+
+@Override
+protected boolean handleRebalanceCompleted() {
+if (!super.handleRebalanceCompleted()) {
+return false;
+}
+if (isLeader()) {
+if (!wasLeader) {
+log.info("This node {} is now a leader for {}. Configuring 
connectors...", this, sourceAndTarget);
+configureConnectors();
+}
+wasLeader = true;
+} else {
+wasLeader = false;
+}
+return true;
+}
+
+private void configureConnectors() {
+CONNECTOR_CLASSES.forEach(this::maybeConfigureConnector);
+}
+
+private void maybeConfigureConnector(Class connectorClass) {
+Map connectorProps = 
config.connectorBaseConfig(sourceAndTarget, connectorClass);
+connectorConfig(connectorClass.getSimpleName(), (e, existingConfig) -> 
{

Review Comment:
   Do we need/want this to execute asynchronously? At first glance it seems 
like it'd be cleaner to read the connector config from the [superclass's 
configState 
field](https://github.com/apache/kafka/blob/a83bc2d977d2af85d4edfc8096854137481001e9/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java#L193),
 which is already `protected` (though for somewhat dubious reasons...).



##
connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorHerder.java:
##
@@ -0,0 +1,94 @@
+/*
+ * 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

Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-11-27 Thread via GitHub


gharris1727 commented on PR #14293:
URL: https://github.com/apache/kafka/pull/14293#issuecomment-1828464698

   Hi @C0urante @yashmayya I'd like to get this into the 3.7.0 release, and 
code freeze is currently planned for Dec 20th. PTAL, thanks!


-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] KAFKA-15372: Reconfigure dedicated MM2 connectors after leadership change [kafka]

2023-11-26 Thread via GitHub


github-actions[bot] commented on PR #14293:
URL: https://github.com/apache/kafka/pull/14293#issuecomment-1827074429

   This PR is being marked as stale since it has not had any activity in 90 
days. If you would like to keep this PR alive, please ask a committer for 
review. If the PR has  merge conflicts, please update it with the latest from 
trunk (or appropriate release branch)  If this PR is no longer valid or 
desired, please feel free to close it. If no activity occurs in the next 30 
days, it will be automatically closed.


-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org