From 36739f55b591ceeec075811aed566c66b1a7b2ba Mon Sep 17 00:00:00 2001 From: Emil Koutanov Date: Sun, 26 May 2019 21:06:45 +1000 Subject: [PATCH] JDK 11 support --- .gitignore | 1 + README.md | 109 +++++++++--------- pom.xml | 34 ++++-- src/main/docker/Dockerfile | 2 +- src/main/docker/kafdrop.sh | 8 +- .../config/InterceptorConfiguration.java | 2 +- .../kafdrop/config/ini/IniFileReader.java | 2 +- .../homeadvisor/kafdrop/model/ConsumerVO.java | 2 +- .../kafdrop/service/CuratorKafkaMonitor.java | 2 +- .../homeadvisor/kafdrop/util/JmxUtils.java | 3 +- 10 files changed, 88 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index 8e33d5b6..a414379f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ target *.iws *.ipr .idea/ +.DS_Store diff --git a/README.md b/README.md index 183f0bf7..0ab0c5f8 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,101 @@ -# Kafdrop +Kafdrop 3 +=== -Kafdrop is a UI for monitoring Apache Kafka clusters. The tool displays information such as brokers, topics, partitions, and even lets you view messages. It is a light weight application that runs on Spring Boot and requires very little configuration. +Kafdrop 3 is a UI for monitoring Apache Kafka clusters. The tool displays information such as brokers, topics, partitions, and lets you view messages. -## Requirements +The project is a continuation of the original [HomeAdvisor/Kafdrop](https://github.com/HomeAdvisor/Kafdrop), which has now been dragged kicking and screaming into the JDK 11 world. It's a lightweight application that runs on Spring Boot and requires very little configuration. -* Java 8 -* Kafka (0.8.1 or 0.8.2 is known to work) -* Zookeeper (3.4.5 or later) +# Requirements + +* Java 11 or newer +* Kafka + ZooKeeper cluster Optional, additional integration: * Schema Registry -## Building - +# Getting Started +## Maven build After cloning the repository, building should just be a matter of running a standard Maven build: -``` +```sh $ mvn clean package ``` -## Running Stand Alone - -The build process creates an executable JAR file. - -``` -java -jar ./target/kafdrop-.jar --zookeeper.connect=:,:,... +## Running from JAR +```sh +java --add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED \ + -jar target/kafdrop-.jar --zookeeper.connect=:,:,... ``` -Then open a browser and navigate to http://localhost:9000. The port can be overridden by adding the following config: +Open a browser and navigate to [http://localhost:9000](http://localhost:9000). The port can be overridden by adding the following config: ``` - --server.port= +--server.port= ``` -Additionally, you can optionally configure a schema registry connection with: +Optionally, configure a schema registry connection with: ``` - --schemaregistry.connect=http://localhost:8081 +--schemaregistry.connect=http://localhost:8081 ``` Finally, a default message format (e.g. to deserialize Avro messages) can optionally be configured as follows: ``` - --message.format=AVRO +--message.format=AVRO ``` -Valid format values are "DEFAULT" and "AVRO". This setting can also be configured at the topic level via dropdown when viewing messages. +Valid format values are `DEFAULT` and `AVRO`. This setting can also be configured at the topic level via dropdown when viewing messages. ## Running with Docker - -Note for Mac Users: You need to convert newline formatting of the kafdrop.sh file *before* running this command: - -``` - dos2unix src/main/docker/* -``` - The following maven command will generate a Docker image: -``` - mvn clean package assembly:single docker:build +```sh +mvn clean package assembly:single docker:build ``` +Once the build finishes you can launch the image: -Once the build finishes you can launch the image as follows: - -``` - docker run -d -p 9000:9000 -e ZOOKEEPER_CONNECT= kafdrop +```sh +docker run -d -p 9000:9000 -e ZOOKEEPER_CONNECT= obsidiandynamics/kafdrop ``` -And access the UI at http://localhost:9000. - -## Kafka APIs +And access the UI at [http://localhost:9000](http://localhost:9000). -Starting with version 2.0.0, Kafdrop offers a set of Kafka APIs that mirror the existing HTML views. Any existing endpoint can be returned as JSON by simply setting the *Accept : application/json header*. There are also two endpoints that are JSON only: +# APIs +## JSON endpoints +Starting with version 2.0.0, Kafdrop offers a set of Kafka APIs that mirror the existing HTML views. Any existing endpoint can be returned as JSON by simply setting the `Accept: application/json` header. There are also two endpoints that are JSON only: - /topic : Returns array of all topic names - /topic/{topicName}/{consumerId} : Return partition offset and lag details for a specific topic and consumer. +* `/topic`: Returns array of all topic names. +* `/topic/{topicName}/{consumerId}`: Returns partition offset and lag details for a specific topic and consumer. ## Swagger - To help document the Kafka APIs, Swagger has been included. The Swagger output is available by default at the following Kafdrop URL: +``` +/v2/api-docs +``` - /v2/api-docs - -However this can be overridden with the following configuration: - - springfox.documentation.swagger.v2.path=/new/swagger/path +This can be overridden with the following configuration: +``` +springfox.documentation.swagger.v2.path=/new/swagger/path +``` Currently only the JSON endpoints are included in the Swagger output; the HTML views and Spring Boot debug endpoints are excluded. You can disable Swagger output with the following configuration: - - swagger.enabled=false +``` +swagger.enabled=false +``` ## CORS Headers - Starting in version 2.0.0, Kafdrop sets CORS headers for all endpoints. You can control the CORS header values with the following configurations: +``` +cors.allowOrigins (default is *) +cors.allowMethods (default is GET,POST,PUT,DELETE) +cors.maxAge (default is 3600) +cors.allowCredentials (default is true) +cors.allowHeaders (default is Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization) +``` - cors.allowOrigins (default is *) - cors.allowMethods (default is GET,POST,PUT,DELETE) - cors.maxAge (default is 3600) - cors.allowCredentials (default is true) - cors.allowHeaders (default is Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization) - You can also disable CORS entirely with the following configuration: - - cors.enabled=false +``` +cors.enabled=false +``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index a7841b14..966693f7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.homeadvisor.kafka kafdrop - 2.0.6 + 3.0.0 For when you have a Kaf(ka) cluster to monitor @@ -19,8 +19,8 @@ - scm:git:git@github.com:HomeAdvisor/Kafdrop.git - scm:git:git@github.com:HomeAdvisor/Kafdrop.git + scm:git:git@github.com:obsidiandynamics/kafdrop.git + scm:git:git@github.com:obsidiandynamics/kafdrop.git HEAD @@ -50,9 +50,14 @@ - commons-lang - commons-lang - 2.6 + org.apache.commons + commons-lang3 + 3.9 + + + javax.xml.bind + jaxb-api + 2.2.11 org.apache.curator @@ -78,7 +83,7 @@ org.projectlombok lombok - 1.16.6 + 1.18.8 @@ -204,10 +209,15 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.8.1 - 1.8 - 1.8 + 11 + 11 + true + 11 + + --add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED + @@ -237,9 +247,9 @@ com.spotify docker-maven-plugin - 0.4.13 + 1.2.0 - kafdrop + obsidiandynamics/kafdrop true ${project.build.directory}/docker-ready diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 57651a22..a540af51 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM java:8 +FROM openjdk:12.0.1-jdk-oraclelinux7 MAINTAINER homeadvisor ADD kafdrop.sh / diff --git a/src/main/docker/kafdrop.sh b/src/main/docker/kafdrop.sh index fb094238..0a3b6a39 100644 --- a/src/main/docker/kafdrop.sh +++ b/src/main/docker/kafdrop.sh @@ -25,5 +25,11 @@ if [ $JMX_PORT ]; then -Djava.rmi.server.hostname=$HOST" fi -java $JMX_ARGS $HEAP_ARGS -jar /kafdrop*/kafdrop*jar +ARGS="--add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED \ + -Xss256K \ + $JMX_ARGS \ + $HEAP_ARGS \ + $JVM_ARGS" + +java $ARGS -jar /kafdrop*/kafdrop*jar diff --git a/src/main/java/com/homeadvisor/kafdrop/config/InterceptorConfiguration.java b/src/main/java/com/homeadvisor/kafdrop/config/InterceptorConfiguration.java index 94907184..28f64b4e 100644 --- a/src/main/java/com/homeadvisor/kafdrop/config/InterceptorConfiguration.java +++ b/src/main/java/com/homeadvisor/kafdrop/config/InterceptorConfiguration.java @@ -18,7 +18,7 @@ package com.homeadvisor.kafdrop.config; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.MediaType; diff --git a/src/main/java/com/homeadvisor/kafdrop/config/ini/IniFileReader.java b/src/main/java/com/homeadvisor/kafdrop/config/ini/IniFileReader.java index d875226f..c31f74b4 100644 --- a/src/main/java/com/homeadvisor/kafdrop/config/ini/IniFileReader.java +++ b/src/main/java/com/homeadvisor/kafdrop/config/ini/IniFileReader.java @@ -18,7 +18,7 @@ package com.homeadvisor.kafdrop.config.ini; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java b/src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java index 3ffe92a2..d9792d2d 100644 --- a/src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java +++ b/src/main/java/com/homeadvisor/kafdrop/model/ConsumerVO.java @@ -18,7 +18,7 @@ package com.homeadvisor.kafdrop.model; -import org.apache.commons.lang.Validate; +import org.apache.commons.lang3.Validate; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitor.java b/src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitor.java index 07774010..64d5c40c 100644 --- a/src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitor.java +++ b/src/main/java/com/homeadvisor/kafdrop/service/CuratorKafkaMonitor.java @@ -36,7 +36,7 @@ import kafka.javaapi.TopicMetadata; import kafka.network.*; import kafka.utils.*; -import org.apache.commons.lang.*; +import org.apache.commons.lang3.*; import org.apache.curator.framework.*; import org.apache.curator.framework.recipes.cache.*; import org.apache.curator.framework.recipes.cache.PathChildrenCache.*; diff --git a/src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java b/src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java index 435c6648..6dd9d228 100644 --- a/src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java +++ b/src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java @@ -20,7 +20,6 @@ import com.google.common.primitives.Ints; import org.springframework.core.env.Environment; -import sun.management.Agent; import java.util.Optional; import java.util.Properties; @@ -33,7 +32,7 @@ public static int getJmxPort(final Environment environment) { Optional jmxPort = Optional.empty(); - final Properties managementProperties = Agent.getManagementProperties(); + final Properties managementProperties = jdk.internal.agent.Agent.getManagementProperties(); if (managementProperties != null) { final String portProperty = managementProperties.getProperty(JMX_PORT_PROPERTY);