You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/03/29 08:22:47 UTC
[GitHub] [hbase] wchevreuil commented on a change in pull request #3100: HBASE-25707 When restoring a table, create a namespace if it does not exist
wchevreuil commented on a change in pull request #3100:
URL: https://github.com/apache/hbase/pull/3100#discussion_r603095951
##########
File path: hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
##########
@@ -487,12 +489,21 @@ private void checkAndCreateTable(Connection conn, Path tableBackupPath, TableNam
if (createNew) {
LOG.info("Creating target table '" + targetTableName + "'");
byte[][] keys;
- if (regionDirList == null || regionDirList.size() == 0) {
- admin.createTable(htd);
- } else {
- keys = generateBoundaryKeys(regionDirList);
- // create table using table descriptor and region boundaries
- admin.createTable(htd, keys);
+ try{
+ if (regionDirList == null || regionDirList.size() == 0) {
+ admin.createTable(htd);
+ } else {
+ keys = generateBoundaryKeys(regionDirList);
+ // create table using table descriptor and region boundaries
+ admin.createTable(htd, keys);
+ }
+ } catch (NamespaceNotFoundException e){
+ LOG.warn(e.getMessage());
Review comment:
nit: Printing the whole exception may confuse operators that something went wrong, maybe worth just log a warn saying there was no namespace and the same will be created?
##########
File path: hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/RestoreTool.java
##########
@@ -487,12 +489,21 @@ private void checkAndCreateTable(Connection conn, Path tableBackupPath, TableNam
if (createNew) {
LOG.info("Creating target table '" + targetTableName + "'");
byte[][] keys;
- if (regionDirList == null || regionDirList.size() == 0) {
- admin.createTable(htd);
- } else {
- keys = generateBoundaryKeys(regionDirList);
- // create table using table descriptor and region boundaries
- admin.createTable(htd, keys);
+ try{
+ if (regionDirList == null || regionDirList.size() == 0) {
+ admin.createTable(htd);
+ } else {
+ keys = generateBoundaryKeys(regionDirList);
+ // create table using table descriptor and region boundaries
+ admin.createTable(htd, keys);
+ }
+ } catch (NamespaceNotFoundException e){
+ LOG.warn(e.getMessage());
+ String namespaceAsString = targetTableName.getNamespaceAsString();
+ LOG.info("Creating target namespace '" + namespaceAsString + "'");
+ admin.createNamespace(NamespaceDescriptor.create(namespaceAsString).build());
+ checkAndCreateTable(conn, tableBackupPath, tableName, targetTableName, regionDirList, htd,
Review comment:
Why we call this `checkAndCreateTable` here, instead of doing same call we currently do in line 494 or 498?
--
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