You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by "jack-moseley (via GitHub)" <gi...@apache.org> on 2023/04/11 00:32:08 UTC

[GitHub] [gobblin] jack-moseley opened a new pull request, #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

jack-moseley opened a new pull request, #3670:
URL: https://github.com/apache/gobblin/pull/3670

   Dear Gobblin maintainers,
   
   Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
   
   
   ### JIRA
   - [x] My PR addresses the following [Gobblin JIRA](https://issues.apache.org/jira/browse/GOBBLIN/) issues and references them in the PR title. For example, "[GOBBLIN-XXX] My Gobblin PR"
       - https://issues.apache.org/jira/browse/GOBBLIN-1809
   
   
   ### Description
   - [x] Here are some details about my PR, including screenshots (if applicable):
   Add new version finder which does not actually list filepaths, and just constructs all unique path names/versions for a given lookback time with a given path partition pattern. This is useful for example with the iceberg cleanable datasets, which if decoupled from data files, should not depend on existence of the file path.
   
   Also fixed a bug in `DatasetCleaner` which sometimes causes the job to fail during shutdown and not print the actual issue with the job.
   
   ### Tests
   - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   Added unit test and tested in retention job
   
   ### Commits
   - [x] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
       1. Subject is separated from body by a blank line
       2. Subject is limited to 50 characters
       3. Subject does not end with a period
       4. Subject uses the imperative mood ("add", not "adding")
       5. Body wraps at 72 characters
       6. Body explains "what" and "why", not "how"
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] homatthew commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1162191798


##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinderTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.data.management.version.finder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Instant;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+@Test(groups = { "gobblin.data.management.version" })
+public class LookbackDateTimeDatasetVersionFinderTest {
+
+  private FileSystem fs;
+  private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH").withZone(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME));
+  // Fixed time for test consistency: April 10, 2023 5:01:27 PM GMT-07:00
+  private final Instant fixedTime = new Instant(1681171287000L);

Review Comment:
   Consider using  instead of the comment + Epoch time
   ```
    final Instant frozenInstant = Instant.parse("2023-01-01T00:00:00.000Z");
   ```



##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinderTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.data.management.version.finder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Instant;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+@Test(groups = { "gobblin.data.management.version" })
+public class LookbackDateTimeDatasetVersionFinderTest {
+
+  private FileSystem fs;
+  private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH").withZone(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME));
+  // Fixed time for test consistency: April 10, 2023 5:01:27 PM GMT-07:00
+  private final Instant fixedTime = new Instant(1681171287000L);

Review Comment:
   Consider using Instant.parse instead of the comment + Epoch time
   ```
    final Instant frozenInstant = Instant.parse("2023-01-01T00:00:00.000Z");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] homatthew commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163363722


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -67,25 +66,20 @@ public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instan
     Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
     PeriodFormatter periodFormatter =
         new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
-            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
-    this.stepDuration = Duration.standardMinutes(1);
+            .appendSuffix("d").appendHours().appendSuffix("h").toFormatter();
+    this.stepDuration = Duration.standardHours(1);
     this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
     this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
     this.endTime = endTime;
   }
 
-  @Override
-  public Class<? extends FileSystemDatasetVersion> versionClass() {
-    return TimestampedDatasetVersion.class;
-  }
-
   @Override
   public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {
     FileSystemDataset fsDataset = (FileSystemDataset) dataset;
     Set<TimestampedDatasetVersion> versions = new HashSet<>();
     Instant startTime = endTime.minus(lookbackPeriod.toStandardDuration());
 
-    while (startTime.isBefore(endTime)) {
+    while (!startTime.isAfter(endTime)) {

Review Comment:
   Does making this a for loop make it easier to read? E.g.
   ```
   for (Instant time = startTime; !time.isAfter(endTime); time.plus(stepDuration))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] Will-Lo merged pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "Will-Lo (via GitHub)" <gi...@apache.org>.
Will-Lo merged PR #3670:
URL: https://github.com/apache/gobblin/pull/3670


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163308997


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/retention/DatasetCleaner.java:
##########
@@ -176,7 +176,7 @@ public void onSuccess(Void arg0) {
   @Override
   public void close() throws IOException {
     try {
-      if (this.finishCleanSignal.isPresent()) {
+      if (this.finishCleanSignal != null && this.finishCleanSignal.isPresent()) {

Review Comment:
   Yes I found that if an exception is thrown during setup (e.g. issue instantiating the datasetsFinder), this will still be null which will cause the job to fail without actually logging the exception.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163382958


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -67,25 +66,20 @@ public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instan
     Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
     PeriodFormatter periodFormatter =
         new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
-            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
-    this.stepDuration = Duration.standardMinutes(1);
+            .appendSuffix("d").appendHours().appendSuffix("h").toFormatter();
+    this.stepDuration = Duration.standardHours(1);
     this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
     this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
     this.endTime = endTime;
   }
 
-  @Override
-  public Class<? extends FileSystemDatasetVersion> versionClass() {
-    return TimestampedDatasetVersion.class;
-  }
-
   @Override
   public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {
     FileSystemDataset fsDataset = (FileSystemDataset) dataset;
     Set<TimestampedDatasetVersion> versions = new HashSet<>();
     Instant startTime = endTime.minus(lookbackPeriod.toStandardDuration());
 
-    while (startTime.isBefore(endTime)) {
+    while (!startTime.isAfter(endTime)) {

Review Comment:
   Yeah I think it does look better, updated it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] homatthew commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163307447


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {
+    return TimestampedDatasetVersion.class;
+  }
+
+  @Override
+  public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {

Review Comment:
   And how do they handle the increase in version numbers? Presumably this will produce more versions than before in some cases. Do we know the magnitude of this increase and how it will affect downstream systems?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163159066


##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinderTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.data.management.version.finder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Instant;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+@Test(groups = { "gobblin.data.management.version" })
+public class LookbackDateTimeDatasetVersionFinderTest {
+
+  private FileSystem fs;
+  private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH").withZone(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME));
+  // Fixed time for test consistency: April 10, 2023 5:01:27 PM GMT-07:00
+  private final Instant fixedTime = new Instant(1681171287000L);

Review Comment:
   Thanks that's a good idea, updated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163306947


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {
+    return TimestampedDatasetVersion.class;
+  }
+
+  @Override
+  public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {

Review Comment:
   When using iceberg dataset cleaner (what this is intended for), the version finder will be called from `CleanableIcebergDataset`, which will just send GMCEs with those paths and not make any call to the filesystem.
   
   Even if it's used with actual file retention (`MultiVersionCleanableDatasetBase`), I see that in `FsCleanableHelper.clean` it will end up ignoring paths that don't exist so it wouldn't cause any failure.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163321511


##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinderTest.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.data.management.version.finder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Instant;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+@Test(groups = { "gobblin.data.management.version" })
+public class LookbackDateTimeDatasetVersionFinderTest {
+
+  private FileSystem fs;
+  private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH").withZone(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME));
+  private final Instant fixedTime = Instant.parse("2023-04-10T17:30:00.000-07:00");

Review Comment:
   Switched to 2023-01-01



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163320960


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);

Review Comment:
   On second thought, since minutely granularity is never really necessary, I changed it to not support minute as part of the pattern and step one hour at a time instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163316427


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {

Review Comment:
   Yeah you're right this override is not required.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] homatthew commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163256521


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {

Review Comment:
   We are extending `DateTimeDatasetVersionFinder` which implements  `AbstractDatasetVersionFinder<TimestampedDatasetVersion> `and already has the method 
   
   ```
     @Override
     public Class<? extends FileSystemDatasetVersion> versionClass() {
       return TimestampedDatasetVersion.class;
     }
   ```
   
   Is this method still required for compiling?



##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);

Review Comment:
   We step through every minute because we support lookbacks to the minute? And is this because the parent class supports to the minute?



##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinderTest.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.data.management.version.finder;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Instant;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+@Test(groups = { "gobblin.data.management.version" })
+public class LookbackDateTimeDatasetVersionFinderTest {
+
+  private FileSystem fs;
+  private DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy/MM/dd/HH").withZone(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME));
+  private final Instant fixedTime = Instant.parse("2023-04-10T17:30:00.000-07:00");

Review Comment:
   Nit: 4-10-2023 is a bit of an abritrary date for future readers and could be jarring. Start of a month / year makes more sense to me, but it's NBD either way



##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {
+    return TimestampedDatasetVersion.class;
+  }
+
+  @Override
+  public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {

Review Comment:
   Who is consuming these dataset versions? How do they handle paths that do not exist



##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/retention/DatasetCleaner.java:
##########
@@ -176,7 +176,7 @@ public void onSuccess(Void arg0) {
   @Override
   public void close() throws IOException {
     try {
-      if (this.finishCleanSignal.isPresent()) {
+      if (this.finishCleanSignal != null && this.finishCleanSignal.isPresent()) {

Review Comment:
   Null case happens when we close when we never cleaned right? 



##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);

Review Comment:
   It's a bit wasteful but since we dedupe using a set, it should be pretty harmless



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] jack-moseley commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "jack-moseley (via GitHub)" <gi...@apache.org>.
jack-moseley commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163325383


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {
+    return TimestampedDatasetVersion.class;
+  }
+
+  @Override
+  public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {

Review Comment:
   If we set the iceberg retention lookback to one day longer than the file retention (which is what my plan is), it means each drop_files GMCE will contain a list of 24 previous partitions instead of about 3. I expect there should be little to no performance impact due to that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [gobblin] homatthew commented on a diff in pull request #3670: [GOBBLIN-1809] Add new lookback version finder for use with iceberg retention

Posted by "homatthew (via GitHub)" <gi...@apache.org>.
homatthew commented on code in PR #3670:
URL: https://github.com/apache/gobblin/pull/3670#discussion_r1163382712


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/version/finder/LookbackDateTimeDatasetVersionFinder.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.data.management.version.finder;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.joda.time.Period;
+import org.joda.time.format.PeriodFormatter;
+import org.joda.time.format.PeriodFormatterBuilder;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.data.management.version.FileSystemDatasetVersion;
+import org.apache.gobblin.data.management.version.TimestampedDatasetVersion;
+import org.apache.gobblin.dataset.Dataset;
+import org.apache.gobblin.dataset.FileSystemDataset;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * {@link DatasetVersionFinder} that constructs {@link TimestampedDatasetVersion}s without actually checking for existence
+ * of the version path. The version path is constructed by appending the version partition pattern to the dataset root.
+ * The versions are found by looking back a specific period of time and finding unique date partitions between that
+ * time and the current time.
+ */
+public class LookbackDateTimeDatasetVersionFinder extends DateTimeDatasetVersionFinder {
+  public static final String VERSION_PATH_PREFIX = "version.path.prefix";
+  public static final String VERSION_LOOKBACK_PERIOD = "version.lookback.period";
+
+  private final Duration stepDuration;
+  private final Period lookbackPeriod;
+  private final String pathPrefix;
+  private final Instant endTime;
+
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config) {
+    this(fs, config, Instant.now());
+  }
+
+  @VisibleForTesting
+  public LookbackDateTimeDatasetVersionFinder(FileSystem fs, Config config, Instant endTime) {
+    super(fs, config);
+    Preconditions.checkArgument(config.hasPath(VERSION_LOOKBACK_PERIOD) , "Missing required property " + VERSION_LOOKBACK_PERIOD);
+    PeriodFormatter periodFormatter =
+        new PeriodFormatterBuilder().appendYears().appendSuffix("y").appendMonths().appendSuffix("M").appendDays()
+            .appendSuffix("d").appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").toFormatter();
+    this.stepDuration = Duration.standardMinutes(1);
+    this.pathPrefix = ConfigUtils.getString(config, VERSION_PATH_PREFIX, "");
+    this.lookbackPeriod = periodFormatter.parsePeriod(config.getString(VERSION_LOOKBACK_PERIOD));
+    this.endTime = endTime;
+  }
+
+  @Override
+  public Class<? extends FileSystemDatasetVersion> versionClass() {
+    return TimestampedDatasetVersion.class;
+  }
+
+  @Override
+  public Collection<TimestampedDatasetVersion> findDatasetVersions(Dataset dataset) throws IOException {

Review Comment:
   FYI for future readers, these 24 partitions are later translated to an expression, so it doesn't really matter how long the partition list is
   https://github.com/apache/gobblin/blob/0d69363abc776812a4f0352860a4125c7f28a508/gobblin-iceberg/src/main/java/org/apache/gobblin/iceberg/writer/IcebergMetadataWriter.java#L667-L674



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org