vinayakphegde commented on code in PR #6717:
URL: https://github.com/apache/hbase/pull/6717#discussion_r2115689818


##########
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/PointInTimeRestoreDriver.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.hadoop.hbase.backup;
+
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.CONF_CONTINUOUS_BACKUP_WAL_DIR;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.LONG_OPTION_PITR_BACKUP_PATH;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.LONG_OPTION_TO_DATETIME;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.OPTION_PITR_BACKUP_PATH;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.OPTION_PITR_BACKUP_PATH_DESC;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.OPTION_TO_DATETIME;
+import static 
org.apache.hadoop.hbase.backup.BackupRestoreConstants.OPTION_TO_DATETIME_DESC;
+
+import java.net.URI;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl;
+import org.apache.hadoop.hbase.backup.util.BackupUtils;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.hbase.util.CommonFSUtils;
+import org.apache.hadoop.util.ToolRunner;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Command-line entry point for restore operation
+ */
[email protected]
+public class PointInTimeRestoreDriver extends AbstractRestoreDriver {
+  private static final String USAGE_STRING = """
+      Usage: hbase pitr [options]
+        <backup_path>   Backup Path to use for Point in Time Restore
+        table(s)        Comma-separated list of tables to restore
+      """;
+
+  @Override
+  protected int executeRestore(boolean check, TableName[] fromTables, 
TableName[] toTables,
+    boolean isOverwrite) {
+    String walBackupDir = getConf().get(CONF_CONTINUOUS_BACKUP_WAL_DIR);
+    if (walBackupDir == null || walBackupDir.isEmpty()) {
+      System.err.printf(
+        "Point-in-Time Restore requires the WAL backup directory (%s) to 
replay logs after full and incremental backups. "
+          + "Set this property if you need Point-in-Time Restore. Otherwise, 
use the normal restore process with the appropriate backup ID.%n",
+        CONF_CONTINUOUS_BACKUP_WAL_DIR);
+      return -1;
+    }
+
+    String[] remainArgs = cmd.getArgs();
+    if (remainArgs.length != 0) {
+      printToolUsage();
+      return -1;
+    }
+
+    String backupRootDir =
+      cmd.hasOption(OPTION_PITR_BACKUP_PATH) ? 
cmd.getOptionValue(OPTION_PITR_BACKUP_PATH) : null;

Review Comment:
   But I will modify it. user will know that backupRootDir could be null since 
we are using cmd.getOptionValue(), which could return null;



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to