Skip to content

Commit

Permalink
quarkusio#2663 Making sure the right RocksDB native binary is added w…
Browse files Browse the repository at this point in the history
…hen doing in-container build;

Also ensuring KafkaProcessor runs when using kafka-streams extension.
  • Loading branch information
gunnarmorling committed Jun 13, 2019
1 parent e6b47d6 commit c405935
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions extensions/kafka-streams/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-client-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kafka-streams</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ void build(RecorderContext recorder,
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, false, ByteArraySerde.class));
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, false, FailOnInvalidTimestamp.class));

nativeLibs.produce(new SubstrateResourceBuildItem(Environment.getJniLibraryFileName("rocksdb")));
// for RocksDB, either add linux64 native lib when targeting containers
if (isContainerBuild()) {
nativeLibs.produce(new SubstrateResourceBuildItem("librocksdbjni-linux64.so"));
}
// otherwise the native lib of the platform this build runs on
else {
nativeLibs.produce(new SubstrateResourceBuildItem(Environment.getJniLibraryFileName("rocksdb")));
}

// re-initializing RocksDB to enable load of native libs
reinitialized.produce(new RuntimeReinitializedClassBuildItem("org.rocksdb.RocksDB"));
Expand All @@ -69,4 +76,22 @@ void build(KafkaStreamsTemplate template) {
// static initializers which already ran during build
template.loadRocksDb();
}

private boolean isContainerBuild() {
String containerRuntime = System.getProperty("native-image.container-runtime");

if (containerRuntime != null) {
containerRuntime = containerRuntime.trim().toLowerCase();
return containerRuntime.equals("docker") || containerRuntime.equals("podman");
}

String dockerBuild = System.getProperty("native-image.docker-build");

if (dockerBuild != null) {
dockerBuild = dockerBuild.trim().toLowerCase();
return !"false".equals(dockerBuild);
}

return false;
}
}

0 comments on commit c405935

Please sign in to comment.