hudi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-hudi] yanghua commented on a change in pull request #1397: [HUDI-692] Add delete savepoint for cli
Date Wed, 11 Mar 2020 09:16:21 GMT
yanghua commented on a change in pull request #1397: [HUDI-692] Add delete savepoint for cli
URL: https://github.com/apache/incubator-hudi/pull/1397#discussion_r390833231
 
 

 ##########
 File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/SavepointsCommand.java
 ##########
 @@ -127,6 +127,26 @@ public String refreshMetaClient() {
     return "Metadata for table " + HoodieCLI.getTableMetaClient().getTableConfig().getTableName()
+ " refreshed.";
   }
 
+  @CliCommand(value = "savepoint delete", help = "Delete the savepoint")
+  public String deleteSavepoint(@CliOption(key = {"commit"}, help = "Delete a savepoint")
final String commitTime) throws Exception {
+    HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient();
+    HoodieTimeline completedInstants = metaClient.getActiveTimeline().getSavePointTimeline().filterCompletedInstants();
+    if (completedInstants.empty()) {
+      throw new HoodieException("There are no completed savepoint to run delete");
+    }
+    HoodieInstant savePoint = new HoodieInstant(false, HoodieTimeline.SAVEPOINT_ACTION, commitTime);
+
+    if (!completedInstants.containsInstant(savePoint)) {
+      return "Commit " + commitTime + " not found in Commits " + completedInstants;
+    }
+
+    JavaSparkContext jsc = SparkUtil.initJavaSparkConf("Delete Savepoint");
+    HoodieWriteClient client = createHoodieClient(jsc, metaClient.getBasePath());
+    client.deleteSavepoint(commitTime);
+    jsc.close();
 
 Review comment:
   `JavaSparkContext` implements `AutoCloseable` interface, can we use `try-with-resource`
here to avoid the resource leak?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message