snehashisp commented on code in PR #17988: URL: https://github.com/apache/kafka/pull/17988#discussion_r1996169025
########## connect/runtime/src/main/java/org/apache/kafka/connect/runtime/TaskPluginsMetadata.java: ########## @@ -0,0 +1,151 @@ +/* + * 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.runtime; + +import org.apache.kafka.connect.connector.Connector; +import org.apache.kafka.connect.connector.Task; +import org.apache.kafka.connect.health.ConnectorType; +import org.apache.kafka.connect.runtime.isolation.LoaderSwap; +import org.apache.kafka.connect.runtime.isolation.PluginType; +import org.apache.kafka.connect.runtime.isolation.PluginUtils; +import org.apache.kafka.connect.runtime.isolation.Plugins; +import org.apache.kafka.connect.sink.SinkConnector; +import org.apache.kafka.connect.source.SourceConnector; +import org.apache.kafka.connect.storage.Converter; +import org.apache.kafka.connect.storage.HeaderConverter; + +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class TaskPluginsMetadata { + + private final String connectorClass; + private final String connectorVersion; + private final ConnectorType connectorType; + private final String taskClass; + private final String taskVersion; + private final String keyConverterClass; + private final String keyConverterVersion; + private final String valueConverterClass; + private final String valueConverterVersion; + private final String headerConverterClass; + private final String headerConverterVersion; + private final Set<TransformationStage.AliasedPluginInfo> transformations; + private final Set<TransformationStage.AliasedPluginInfo> predicates; + + public TaskPluginsMetadata( + Class<? extends Connector> connectorClass, + Task task, + Converter keyConverter, + Converter valueConverter, + HeaderConverter headerConverter, + List<TransformationStage.StageInfo> transformationStageInfo, + Plugins plugins + ) { + + assert connectorClass != null; + assert task != null; + assert keyConverter != null; + assert valueConverter != null; + assert headerConverter != null; + assert transformationStageInfo != null; + + Function<ClassLoader, LoaderSwap> pluginLoaderSwapper = plugins.safeLoaderSwapper(); + + this.connectorClass = connectorClass.getName(); + this.connectorVersion = plugins.pluginVersion(connectorClass.getName(), connectorClass.getClassLoader(), PluginType.SINK, PluginType.SOURCE); + this.connectorType = getConnectorType(connectorClass, pluginLoaderSwapper); + this.taskClass = task.getClass().getName(); + this.taskVersion = task.version(); Review Comment: So this is being called during task build after switching the context classloader to the connector loader. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
