Search in sources :

Example 1 with DatasetStoreDataset

use of org.apache.gobblin.metastore.DatasetStoreDataset in project incubator-gobblin by apache.

the class CleanableDatasetStoreDatasetTest method testCleanStateStore.

@Test
public void testCleanStateStore() throws IOException {
    File tmpDir = Files.createTempDir();
    tmpDir.deleteOnExit();
    FileSystem fs = FileSystem.getLocal(new Configuration());
    FsDatasetStateStore store = new FsDatasetStateStore(fs, tmpDir.getAbsolutePath());
    store.persistDatasetState("dataset1", new JobState.DatasetState("job1", "job1_id1"));
    store.persistDatasetState("dataset1", new JobState.DatasetState("job1", "job1_id2"));
    store.persistDatasetState("dataset1", new JobState.DatasetState("job2", "job2_id1"));
    store.persistDatasetState("", new JobState.DatasetState("job3", "job3_id1"));
    Properties props = new Properties();
    props.setProperty(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, tmpDir.getAbsolutePath());
    props.setProperty("selection.timeBased.lookbackTime", "0m");
    TimeBasedDatasetStoreDatasetFinder datasetFinder = new TimeBasedDatasetStoreDatasetFinder(fs, props);
    List<DatasetStoreDataset> datasets = datasetFinder.findDatasets();
    for (DatasetStoreDataset dataset : datasets) {
        ((CleanableDataset) dataset).clean();
        File jobDir = new File(tmpDir.getAbsolutePath(), dataset.getKey().getStoreName());
        Assert.assertEquals(jobDir.list().length, 1);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) CleanableDataset(org.apache.gobblin.data.management.retention.dataset.CleanableDataset) FileSystem(org.apache.hadoop.fs.FileSystem) JobState(org.apache.gobblin.runtime.JobState) DatasetStoreDataset(org.apache.gobblin.metastore.DatasetStoreDataset) Properties(java.util.Properties) File(java.io.File) TimeBasedDatasetStoreDatasetFinder(org.apache.gobblin.data.management.retention.dataset.finder.TimeBasedDatasetStoreDatasetFinder) FsDatasetStateStore(org.apache.gobblin.runtime.FsDatasetStateStore) Test(org.testng.annotations.Test)

Example 2 with DatasetStoreDataset

use of org.apache.gobblin.metastore.DatasetStoreDataset in project incubator-gobblin by apache.

the class TimestampedDatasetStateStoreVersionFinder method findDatasetVersions.

@Override
public Collection<TimestampedDatasetStateStoreVersion> findDatasetVersions(Dataset dataset) throws IOException {
    DatasetStoreDataset storeDataset = ((DatasetStoreDataset) dataset);
    List<TimestampedDatasetStateStoreVersion> versions = Lists.newArrayList();
    for (DatasetStateStoreEntryManager entry : storeDataset.getDatasetStateStoreMetadataEntries()) {
        versions.add(new TimestampedDatasetStateStoreVersion(entry));
    }
    return versions;
}
Also used : DatasetStateStoreEntryManager(org.apache.gobblin.metastore.metadata.DatasetStateStoreEntryManager) DatasetStoreDataset(org.apache.gobblin.metastore.DatasetStoreDataset) TimestampedDatasetStateStoreVersion(org.apache.gobblin.data.management.version.TimestampedDatasetStateStoreVersion)

Aggregations

DatasetStoreDataset (org.apache.gobblin.metastore.DatasetStoreDataset)2 File (java.io.File)1 Properties (java.util.Properties)1 CleanableDataset (org.apache.gobblin.data.management.retention.dataset.CleanableDataset)1 TimeBasedDatasetStoreDatasetFinder (org.apache.gobblin.data.management.retention.dataset.finder.TimeBasedDatasetStoreDatasetFinder)1 TimestampedDatasetStateStoreVersion (org.apache.gobblin.data.management.version.TimestampedDatasetStateStoreVersion)1 DatasetStateStoreEntryManager (org.apache.gobblin.metastore.metadata.DatasetStateStoreEntryManager)1 FsDatasetStateStore (org.apache.gobblin.runtime.FsDatasetStateStore)1 JobState (org.apache.gobblin.runtime.JobState)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Test (org.testng.annotations.Test)1