Search in sources :

Example 1 with CombineRetentionPolicy

use of org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy in project incubator-gobblin by apache.

the class CombineRetentionPolicyTest method testCommonSuperclass.

@Test
public void testCommonSuperclass() throws IOException {
    Properties props = new Properties();
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "1", ContainsARetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.DELETE_SETS_COMBINE_OPERATION, CombineRetentionPolicy.DeletableCombineOperation.INTERSECT.name());
    CombineRetentionPolicy policy = new CombineRetentionPolicy(props);
    Assert.assertEquals(policy.commonSuperclass(StringDatasetVersion.class, StringDatasetVersion.class), StringDatasetVersion.class);
    Assert.assertEquals(policy.commonSuperclass(StringDatasetVersion.class, TimestampedDatasetVersion.class), DatasetVersion.class);
    Assert.assertEquals(policy.commonSuperclass(StringDatasetVersion.class, FileStatusDatasetVersion.class), StringDatasetVersion.class);
    Assert.assertEquals(policy.commonSuperclass(FileStatusDatasetVersion.class, StringDatasetVersion.class), StringDatasetVersion.class);
    Assert.assertEquals(policy.commonSuperclass(DatasetVersion.class, StringDatasetVersion.class), DatasetVersion.class);
}
Also used : CombineRetentionPolicy(org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy) TimestampedDatasetVersion(org.apache.gobblin.data.management.version.TimestampedDatasetVersion) ContainsARetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsARetentionPolicy) FileStatusDatasetVersion(org.apache.gobblin.data.management.version.FileStatusDatasetVersion) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) DatasetVersion(org.apache.gobblin.data.management.version.DatasetVersion) FileStatusDatasetVersion(org.apache.gobblin.data.management.version.FileStatusDatasetVersion) TimestampedDatasetVersion(org.apache.gobblin.data.management.version.TimestampedDatasetVersion) Properties(java.util.Properties) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) Test(org.testng.annotations.Test)

Example 2 with CombineRetentionPolicy

use of org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy in project incubator-gobblin by apache.

the class CombineRetentionPolicyTest method testIntersect.

@Test
public void testIntersect() throws IOException {
    Properties props = new Properties();
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "1", ContainsARetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "2", ContainsBRetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "3", ContainsCRetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.DELETE_SETS_COMBINE_OPERATION, CombineRetentionPolicy.DeletableCombineOperation.INTERSECT.name());
    CombineRetentionPolicy policy = new CombineRetentionPolicy(props);
    Collection<DatasetVersion> deletableVersions = policy.listDeletableVersions(Lists.<DatasetVersion>newArrayList(new StringDatasetVersion("a", new Path("/")), new StringDatasetVersion("abc", new Path("/")), new StringDatasetVersion("abcd", new Path("/")), new StringDatasetVersion("bc", new Path("/")), new StringDatasetVersion("d", new Path("/"))));
    Set<String> actualDeletableVersions = Sets.newHashSet(Iterables.transform(deletableVersions, new Function<DatasetVersion, String>() {

        @Nullable
        @Override
        public String apply(DatasetVersion input) {
            return ((StringDatasetVersion) input).getVersion();
        }
    }));
    Assert.assertEquals(policy.versionClass(), StringDatasetVersion.class);
    Assert.assertEquals(deletableVersions.size(), 2);
    Assert.assertEquals(actualDeletableVersions, Sets.newHashSet("abcd", "abc"));
}
Also used : ContainsCRetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsCRetentionPolicy) CombineRetentionPolicy(org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy) Path(org.apache.hadoop.fs.Path) Function(com.google.common.base.Function) ContainsARetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsARetentionPolicy) ContainsBRetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsBRetentionPolicy) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) DatasetVersion(org.apache.gobblin.data.management.version.DatasetVersion) FileStatusDatasetVersion(org.apache.gobblin.data.management.version.FileStatusDatasetVersion) TimestampedDatasetVersion(org.apache.gobblin.data.management.version.TimestampedDatasetVersion) Properties(java.util.Properties) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) Test(org.testng.annotations.Test)

Example 3 with CombineRetentionPolicy

use of org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy in project incubator-gobblin by apache.

the class CombineRetentionPolicyTest method testUnion.

@Test
public void testUnion() throws IOException {
    Properties props = new Properties();
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "1", ContainsARetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "2", ContainsBRetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.RETENTION_POLICIES_PREFIX + "3", ContainsCRetentionPolicy.class.getCanonicalName());
    props.setProperty(CombineRetentionPolicy.DELETE_SETS_COMBINE_OPERATION, CombineRetentionPolicy.DeletableCombineOperation.UNION.name());
    CombineRetentionPolicy policy = new CombineRetentionPolicy(props);
    Collection<DatasetVersion> deletableVersions = policy.listDeletableVersions(Lists.<DatasetVersion>newArrayList(new StringDatasetVersion("a", new Path("/")), new StringDatasetVersion("abc", new Path("/")), new StringDatasetVersion("abcd", new Path("/")), new StringDatasetVersion("bc", new Path("/")), new StringDatasetVersion("d", new Path("/"))));
    Set<String> actualDeletableVersions = Sets.newHashSet(Iterables.transform(deletableVersions, new Function<DatasetVersion, String>() {

        @Nullable
        @Override
        public String apply(DatasetVersion input) {
            return ((StringDatasetVersion) input).getVersion();
        }
    }));
    Assert.assertEquals(deletableVersions.size(), 4);
    Assert.assertEquals(actualDeletableVersions, Sets.newHashSet("abcd", "abc", "a", "bc"));
}
Also used : ContainsCRetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsCRetentionPolicy) CombineRetentionPolicy(org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy) Path(org.apache.hadoop.fs.Path) Function(com.google.common.base.Function) ContainsARetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsARetentionPolicy) ContainsBRetentionPolicy(org.apache.gobblin.data.management.retention.test.ContainsBRetentionPolicy) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) DatasetVersion(org.apache.gobblin.data.management.version.DatasetVersion) FileStatusDatasetVersion(org.apache.gobblin.data.management.version.FileStatusDatasetVersion) TimestampedDatasetVersion(org.apache.gobblin.data.management.version.TimestampedDatasetVersion) Properties(java.util.Properties) StringDatasetVersion(org.apache.gobblin.data.management.version.StringDatasetVersion) Test(org.testng.annotations.Test)

Aggregations

Properties (java.util.Properties)3 CombineRetentionPolicy (org.apache.gobblin.data.management.retention.policy.CombineRetentionPolicy)3 ContainsARetentionPolicy (org.apache.gobblin.data.management.retention.test.ContainsARetentionPolicy)3 DatasetVersion (org.apache.gobblin.data.management.version.DatasetVersion)3 FileStatusDatasetVersion (org.apache.gobblin.data.management.version.FileStatusDatasetVersion)3 StringDatasetVersion (org.apache.gobblin.data.management.version.StringDatasetVersion)3 TimestampedDatasetVersion (org.apache.gobblin.data.management.version.TimestampedDatasetVersion)3 Test (org.testng.annotations.Test)3 Function (com.google.common.base.Function)2 ContainsBRetentionPolicy (org.apache.gobblin.data.management.retention.test.ContainsBRetentionPolicy)2 ContainsCRetentionPolicy (org.apache.gobblin.data.management.retention.test.ContainsCRetentionPolicy)2 Path (org.apache.hadoop.fs.Path)2