Skip to content

Commit

Permalink
JDK 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoutanov committed May 26, 2019
1 parent ce575c4 commit 36739f5
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ target
*.iws
*.ipr
.idea/
.DS_Store
109 changes: 52 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -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-<version>.jar --zookeeper.connect=<host>:<port>,<host>:<port>,...
## Running from JAR
```sh
java --add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED \
-jar target/kafdrop-<version>.jar --zookeeper.connect=<host>:<port>,<host>:<port>,...
```

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=<port>
--server.port=<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=<host:port,host:port> kafdrop
```sh
docker run -d -p 9000:9000 -e ZOOKEEPER_CONNECT=<host:port,host:port> 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
```
34 changes: 22 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.homeadvisor.kafka</groupId>
<artifactId>kafdrop</artifactId>
<version>2.0.6</version>
<version>3.0.0</version>

<description>For when you have a Kaf(ka) cluster to monitor</description>

Expand All @@ -19,8 +19,8 @@
</properties>

<scm>
<connection>scm:git:[email protected]:HomeAdvisor/Kafdrop.git</connection>
<developerConnection>scm:git:[email protected]:HomeAdvisor/Kafdrop.git</developerConnection>
<connection>scm:git:[email protected]:obsidiandynamics/kafdrop.git</connection>
<developerConnection>scm:git:[email protected]:obsidiandynamics/kafdrop.git</developerConnection>
<tag>HEAD</tag>
</scm>

Expand Down Expand Up @@ -50,9 +50,14 @@

<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
Expand All @@ -78,7 +83,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
<version>1.18.8</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -204,10 +209,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<fork>true</fork>
<compilerVersion>11</compilerVersion>
<compilerArgs>
<arg>--add-exports=jdk.management.agent/jdk.internal.agent=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -237,9 +247,9 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<version>1.2.0</version>
<configuration>
<imageName>kafdrop</imageName>
<imageName>obsidiandynamics/kafdrop</imageName>
<forceTags>true</forceTags>
<dockerDirectory>${project.build.directory}/docker-ready</dockerDirectory>
<imageTags>
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM java:8
FROM openjdk:12.0.1-jdk-oraclelinux7
MAINTAINER homeadvisor

ADD kafdrop.sh /
Expand Down
8 changes: 7 additions & 1 deletion src/main/docker/kafdrop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/homeadvisor/kafdrop/util/JmxUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +32,7 @@ public static int getJmxPort(final Environment environment)
{
Optional<Integer> 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);
Expand Down

0 comments on commit 36739f5

Please sign in to comment.