From eba0af7a2de00c024095591482f439baa7de9bfd Mon Sep 17 00:00:00 2001 From: Bruce Szalwinski Date: Tue, 21 Mar 2017 16:28:16 -0500 Subject: [PATCH 1/2] Key / Value transformations are static nested classes and so are referenced using OuterClass$Key and OuterClass$Value. --- bin/connect-plugin-discovery.sh | 33 +++++++++++++++++++ .../connect/runtime/PluginDiscovery.java | 2 +- .../connect/transforms/ExtractField.java | 4 +-- .../kafka/connect/transforms/HoistField.java | 4 +-- .../kafka/connect/transforms/InsertField.java | 4 +-- .../kafka/connect/transforms/MaskField.java | 4 +-- .../connect/transforms/ReplaceField.java | 4 ++- .../connect/transforms/SetSchemaMetadata.java | 4 +-- 8 files changed, 47 insertions(+), 12 deletions(-) create mode 100755 bin/connect-plugin-discovery.sh diff --git a/bin/connect-plugin-discovery.sh b/bin/connect-plugin-discovery.sh new file mode 100755 index 0000000000000..0759bc44b9121 --- /dev/null +++ b/bin/connect-plugin-discovery.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# 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. + +base_dir=$(dirname $0) + +if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then + export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties" +fi + +COMMAND=$1 +case $COMMAND in + -daemon) + EXTRA_ARGS="-daemon "$EXTRA_ARGS + shift + ;; + *) + ;; +esac + +exec $(dirname $0)/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.runtime.PluginDiscovery "$@" diff --git a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/PluginDiscovery.java b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/PluginDiscovery.java index be55daf571513..d31ce6d1d7aac 100644 --- a/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/PluginDiscovery.java +++ b/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/PluginDiscovery.java @@ -106,7 +106,7 @@ private static List> transformationPlugins(Refle Collections.sort(transformationPlugins, new Comparator>() { @Override public int compare(Class a, Class b) { - return a.getCanonicalName().compareTo(b.getCanonicalName()); + return a.getName().compareTo(b.getName()); } }); diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ExtractField.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ExtractField.java index 36373eb0e98eb..bb4b53927d56f 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ExtractField.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ExtractField.java @@ -31,8 +31,8 @@ public abstract class ExtractField> implements Transf public static final String OVERVIEW_DOC = "Extract the specified field from a Struct when schema present, or a Map in the case of schemaless data." - + "

Use the concrete transformation type designed for the record key (" + Key.class.getCanonicalName() + ") " - + "or value (" + Value.class.getCanonicalName() + ")."; + + "

Use the concrete transformation type designed for the record key (" + Key.class.getName() + ") " + + "or value (" + Value.class.getName() + ")."; private static final String FIELD_CONFIG = "field"; diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/HoistField.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/HoistField.java index 1035e97a41433..a852c797a3611 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/HoistField.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/HoistField.java @@ -33,8 +33,8 @@ public abstract class HoistField> implements Transfor public static final String OVERVIEW_DOC = "Wrap data using the specified field name in a Struct when schema present, or a Map in the case of schemaless data." - + "

Use the concrete transformation type designed for the record key (" + Key.class.getCanonicalName() + ") " - + "or value (" + Value.class.getCanonicalName() + ")."; + + "

Use the concrete transformation type designed for the record key (" + Key.class.getName() + ") " + + "or value (" + Value.class.getName() + ")."; private static final String FIELD_CONFIG = "field"; diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java index 441129a8f9efa..5e472a907c3f4 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java @@ -42,8 +42,8 @@ public abstract class InsertField> implements Transfo public static final String OVERVIEW_DOC = "Insert field(s) using attributes from the record metadata or a configured static value." - + "

Use the concrete transformation type designed for the record key (" + Key.class.getCanonicalName() + ") " - + "or value (" + Value.class.getCanonicalName() + ")."; + + "

Use the concrete transformation type designed for the record key (" + Key.class.getName() + ") " + + "or value (" + Value.class.getName() + ")."; private interface ConfigName { String TOPIC_FIELD = "topic.field"; diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/MaskField.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/MaskField.java index f9946a025721f..050c549c97e16 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/MaskField.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/MaskField.java @@ -42,8 +42,8 @@ public abstract class MaskField> implements Transform public static final String OVERVIEW_DOC = "Mask specified fields with a valid null value for the field type (i.e. 0, false, empty string, and so on)." - + "

Use the concrete transformation type designed for the record key (" + Key.class.getCanonicalName() + ") " - + "or value (" + Value.class.getCanonicalName() + ")."; + + "

Use the concrete transformation type designed for the record key (" + Key.class.getName() + ") " + + "or value (" + Value.class.getName() + ")."; private static final String FIELDS_CONFIG = "fields"; diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java index 8bdc15333a8bf..ee08945416683 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/ReplaceField.java @@ -39,7 +39,9 @@ public abstract class ReplaceField> implements Transformation { - public static final String OVERVIEW_DOC = "Filter or rename fields."; + public static final String OVERVIEW_DOC = "Filter or rename fields." + + "

Use the concrete transformation type designed for the record key (" + Key.class.getName() + ") " + + "or value (" + Value.class.getName() + ")."; interface ConfigName { String BLACKLIST = "blacklist"; diff --git a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/SetSchemaMetadata.java b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/SetSchemaMetadata.java index d34a43060ab5d..bb581de178024 100644 --- a/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/SetSchemaMetadata.java +++ b/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/SetSchemaMetadata.java @@ -30,8 +30,8 @@ public abstract class SetSchemaMetadata> implements Transformation { public static final String OVERVIEW_DOC = - "Set the schema name, version or both on the record's key (" + Key.class.getCanonicalName() + ")" - + " or value (" + Value.class.getCanonicalName() + ") schema."; + "Set the schema name, version or both on the record's key (" + Key.class.getName() + ")" + + " or value (" + Value.class.getName() + ") schema."; private interface ConfigName { String SCHEMA_NAME = "schema.name"; From ec3b5b962e60e55758653c378b89329d959c4c7d Mon Sep 17 00:00:00 2001 From: Bruce Szalwinski Date: Wed, 22 Mar 2017 09:48:42 -0500 Subject: [PATCH 2/2] remove connect-plugin-discovery. will submit in a different PR --- bin/connect-plugin-discovery.sh | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100755 bin/connect-plugin-discovery.sh diff --git a/bin/connect-plugin-discovery.sh b/bin/connect-plugin-discovery.sh deleted file mode 100755 index 0759bc44b9121..0000000000000 --- a/bin/connect-plugin-discovery.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# 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. - -base_dir=$(dirname $0) - -if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then - export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties" -fi - -COMMAND=$1 -case $COMMAND in - -daemon) - EXTRA_ARGS="-daemon "$EXTRA_ARGS - shift - ;; - *) - ;; -esac - -exec $(dirname $0)/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.runtime.PluginDiscovery "$@"