-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kafka producer and consumer, checkstyle (#1)
* kafka producer and consumer, better logging, copied classes (also little bit reworked) Signed-off-by: Lukas Kral <[email protected]> * add travis and makefiles Signed-off-by: Lukas Kral <[email protected]> * fixups and more dockerfiles and makefiles Signed-off-by: Lukas Kral <[email protected]> * use ubi8 as base image Signed-off-by: Lukas Kral <[email protected]> * Jakub's comments Signed-off-by: Lukas Kral <[email protected]> * change name of docker org Signed-off-by: Lukas Kral <[email protected]> * Make build.sh executable Signed-off-by: Lukas Kral <[email protected]> * fix names for jars and change version to 0.1.0-SNAPSHOT Signed-off-by: Lukas Kral <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE module PUBLIC | ||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" | ||
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd"> | ||
|
||
<module name="Checker"> | ||
|
||
<property name="localeLanguage" value="en"/> | ||
|
||
<module name="FileTabCharacter"/> | ||
|
||
<!-- header --> | ||
<module name="RegexpHeader"> | ||
<!-- | ||
/* | ||
* Copyright Strimzi authors. | ||
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). | ||
*/ | ||
--> | ||
<property name="header" value="^\/\*$\n^\s\*\sCopyright\sStrimzi\sauthors\.$\n^\s\*\sLicense:\sApache\sLicense\s2\.0\s\(see\sthe\sfile\sLICENSE\sor\shttp:\/\/apache\.org\/licenses\/LICENSE-2\.0\.html\)\.$\n^\s\*\/$"/> | ||
<property name="fileExtensions" value="java"/> | ||
</module> | ||
|
||
<module name="SuppressWarningsFilter" /> | ||
<module name="TreeWalker"> | ||
<!-- code cleanup --> | ||
<module name="UnusedImports"> | ||
<property name="processJavadoc" value="true" /> | ||
</module> | ||
<module name="RedundantImport"/> | ||
<module name="IllegalImport" /> | ||
<module name="EqualsHashCode"/> | ||
<module name="SimplifyBooleanExpression"/> | ||
<module name="OneStatementPerLine"/> | ||
<module name="UnnecessaryParentheses" /> | ||
<module name="SimplifyBooleanReturn"/> | ||
|
||
<!-- style --> | ||
<module name="DefaultComesLast"/> | ||
<module name="EmptyStatement"/> | ||
<module name="ArrayTypeStyle"/> | ||
<module name="UpperEll"/> | ||
<module name="LeftCurly"/> | ||
<module name="RightCurly"/> | ||
<module name="EmptyStatement"/> | ||
<module name="ConstantName"> | ||
<property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/> | ||
</module> | ||
<module name="LocalVariableName"/> | ||
<module name="LocalFinalVariableName"/> | ||
<module name="MemberName"/> | ||
<module name="ClassTypeParameterName"> | ||
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/> | ||
</module> | ||
<module name="MethodTypeParameterName"> | ||
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/> | ||
</module> | ||
<module name="InterfaceTypeParameterName"> | ||
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/> | ||
</module> | ||
<module name="PackageName"/> | ||
<module name="ParameterName"/> | ||
<module name="StaticVariableName"/> | ||
<module name="TypeName"/> | ||
<module name="AvoidStarImport"/> | ||
|
||
<!-- dependencies --> | ||
<!--<module name="ImportControl"> | ||
<property name="file" value="${importControlFile}"/> | ||
</module>--> | ||
|
||
<!-- whitespace --> | ||
<module name="GenericWhitespace"/> | ||
<module name="NoWhitespaceBefore"/> | ||
<module name="WhitespaceAfter" /> | ||
<module name="NoWhitespaceAfter"/> | ||
<module name="WhitespaceAround"> | ||
<property name="allowEmptyConstructors" value="true"/> | ||
<property name="allowEmptyMethods" value="true"/> | ||
</module> | ||
<module name="Indentation"/> | ||
<module name="MethodParamPad"/> | ||
<module name="ParenPad"/> | ||
<module name="TypecastParenPad"/> | ||
|
||
<!-- locale-sensitive methods should specify locale --> | ||
<module name="Regexp"> | ||
<property name="format" value="\.to(Lower|Upper)Case\(\)"/> | ||
<property name="illegalPattern" value="true"/> | ||
<property name="ignoreComments" value="true"/> | ||
</module> | ||
|
||
<!-- code quality --> | ||
<module name="MethodLength"/> | ||
<module name="ParameterNumber"> | ||
<!-- default is 8 --> | ||
<property name="max" value="13"/> | ||
</module> | ||
<module name="ClassDataAbstractionCoupling"> | ||
<!-- default is 7 --> | ||
<property name="max" value="20"/> | ||
</module> | ||
<module name="BooleanExpressionComplexity"> | ||
<!-- default is 3 --> | ||
<property name="max" value="5"/> | ||
</module> | ||
|
||
<module name="ClassFanOutComplexity"> | ||
<!-- default is 20 --> | ||
<property name="max" value="44"/> | ||
</module> | ||
<module name="CyclomaticComplexity"> | ||
<!-- default is 10--> | ||
<property name="max" value="19"/> | ||
</module> | ||
<module name="JavaNCSS"> | ||
<!-- default is 50 --> | ||
<property name="methodMaximum" value="100"/> | ||
</module> | ||
<module name="NPathComplexity"> | ||
<!-- default is 200 --> | ||
<property name="max" value="5832"/> | ||
</module> | ||
|
||
<module name="IllegalToken"> | ||
<property name="tokens" value="LITERAL_ASSERT"/> | ||
</module> | ||
|
||
<!-- Make the @SuppressWarnings annotations available to Checkstyle --> | ||
<module name="SuppressWarningsHolder" /> | ||
</module> | ||
|
||
<module name="SuppressionFilter"> | ||
<property name="file" value="${checkstyle.suppressions.file}"/> | ||
</module> | ||
|
||
<!-- Filter out Checkstyle warnings that have been suppressed with the @SuppressWarnings annotation --> | ||
<module name="SuppressWarningsFilter" /> | ||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!DOCTYPE suppressions PUBLIC | ||
"-//Puppy Crawl//DTD Suppressions 1.1//EN" | ||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> | ||
|
||
<suppressions> | ||
|
||
<!-- Note that [/\\] must be used as the path separator for cross-platform support --> | ||
|
||
</suppressions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Maven build targets | ||
target/ | ||
|
||
# IntelliJ IDEA specific | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sudo: required | ||
language: java | ||
jdk: | ||
- openjdk11 | ||
services: | ||
- docker | ||
script: | ||
- "./.travis/build.sh" | ||
cache: | ||
directories: | ||
- "$HOME/.m2" | ||
env: | ||
global: | ||
- PULL_REQUEST=${TRAVIS_PULL_REQUEST} | ||
- COMMIT=${TRAVIS_COMMIT::8} | ||
- TAG=${TRAVIS_TAG:-latest} | ||
- BRANCH=${TRAVIS_BRANCH:-main} | ||
- DOCKER_REGISTRY=quay.io | ||
- DOCKER_ORG=strimzi-test-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
export PULL_REQUEST=${PULL_REQUEST:-true} | ||
export BRANCH=${BRANCH:-main} | ||
export TAG=${TAG:-latest} | ||
export DOCKER_ORG=${DOCKER_ORG:-strimzici} | ||
export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io} | ||
export DOCKER_TAG=$COMMIT | ||
|
||
make build | ||
|
||
if [ "$PULL_REQUEST" != "false" ] ; then | ||
make docker_build | ||
echo "Building PR: Nothing to push" | ||
else | ||
if [ "$TAG" = "latest" ] && [ "$BRANCH" != "main" ]; then | ||
make docker_build | ||
echo "Not in tag or main branch: Nothing to push" | ||
else | ||
export DOCKER_TAG=$TAG | ||
make docker_build | ||
fi | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
RELEASE_VERSION ?= latest | ||
|
||
SUBDIRS=kafka/consumer kafka/producer | ||
DOCKER_TARGETS=docker_build docker_tag | ||
|
||
all: $(SUBDIRS) | ||
build: $(SUBDIRS) | ||
clean: $(SUBDIRS) | ||
$(DOCKER_TARGETS): $(SUBDIRS) | ||
|
||
$(SUBDIRS): | ||
$(MAKE) -C $@ $(MAKECMDGOALS) | ||
|
||
.PHONY: all $(SUBDIRS) $(DOCKER_TARGETS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Makefile.docker contains the shared tasks for building, tagging and pushing Docker images. | ||
# This file is included into the Makefile files which contain the Dockerfile files (E.g. | ||
# kafka-base, kafka-statefulsets etc.). | ||
# | ||
# The DOCKER_ORG (default is name of the current user) and DOCKER_TAG (based on Git Tag, | ||
# default latest) variables are used to name the Docker image. DOCKER_REGISTRY identifies | ||
# the registry where the image will be pushed (default is Docker Hub). DOCKER_VERSION_ARG | ||
# is passed to the image build (based on Git commit, default latest) | ||
|
||
DOCKERFILE_DIR ?= ./ | ||
DOCKER_REGISTRY ?= quay.io | ||
DOCKER_ORG ?= $(USER) | ||
DOCKER_TAG ?= latest | ||
DOCKER_VERSION_ARG ?= latest | ||
|
||
all: docker_build docker_push | ||
|
||
docker_build: | ||
echo "Building Docker image ..." | ||
mkdir -p scripts | ||
cp ../../scripts/run.sh ./scripts/run.sh | ||
docker build --build-arg version=$(DOCKER_VERSION_ARG) -t strimzi/$(PROJECT_NAME):$(DOCKER_TAG) $(DOCKERFILE_DIR) | ||
rm -rf ./scripts | ||
|
||
docker_tag: | ||
echo "Tagging strimzi/$(PROJECT_NAME):$(DOCKER_TAG) to $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG) ..." | ||
docker tag strimzi/$(PROJECT_NAME):$(DOCKER_TAG) $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG) | ||
|
||
docker_push: docker_tag | ||
echo "Pushing $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG) ..." | ||
docker push $(DOCKER_REGISTRY)/$(DOCKER_ORG)/$(PROJECT_NAME):$(DOCKER_TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Makefile.maven contains the shared tasks for building Java applications. This file is | ||
# included into the Makefile files which contain some Java sources which should be build | ||
# | ||
|
||
java_build: | ||
echo "Building JAR file ..." | ||
mvn package | ||
|
||
java_clean: | ||
echo "Cleaning Maven build ..." | ||
mvn clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
|
||
USER root | ||
|
||
RUN microdnf update \ | ||
&& microdnf install java-11-openjdk-headless shadow-utils \ | ||
&& microdnf clean all | ||
|
||
# Set JAVA_HOME env var | ||
ENV JAVA_HOME /usr/lib/jvm/jre-11 | ||
|
||
# Add strimzi user with UID 1001 | ||
# The user is in the group 0 to have access to the mounted volumes and storage | ||
RUN useradd -r -m -u 1001 -g 0 strimzi | ||
|
||
ARG version=latest | ||
ENV VERSION ${version} | ||
|
||
COPY ./scripts/ /bin | ||
COPY ./src/resources/log4j2.properties /bin/log4j2.properties | ||
|
||
ADD target/test-client-kafka-consumer-0.1.0-SNAPSHOT.jar / | ||
|
||
USER 1001 | ||
|
||
CMD ["/bin/run.sh", "/test-client-kafka-consumer-0.1.0-SNAPSHOT.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
PROJECT_NAME=test-client-kafka-consumer | ||
|
||
all: java_build docker_build docker_push | ||
build: java_build | ||
clean: java_clean | ||
|
||
include ../../Makefile.docker | ||
|
||
include ../../Makefile.maven | ||
|
||
.PHONY: build clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.strimzi</groupId> | ||
<artifactId>kafka-test-clients</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>test-client-kafka-consumer</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.kafka</groupId> | ||
<artifactId>kafka-clients</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
<version>${log4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<version>${log4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> | ||
<version>${log4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jaegertracing</groupId> | ||
<artifactId>jaeger-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>opentracing-kafka-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.strimzi</groupId> | ||
<artifactId>kafka-oauth-client</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
Oops, something went wrong.