Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spark-lineage): default timeout for future responses #10947

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public MetadataWriteResponse get(long timeout, TimeUnit unit)
return mapper.map(response);
} else {
// We wait for the callback to fill this out
responseLatch.await();
responseLatch.await(timeout, unit);
return responseReference.get();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void completed(SimpleHttpResponse response) {

@Override
public void failed(Exception ex) {
responseLatch.countDown();
if (callback != null) {
try {
callback.onFailure(ex);
Expand All @@ -261,6 +262,7 @@ public void failed(Exception ex) {

@Override
public void cancelled() {
responseLatch.countDown();
if (callback != null) {
try {
callback.onFailure(new RuntimeException("Cancelled"));
Expand Down Expand Up @@ -344,6 +346,7 @@ public void completed(SimpleHttpResponse response) {

@Override
public void failed(Exception ex) {
responseLatch.countDown();
if (callback != null) {
try {
callback.onFailure(ex);
Expand All @@ -355,6 +358,7 @@ public void failed(Exception ex) {

@Override
public void cancelled() {
responseLatch.countDown();
if (callback != null) {
try {
callback.onFailure(new RuntimeException("Cancelled"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
Expand All @@ -53,6 +55,7 @@ public class DatahubEventEmitter extends EventEmitter {
private final List<DatahubJob> _datahubJobs = new LinkedList<>();
private final Map<String, MetadataChangeProposalWrapper> schemaMap = new HashMap<>();
private SparkLineageConf datahubConf;
private static final int DEFAULT_TIMEOUT_SEC = 10;

private final EventFormatter eventFormatter = new EventFormatter();

Expand Down Expand Up @@ -386,8 +389,8 @@ protected void emitMcps(List<MetadataChangeProposal> mcps) {
.forEach(
future -> {
try {
log.info(future.get().toString());
} catch (InterruptedException | ExecutionException e) {
log.info(future.get(DEFAULT_TIMEOUT_SEC, TimeUnit.SECONDS).toString());
} catch (InterruptedException | ExecutionException | TimeoutException e) {
// log error, but don't impact thread
log.error("Failed to emit metadata to DataHub", e);
}
Expand Down
Loading