Skip to content

Commit

Permalink
Add option to disable chuncked encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
treff7es committed Nov 15, 2024
1 parent 413b6dd commit 8dcbe18
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
26 changes: 14 additions & 12 deletions metadata-integration/java/acryl-spark-lineage/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.palantir.git-version") apply false
}
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'signing'
apply plugin: 'io.codearte.nexus-staging'
Expand Down Expand Up @@ -91,6 +91,8 @@ shadowJar {
zip64 = true
archiveClassifier = ''
mergeServiceFiles()
project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation]

def exclude_modules = project
.configurations
Expand Down Expand Up @@ -126,25 +128,24 @@ shadowJar {
relocate 'org.slf4j', 'datahub.spark2.shaded.org.slf4j'
//
relocate 'org.apache.hc', 'io.acryl.shaded.http'
relocate 'org.apache.commons.codec', 'datahub.spark2.shaded.o.a.c.codec'
relocate 'org.apache.commons.compress', 'datahub.spark2.shaded.o.a.c.compress'
relocate 'org.apache.commons.lang3', 'datahub.spark2.shaded.o.a.c.lang3'
relocate 'org.apache.commons.codec', 'io.acryl.shaded.org.apache.commons.codec'
relocate 'org.apache.commons.codec', 'io.acryl.shaded.org.apache.commons.compress'
relocate 'org.apache.commons.codec', 'io.acryl.shaded.org.apache.commons.lang3'
relocate 'mozilla', 'datahub.spark2.shaded.mozilla'
relocate 'com.typesafe', 'datahub.spark2.shaded.typesafe'
relocate 'io.opentracing', 'datahub.spark2.shaded.io.opentracing'
relocate 'io.netty', 'datahub.spark2.shaded.io.netty'
relocate 'ch.randelshofer', 'datahub.spark2.shaded.ch.randelshofer'
relocate 'ch.qos', 'datahub.spark2.shaded.ch.qos'
relocate 'com.typesafe', 'io.acryl.shaded.com.typesafe'
relocate 'io.opentracing', 'io.acryl.shaded.io.opentracing'
relocate 'io.netty', 'io.acryl.shaded.io.netty'
relocate 'ch.randelshofer', 'io.acryl.shaded.ch.randelshofer'
relocate 'ch.qos', 'io.acryl.shaded.ch.qos'
relocate 'org.springframework', 'io.acryl.shaded.org.springframework'
relocate 'com.fasterxml.jackson', 'io.acryl.shaded.jackson'
relocate 'org.yaml', 'io.acryl.shaded.org.yaml' // Required for shading snakeyaml
relocate 'net.jcip.annotations', 'io.acryl.shaded.annotations'
relocate 'javassist', 'io.acryl.shaded.javassist'
relocate 'edu.umd.cs.findbugs', 'io.acryl.shaded.findbugs'
relocate 'org.antlr', 'io.acryl.shaded.org.antlr'
relocate 'antlr', 'io.acryl.shaded.antlr'
//relocate 'org.antlr', 'io.acryl.shaded.org.antlr'
//relocate 'antlr', 'io.acryl.shaded.antlr'
relocate 'com.google.common', 'io.acryl.shaded.com.google.common'
relocate 'org.apache.commons', 'io.acryl.shaded.org.apache.commons'
relocate 'org.reflections', 'io.acryl.shaded.org.reflections'
relocate 'st4hidden', 'io.acryl.shaded.st4hidden'
relocate 'org.stringtemplate', 'io.acryl.shaded.org.stringtemplate'
Expand All @@ -155,6 +156,7 @@ shadowJar {
relocate 'org.checkerframework', 'io.acryl.shaded.org.checkerframework'
relocate 'com.google.errorprone', 'io.acryl.shaded.com.google.errorprone'
relocate 'com.sun.jna', 'io.acryl.shaded.com.sun.jna'

}

checkShadowJar {
Expand Down
4 changes: 2 additions & 2 deletions metadata-integration/java/datahub-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jar {
}

dependencies {
implementation project(':entity-registry')
implementation project(':metadata-integration:java:datahub-event')
api project(':entity-registry')
api project(':metadata-integration:java:datahub-event')
implementation(externalDependency.kafkaAvroSerializer) {
exclude group: "org.apache.avro"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public boolean retryRequest(

@Override
public boolean retryRequest(HttpResponse response, int execCount, HttpContext context) {
log.warn("Retrying request due to error: {}", response);
return super.retryRequest(response, execCount, context);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datahub.client.rest;

import static com.linkedin.metadata.Constants.*;
import static org.apache.hc.core5.http.HttpHeaders.*;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.StreamReadConstraints;
Expand All @@ -26,6 +27,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import javax.annotation.concurrent.ThreadSafe;
Expand Down Expand Up @@ -97,17 +99,21 @@ public RestEmitter(RestEmitterConfig config) {
this.config = config;
HttpAsyncClientBuilder httpClientBuilder = this.config.getAsyncHttpClientBuilder();
httpClientBuilder.setRetryStrategy(new DatahubHttpRequestRetryStrategy());
if ((config.getTimeoutSec() != null) || (config.isDisableChunkedEncoding())) {
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
// Override httpClient settings with RestEmitter configs if present
if (config.getTimeoutSec() != null) {
requestConfigBuilder
.setConnectionRequestTimeout(config.getTimeoutSec() * 1000, TimeUnit.MILLISECONDS)
.setResponseTimeout(config.getTimeoutSec() * 1000, TimeUnit.MILLISECONDS);
}
if (config.isDisableChunkedEncoding()) {
requestConfigBuilder.setContentCompressionEnabled(false);
}

// Override httpClient settings with RestEmitter configs if present
if (config.getTimeoutSec() != null) {
httpClientBuilder.setDefaultRequestConfig(
RequestConfig.custom()
.setConnectionRequestTimeout(
config.getTimeoutSec() * 1000, java.util.concurrent.TimeUnit.MILLISECONDS)
.setResponseTimeout(
config.getTimeoutSec() * 1000, java.util.concurrent.TimeUnit.MILLISECONDS)
.build());
httpClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
}

PoolingAsyncClientConnectionManagerBuilder poolingAsyncClientConnectionManagerBuilder =
PoolingAsyncClientConnectionManagerBuilder.create();

Expand Down Expand Up @@ -225,6 +231,7 @@ private Future<MetadataWriteResponse> postGeneric(
}

simpleRequestBuilder.setBody(payloadJson, ContentType.APPLICATION_JSON);

AtomicReference<MetadataWriteResponse> responseAtomicReference = new AtomicReference<>();
CountDownLatch responseLatch = new CountDownLatch(1);
FutureCallback<SimpleHttpResponse> httpCallback =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class RestEmitterConfig {
Integer timeoutSec;
@Builder.Default boolean disableSslVerification = false;

@Builder.Default boolean disableChunkedEncoding = false;

@Builder.Default int maxRetries = 0;

@Builder.Default int retryIntervalSec = 10;
Expand Down

0 comments on commit 8dcbe18

Please sign in to comment.