Adding the versioning system for the connector.
diff --git a/src/main/java/org/apache/geode/kafka/Version.java b/src/main/java/org/apache/geode/kafka/Version.java
new file mode 100644
index 0000000..81748cf
--- /dev/null
+++ b/src/main/java/org/apache/geode/kafka/Version.java
@@ -0,0 +1,48 @@
+/*
+ * 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.geode.kafka;
+
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Version {
+
+ private static final Logger log = LoggerFactory.getLogger(Version.class);
+ private static String version = "unknown";
+
+ private static final String VERSION_FILE = "/kafka-connect-geode-version.properties";
+
+ static {
+ try {
+ Properties properties = new Properties();
+ try (InputStream stream = Version.class.getResourceAsStream(VERSION_FILE)) {
+ properties.load(stream);
+ version = properties.getProperty("version", version).trim();
+ }
+
+ } catch (Exception exception) {
+ log.warn("Error while loading version");
+ }
+ }
+
+ public static String getVersion() {
+ return version;
+ }
+
+
+}
diff --git a/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSink.java b/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSink.java
index b09ba87..aae3b0d 100644
--- a/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSink.java
+++ b/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSink.java
@@ -25,6 +25,8 @@
import org.apache.kafka.connect.connector.Task;
import org.apache.kafka.connect.sink.SinkConnector;
+import org.apache.geode.kafka.Version;
+
public class GeodeKafkaSink extends SinkConnector {
private Map<String, String> sharedProps;
@@ -65,8 +67,7 @@
@Override
public String version() {
- // TODO
- return "unknown";
+ return Version.getVersion();
}
}
diff --git a/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSinkTask.java b/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSinkTask.java
index 48dcf30..a568616 100644
--- a/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSinkTask.java
+++ b/src/main/java/org/apache/geode/kafka/sink/GeodeKafkaSinkTask.java
@@ -30,6 +30,7 @@
import org.apache.geode.cache.RegionExistsException;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.kafka.GeodeContext;
+import org.apache.geode.kafka.Version;
/**
@@ -50,8 +51,7 @@
*/
@Override
public String version() {
- // TODO
- return "unknown";
+ return Version.getVersion();
}
@Override
diff --git a/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSource.java b/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSource.java
index 676cd46..173d9d9 100644
--- a/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSource.java
+++ b/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSource.java
@@ -25,12 +25,12 @@
import java.util.Map;
import org.apache.kafka.common.config.ConfigDef;
-import org.apache.kafka.common.utils.AppInfoParser;
import org.apache.kafka.connect.connector.Task;
import org.apache.kafka.connect.source.SourceConnector;
import org.apache.kafka.connect.util.ConnectorUtils;
import org.apache.geode.kafka.GeodeConnectorConfig;
+import org.apache.geode.kafka.Version;
public class GeodeKafkaSource extends SourceConnector {
@@ -79,7 +79,6 @@
@Override
public String version() {
- // TODO
- return AppInfoParser.getVersion();
+ return Version.getVersion();
}
}
diff --git a/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSourceTask.java b/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSourceTask.java
index 9223ee4..a9edf95 100644
--- a/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSourceTask.java
+++ b/src/main/java/org/apache/geode/kafka/source/GeodeKafkaSourceTask.java
@@ -35,6 +35,7 @@
import org.apache.geode.cache.query.CqResults;
import org.apache.geode.cache.query.Struct;
import org.apache.geode.kafka.GeodeContext;
+import org.apache.geode.kafka.Version;
public class GeodeKafkaSourceTask extends SourceTask {
@@ -61,7 +62,7 @@
@Override
public String version() {
- return null;
+ return Version.getVersion();
}
@Override
diff --git a/src/main/resources/kafka-connect-geode-version.properties b/src/main/resources/kafka-connect-geode-version.properties
new file mode 100644
index 0000000..5ea51b3
--- /dev/null
+++ b/src/main/resources/kafka-connect-geode-version.properties
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+version=${project.version}
\ No newline at end of file
diff --git a/version.txt b/version.txt
new file mode 100644
index 0000000..addce8b
--- /dev/null
+++ b/version.txt
@@ -0,0 +1,2 @@
+##This file must be updated at package time to have a valid package##
+invalid