Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub MetadataResponseFuture

From Leeroopedia
Revision as of 14:43, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Datahub_project_Datahub_MetadataResponseFuture.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Java_SDK, Metadata_Emission
Last Updated 2026-02-10 00:00 GMT

Overview

A Future<MetadataWriteResponse> implementation that wraps an underlying HTTP response future and maps it to a DataHub metadata write response.

Description

MetadataResponseFuture adapts an Apache HTTP Client Future<SimpleHttpResponse> into a Future<MetadataWriteResponse> that the DataHub client SDK consumers can work with. It supports two resolution strategies:

  1. Callback-based resolution: Uses a CountDownLatch and an AtomicReference<MetadataWriteResponse> that an external callback populates. The get() method waits on the latch until the callback completes.
  2. Mapper-based resolution: Uses a ResponseMapper functional interface to synchronously transform the SimpleHttpResponse into a MetadataWriteResponse when get() is called.

The class delegates cancellation and status checks (cancel, isCancelled, isDone) directly to the underlying HTTP future.

The inner ResponseMapper functional interface provides a clean extension point for custom response mapping logic.

Usage

This class is used internally by the REST emitter to wrap asynchronous HTTP calls. It is not typically instantiated directly by SDK consumers but is returned from Emitter.emit() calls.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/MetadataResponseFuture.java

Signature

public class MetadataResponseFuture implements Future<MetadataWriteResponse> {

    // Callback-based constructor
    public MetadataResponseFuture(
        Future<SimpleHttpResponse> underlyingFuture,
        AtomicReference<MetadataWriteResponse> responseAtomicReference,
        CountDownLatch responseLatch)

    // Mapper-based constructor
    public MetadataResponseFuture(
        Future<SimpleHttpResponse> underlyingFuture,
        ResponseMapper mapper)

    public boolean cancel(boolean mayInterruptIfRunning)
    public boolean isCancelled()
    public boolean isDone()
    public MetadataWriteResponse get() throws InterruptedException, ExecutionException
    public MetadataWriteResponse get(long timeout, TimeUnit unit)
        throws InterruptedException, ExecutionException, TimeoutException

    @FunctionalInterface
    public interface ResponseMapper {
        MetadataWriteResponse map(SimpleHttpResponse httpResponse);
    }
}

Import

import datahub.client.MetadataResponseFuture;

I/O Contract

Inputs

Constructor Parameter Type Description
Callback-based underlyingFuture Future<SimpleHttpResponse> The underlying HTTP future
Callback-based responseAtomicReference AtomicReference<MetadataWriteResponse> Reference populated by external callback
Callback-based responseLatch CountDownLatch Latch signaled when the callback completes
Mapper-based underlyingFuture Future<SimpleHttpResponse> The underlying HTTP future
Mapper-based mapper ResponseMapper Functional interface mapping HTTP response to metadata response

Outputs

  • get() and get(timeout, unit) return a MetadataWriteResponse containing the success status and response content.
  • cancel(), isCancelled(), and isDone() return boolean status values delegated from the underlying future.

Usage Examples

// Mapper-based usage (internal to REST emitter)
MetadataResponseFuture future = new MetadataResponseFuture(
    httpFuture,
    response -> MetadataWriteResponse.builder()
        .success(response.getCode() == 200)
        .responseContent(response.getBodyText())
        .build()
);

MetadataWriteResponse result = future.get(10, TimeUnit.SECONDS);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment