Search in sources :

Example 11 with GlobalMetadata

use of org.apache.gobblin.metadata.types.GlobalMetadata in project incubator-gobblin by apache.

the class RecordWithMetadataToEnvelopedRecordWithMetadata method updateRecordMetadata.

private void updateRecordMetadata(RecordWithMetadata<?> inputRecord) {
    GlobalMetadata md = inputRecord.getMetadata().getGlobalMetadata();
    String origContentType = md.getContentType();
    if (origContentType != null) {
        md.setInnerContentType(origContentType);
    }
    md.setContentType(CONTENT_TYPE);
    md.markImmutable();
}
Also used : GlobalMetadata(org.apache.gobblin.metadata.types.GlobalMetadata)

Example 12 with GlobalMetadata

use of org.apache.gobblin.metadata.types.GlobalMetadata in project incubator-gobblin by apache.

the class BaseDataPublisherTest method checkMetadata.

private void checkMetadata(File file, int expectedNumFiles, int expectedNumRecords, FsWriterMetrics.FileInfo... expectedFileInfo) throws IOException {
    Assert.assertTrue(file.exists(), "Expected file " + file.getAbsolutePath() + " to exist");
    String contents = IOUtils.toString(new FileInputStream(file), StandardCharsets.UTF_8);
    GlobalMetadata metadata = GlobalMetadata.fromJson(contents);
    Assert.assertEquals(metadata.getNumFiles(), expectedNumFiles, "# of files do not match");
    Assert.assertEquals(metadata.getNumRecords(), expectedNumRecords, "# of records do not match");
    for (FsWriterMetrics.FileInfo fileInfo : expectedFileInfo) {
        long recordsInMetadata = ((Number) metadata.getFileMetadata(fileInfo.getFileName(), GlobalMetadata.NUM_RECORDS_KEY)).longValue();
        Assert.assertEquals(recordsInMetadata, fileInfo.getNumRecords(), "# of records in file-level metadata do not match");
    }
}
Also used : GlobalMetadata(org.apache.gobblin.metadata.types.GlobalMetadata) FsWriterMetrics(org.apache.gobblin.writer.FsWriterMetrics) FileInputStream(java.io.FileInputStream)

Example 13 with GlobalMetadata

use of org.apache.gobblin.metadata.types.GlobalMetadata in project incubator-gobblin by apache.

the class GlobalMetadataCollectorTest method handlesNullDefaults.

@Test
public void handlesNullDefaults() {
    GlobalMetadataCollector collectorWithNoDefaults = new GlobalMetadataCollector(-1);
    GlobalMetadata record = buildMetadataWithContentType(CONTENT_TYPE);
    GlobalMetadata newRecord = collectorWithNoDefaults.processMetadata(record);
    Assert.assertEquals(newRecord, record);
    Assert.assertEquals(collectorWithNoDefaults.getMetadataRecords().size(), 1);
}
Also used : GlobalMetadata(org.apache.gobblin.metadata.types.GlobalMetadata) Test(org.testng.annotations.Test)

Example 14 with GlobalMetadata

use of org.apache.gobblin.metadata.types.GlobalMetadata in project incubator-gobblin by apache.

the class GlobalMetadataCollectorTest method testDoesNotStoreRecordTwice.

@Test
public void testDoesNotStoreRecordTwice() {
    GlobalMetadata defaults = buildMetadataWithUrn("DEFAULT");
    GlobalMetadataCollector collectorWithDefaults = new GlobalMetadataCollector(defaults, -1);
    GlobalMetadata r1 = buildMetadataWithContentType(CONTENT_TYPE);
    GlobalMetadata newRecord = collectorWithDefaults.processMetadata(r1);
    Assert.assertNotNull(newRecord);
    GlobalMetadata r2 = buildMetadataWithContentType(CONTENT_TYPE);
    newRecord = collectorWithDefaults.processMetadata(r2);
    Assert.assertNull(newRecord);
    Assert.assertEquals(collectorWithDefaults.getMetadataRecords().size(), 1);
}
Also used : GlobalMetadata(org.apache.gobblin.metadata.types.GlobalMetadata) Test(org.testng.annotations.Test)

Example 15 with GlobalMetadata

use of org.apache.gobblin.metadata.types.GlobalMetadata in project incubator-gobblin by apache.

the class SimpleConfigMetadataProvider method getGlobalMetadataForDataset.

@Override
public GlobalMetadata getGlobalMetadataForDataset(String datasetUrn) {
    GlobalMetadata defaultMetadata = new GlobalMetadata();
    defaultMetadata.setDatasetUrn(datasetUrn);
    PermissionMetadataParser.setPermission(defaultMetadata, permission);
    return defaultMetadata;
}
Also used : GlobalMetadata(org.apache.gobblin.metadata.types.GlobalMetadata)

Aggregations

GlobalMetadata (org.apache.gobblin.metadata.types.GlobalMetadata)16 Test (org.testng.annotations.Test)9 File (java.io.File)5 State (org.apache.gobblin.configuration.State)5 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)5 FsWriterMetrics (org.apache.gobblin.writer.FsWriterMetrics)5 TaskState (org.apache.hadoop.mapreduce.v2.api.records.TaskState)5 FileInputStream (java.io.FileInputStream)3 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 ImmutableList (com.google.common.collect.ImmutableList)1 Files (com.google.common.io.Files)1 ConfigFactory (com.typesafe.config.ConfigFactory)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1