Search in sources :

Example 16 with DatasetDescriptor

use of org.apache.gobblin.dataset.DatasetDescriptor in project incubator-gobblin by apache.

the class LineageInfo method putDestination.

/**
 * Put a {@link DatasetDescriptor} of a destination dataset to a state
 *
 * <p>
 *   Only the {@link org.apache.gobblin.writer.DataWriter} or {@link org.apache.gobblin.publisher.DataPublisher}
 *   is supposed to put the destination dataset information. Since different branches may concurrently put,
 *   the method is implemented to be threadsafe
 * </p>
 */
public void putDestination(DatasetDescriptor destination, int branchId, State state) {
    if (!hasLineageInfo(state)) {
        log.warn("State has no lineage info but branch " + branchId + " puts a destination: " + GSON.toJson(destination));
        return;
    }
    log.debug(String.format("Put destination %s for branch %d", GSON.toJson(destination), branchId));
    synchronized (state.getProp(getKey(NAME_KEY))) {
        DatasetDescriptor descriptor = resolver.resolve(destination, state);
        if (descriptor == null) {
            return;
        }
        state.setProp(getKey(BRANCH, branchId, LineageEventBuilder.DESTINATION), GSON.toJson(descriptor));
    }
}
Also used : DatasetDescriptor(org.apache.gobblin.dataset.DatasetDescriptor)

Aggregations

DatasetDescriptor (org.apache.gobblin.dataset.DatasetDescriptor)16 Test (org.testng.annotations.Test)6 Path (org.apache.hadoop.fs.Path)5 LineageInfo (org.apache.gobblin.metrics.event.lineage.LineageInfo)4 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)3 WorkUnit (org.apache.gobblin.source.workunit.WorkUnit)3 Gson (com.google.gson.Gson)2 SourceState (org.apache.gobblin.configuration.SourceState)2 State (org.apache.gobblin.configuration.State)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Config (com.typesafe.config.Config)1 URI (java.net.URI)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ToString (lombok.ToString)1 ConversionConfig (org.apache.gobblin.data.management.conversion.hive.dataset.ConvertibleHiveDataset.ConversionConfig)1 LineageEventBuilder (org.apache.gobblin.metrics.event.lineage.LineageEventBuilder)1 QueryBasedSource (org.apache.gobblin.source.extractor.extract.QueryBasedSource)1 Extract (org.apache.gobblin.source.workunit.Extract)1