Skip to content

Commit

Permalink
Showing 1 changed file with 65 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
package io.micronaut.configuration.kafka.graal;

import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.zip.CRC32;
import java.util.zip.Checksum;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;

import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.record.BufferSupplier;
import org.apache.kafka.common.metrics.KafkaMetric;
import org.apache.kafka.common.metrics.Metrics;
import org.apache.kafka.common.metrics.MetricsReporter;
import org.apache.kafka.common.record.CompressionType;
import static org.apache.kafka.common.record.CompressionType.*;
import org.apache.kafka.common.utils.ByteBufferInputStream;
import org.apache.kafka.common.utils.ByteBufferOutputStream;
import java.util.zip.GZIPOutputStream;
import java.util.zip.GZIPInputStream;
import java.io.BufferedOutputStream;;
import java.io.BufferedInputStream;
import org.apache.kafka.common.record.KafkaLZ4BlockInputStream;
import org.apache.kafka.common.record.KafkaLZ4BlockOutputStream;
import org.apache.kafka.common.record.RecordBatch;
import org.apache.kafka.common.utils.AppInfoParser;

import java.util.List;
import java.util.Map;
import java.util.zip.CRC32;
import java.util.zip.Checksum;



@TargetClass(className = "org.apache.kafka.common.utils.Crc32C$Java9ChecksumFactory")
@Substitute
@@ -38,6 +28,7 @@ public Checksum create() {

}

// Replace unsupported compression types
@TargetClass(className = "org.apache.kafka.common.record.CompressionType")
final class CompressionTypeSubs {

@@ -50,3 +41,56 @@ final class CompressionTypeSubs {
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
public static CompressionType ZSTD = CompressionType.GZIP;
}

// Replace JMX metrics, no operable on GraalVM
@TargetClass(className = "org.apache.kafka.common.metrics.JmxReporter")
@Substitute
final class NoopReporter implements MetricsReporter {

@Substitute
public NoopReporter() {
}

@Substitute
public NoopReporter(String prefix) {
}

@Override
@Substitute
public void init(List<KafkaMetric> metrics) {
}

@Override
@Substitute
public void metricChange(KafkaMetric metric) {
}

@Override
@Substitute
public void metricRemoval(KafkaMetric metric) {
}

@Override
@Substitute
public void close() {
}

@Override
@Substitute
public void configure(Map<String, ?> configs) {
}
}

@TargetClass(AppInfoParser.class)
final class AppInfoParserNoJMX {

@Substitute
public static void registerAppInfo(String prefix, String id, Metrics metrics, long nowMs) {
// no-op
}

@Substitute
public static void unregisterAppInfo(String prefix, String id, Metrics metrics) {
// no-op
}
}

0 comments on commit 3359ea5

Please sign in to comment.