HBASE-19537 Removed unnecessary semicolons from hbase-backup
This commit is contained in:
parent
dd00081c26
commit
d50ae03716
@ -62,7 +62,7 @@ public class BackupInfo implements Comparable<BackupInfo> {
|
|||||||
* Backup session states
|
* Backup session states
|
||||||
*/
|
*/
|
||||||
public static enum BackupState {
|
public static enum BackupState {
|
||||||
RUNNING, COMPLETE, FAILED, ANY;
|
RUNNING, COMPLETE, FAILED, ANY
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +70,7 @@ public class BackupInfo implements Comparable<BackupInfo> {
|
|||||||
* BackupState.RUNNING
|
* BackupState.RUNNING
|
||||||
*/
|
*/
|
||||||
public static enum BackupPhase {
|
public static enum BackupPhase {
|
||||||
REQUEST, SNAPSHOT, PREPARE_INCREMENTAL, SNAPSHOTCOPY, INCREMENTAL_COPY, STORE_MANIFEST;
|
REQUEST, SNAPSHOT, PREPARE_INCREMENTAL, SNAPSHOTCOPY, INCREMENTAL_COPY, STORE_MANIFEST
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ public class RestoreDriver extends AbstractHBaseTool {
|
|||||||
String tableMapping =
|
String tableMapping =
|
||||||
cmd.hasOption(OPTION_TABLE_MAPPING) ? cmd.getOptionValue(OPTION_TABLE_MAPPING) : null;
|
cmd.hasOption(OPTION_TABLE_MAPPING) ? cmd.getOptionValue(OPTION_TABLE_MAPPING) : null;
|
||||||
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
||||||
BackupAdmin client = new BackupAdminImpl(conn);) {
|
BackupAdmin client = new BackupAdminImpl(conn)) {
|
||||||
// Check backup set
|
// Check backup set
|
||||||
if (cmd.hasOption(OPTION_SET)) {
|
if (cmd.hasOption(OPTION_SET)) {
|
||||||
String setName = cmd.getOptionValue(OPTION_SET);
|
String setName = cmd.getOptionValue(OPTION_SET);
|
||||||
|
@ -459,7 +459,7 @@ public class BackupAdminImpl implements BackupAdmin {
|
|||||||
public void addToBackupSet(String name, TableName[] tables) throws IOException {
|
public void addToBackupSet(String name, TableName[] tables) throws IOException {
|
||||||
String[] tableNames = new String[tables.length];
|
String[] tableNames = new String[tables.length];
|
||||||
try (final BackupSystemTable table = new BackupSystemTable(conn);
|
try (final BackupSystemTable table = new BackupSystemTable(conn);
|
||||||
final Admin admin = conn.getAdmin();) {
|
final Admin admin = conn.getAdmin()) {
|
||||||
for (int i = 0; i < tables.length; i++) {
|
for (int i = 0; i < tables.length; i++) {
|
||||||
tableNames[i] = tables[i].getNameAsString();
|
tableNames[i] = tables[i].getNameAsString();
|
||||||
if (!admin.tableExists(TableName.valueOf(tableNames[i]))) {
|
if (!admin.tableExists(TableName.valueOf(tableNames[i]))) {
|
||||||
@ -561,7 +561,7 @@ public class BackupAdminImpl implements BackupAdmin {
|
|||||||
outputFs.mkdirs(targetTableBackupDirPath);
|
outputFs.mkdirs(targetTableBackupDirPath);
|
||||||
}
|
}
|
||||||
ArrayList<TableName> nonExistingTableList = null;
|
ArrayList<TableName> nonExistingTableList = null;
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
for (TableName tableName : tableList) {
|
for (TableName tableName : tableList) {
|
||||||
if (!admin.tableExists(tableName)) {
|
if (!admin.tableExists(tableName)) {
|
||||||
if (nonExistingTableList == null) {
|
if (nonExistingTableList == null) {
|
||||||
@ -615,7 +615,7 @@ public class BackupAdminImpl implements BackupAdmin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mergeBackups(String[] backupIds) throws IOException {
|
public void mergeBackups(String[] backupIds) throws IOException {
|
||||||
try (final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
checkIfValidForMerge(backupIds, sysTable);
|
checkIfValidForMerge(backupIds, sysTable);
|
||||||
BackupMergeJob job = BackupRestoreFactory.getBackupMergeJob(conn.getConfiguration());
|
BackupMergeJob job = BackupRestoreFactory.getBackupMergeJob(conn.getConfiguration());
|
||||||
job.run(backupIds);
|
job.run(backupIds);
|
||||||
|
@ -144,7 +144,7 @@ public final class BackupCommands {
|
|||||||
conn = ConnectionFactory.createConnection(getConf());
|
conn = ConnectionFactory.createConnection(getConf());
|
||||||
if (requiresNoActiveSession()) {
|
if (requiresNoActiveSession()) {
|
||||||
// Check active session
|
// Check active session
|
||||||
try (BackupSystemTable table = new BackupSystemTable(conn);) {
|
try (BackupSystemTable table = new BackupSystemTable(conn)) {
|
||||||
List<BackupInfo> sessions = table.getBackupInfos(BackupState.RUNNING);
|
List<BackupInfo> sessions = table.getBackupInfos(BackupState.RUNNING);
|
||||||
|
|
||||||
if (sessions.size() > 0) {
|
if (sessions.size() > 0) {
|
||||||
@ -158,7 +158,7 @@ public final class BackupCommands {
|
|||||||
}
|
}
|
||||||
if (requiresConsistentState()) {
|
if (requiresConsistentState()) {
|
||||||
// Check failed delete
|
// Check failed delete
|
||||||
try (BackupSystemTable table = new BackupSystemTable(conn);) {
|
try (BackupSystemTable table = new BackupSystemTable(conn)) {
|
||||||
String[] ids = table.getListOfBackupIdsFromDeleteOperation();
|
String[] ids = table.getListOfBackupIdsFromDeleteOperation();
|
||||||
|
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
@ -332,8 +332,7 @@ public final class BackupCommands {
|
|||||||
System.setProperty("mapreduce.job.queuename", queueName);
|
System.setProperty("mapreduce.job.queuename", queueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
|
|
||||||
BackupRequest.Builder builder = new BackupRequest.Builder();
|
BackupRequest.Builder builder = new BackupRequest.Builder();
|
||||||
BackupRequest request =
|
BackupRequest request =
|
||||||
builder
|
builder
|
||||||
@ -471,7 +470,7 @@ public final class BackupCommands {
|
|||||||
super.execute();
|
super.execute();
|
||||||
|
|
||||||
String backupId = args[1];
|
String backupId = args[1];
|
||||||
try (final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
BackupInfo info = sysTable.readBackupInfo(backupId);
|
BackupInfo info = sysTable.readBackupInfo(backupId);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
System.out.println("ERROR: " + backupId + " does not exist");
|
System.out.println("ERROR: " + backupId + " does not exist");
|
||||||
@ -512,7 +511,7 @@ public final class BackupCommands {
|
|||||||
super.execute();
|
super.execute();
|
||||||
|
|
||||||
String backupId = (args == null || args.length <= 1) ? null : args[1];
|
String backupId = (args == null || args.length <= 1) ? null : args[1];
|
||||||
try (final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
BackupInfo info = null;
|
BackupInfo info = null;
|
||||||
|
|
||||||
if (backupId != null) {
|
if (backupId != null) {
|
||||||
@ -569,7 +568,7 @@ public final class BackupCommands {
|
|||||||
String[] args = cmdline.getArgs();
|
String[] args = cmdline.getArgs();
|
||||||
String[] backupIds = new String[args.length - 1];
|
String[] backupIds = new String[args.length - 1];
|
||||||
System.arraycopy(args, 1, backupIds, 0, backupIds.length);
|
System.arraycopy(args, 1, backupIds, 0, backupIds.length);
|
||||||
try (BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
int deleted = admin.deleteBackups(backupIds);
|
int deleted = admin.deleteBackups(backupIds);
|
||||||
System.out.println("Deleted " + deleted + " backups. Total requested: " + (args.length -1));
|
System.out.println("Deleted " + deleted + " backups. Total requested: " + (args.length -1));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -606,8 +605,7 @@ public final class BackupCommands {
|
|||||||
|
|
||||||
Configuration conf = getConf() != null ? getConf() : HBaseConfiguration.create();
|
Configuration conf = getConf() != null ? getConf() : HBaseConfiguration.create();
|
||||||
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
||||||
final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
|
|
||||||
// Failed backup
|
// Failed backup
|
||||||
BackupInfo backupInfo;
|
BackupInfo backupInfo;
|
||||||
List<BackupInfo> list = sysTable.getBackupInfos(BackupState.RUNNING);
|
List<BackupInfo> list = sysTable.getBackupInfos(BackupState.RUNNING);
|
||||||
@ -658,7 +656,7 @@ public final class BackupCommands {
|
|||||||
BackupSystemTable.restoreFromSnapshot(conn);
|
BackupSystemTable.restoreFromSnapshot(conn);
|
||||||
// Finish previous failed session
|
// Finish previous failed session
|
||||||
sysTable.finishBackupExclusiveOperation();
|
sysTable.finishBackupExclusiveOperation();
|
||||||
try (BackupAdmin admin = new BackupAdminImpl(conn);) {
|
try (BackupAdmin admin = new BackupAdminImpl(conn)) {
|
||||||
admin.deleteBackups(backupIds);
|
admin.deleteBackups(backupIds);
|
||||||
}
|
}
|
||||||
System.out.println("DELETE operation finished OK: " + StringUtils.join(backupIds));
|
System.out.println("DELETE operation finished OK: " + StringUtils.join(backupIds));
|
||||||
@ -682,7 +680,7 @@ public final class BackupCommands {
|
|||||||
sysTable.finishBackupExclusiveOperation();
|
sysTable.finishBackupExclusiveOperation();
|
||||||
// Finish previous failed session
|
// Finish previous failed session
|
||||||
sysTable.finishMergeOperation();
|
sysTable.finishMergeOperation();
|
||||||
try (BackupAdmin admin = new BackupAdminImpl(conn);) {
|
try (BackupAdmin admin = new BackupAdminImpl(conn)) {
|
||||||
admin.mergeBackups(backupIds);
|
admin.mergeBackups(backupIds);
|
||||||
}
|
}
|
||||||
System.out.println("MERGE operation finished OK: " + StringUtils.join(backupIds));
|
System.out.println("MERGE operation finished OK: " + StringUtils.join(backupIds));
|
||||||
@ -734,7 +732,7 @@ public final class BackupCommands {
|
|||||||
}
|
}
|
||||||
Configuration conf = getConf() != null ? getConf() : HBaseConfiguration.create();
|
Configuration conf = getConf() != null ? getConf() : HBaseConfiguration.create();
|
||||||
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
try (final Connection conn = ConnectionFactory.createConnection(conf);
|
||||||
final BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
final BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
admin.mergeBackups(backupIds);
|
admin.mergeBackups(backupIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -781,7 +779,7 @@ public final class BackupCommands {
|
|||||||
if (backupRootPath == null) {
|
if (backupRootPath == null) {
|
||||||
// Load from backup system table
|
// Load from backup system table
|
||||||
super.execute();
|
super.execute();
|
||||||
try (final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
history = sysTable.getBackupHistory(n, tableNameFilter, tableSetFilter);
|
history = sysTable.getBackupHistory(n, tableNameFilter, tableSetFilter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -905,7 +903,7 @@ public final class BackupCommands {
|
|||||||
|
|
||||||
// List all backup set names
|
// List all backup set names
|
||||||
// does not expect any args
|
// does not expect any args
|
||||||
try (BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
List<BackupSet> list = admin.listBackupSets();
|
List<BackupSet> list = admin.listBackupSets();
|
||||||
for (BackupSet bs : list) {
|
for (BackupSet bs : list) {
|
||||||
System.out.println(bs);
|
System.out.println(bs);
|
||||||
@ -921,7 +919,7 @@ public final class BackupCommands {
|
|||||||
super.execute();
|
super.execute();
|
||||||
|
|
||||||
String setName = args[2];
|
String setName = args[2];
|
||||||
try (final BackupSystemTable sysTable = new BackupSystemTable(conn);) {
|
try (final BackupSystemTable sysTable = new BackupSystemTable(conn)) {
|
||||||
List<TableName> tables = sysTable.describeBackupSet(setName);
|
List<TableName> tables = sysTable.describeBackupSet(setName);
|
||||||
BackupSet set = tables == null ? null : new BackupSet(setName, tables);
|
BackupSet set = tables == null ? null : new BackupSet(setName, tables);
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
@ -940,7 +938,7 @@ public final class BackupCommands {
|
|||||||
super.execute();
|
super.execute();
|
||||||
|
|
||||||
String setName = args[2];
|
String setName = args[2];
|
||||||
try (final BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (final BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
boolean result = admin.deleteBackupSet(setName);
|
boolean result = admin.deleteBackupSet(setName);
|
||||||
if (result) {
|
if (result) {
|
||||||
System.out.println("Delete set " + setName + " OK.");
|
System.out.println("Delete set " + setName + " OK.");
|
||||||
@ -960,7 +958,7 @@ public final class BackupCommands {
|
|||||||
String setName = args[2];
|
String setName = args[2];
|
||||||
String[] tables = args[3].split(",");
|
String[] tables = args[3].split(",");
|
||||||
TableName[] tableNames = toTableNames(tables);
|
TableName[] tableNames = toTableNames(tables);
|
||||||
try (final BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (final BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
admin.removeFromBackupSet(setName, tableNames);
|
admin.removeFromBackupSet(setName, tableNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -986,7 +984,7 @@ public final class BackupCommands {
|
|||||||
for (int i = 0; i < tables.length; i++) {
|
for (int i = 0; i < tables.length; i++) {
|
||||||
tableNames[i] = TableName.valueOf(tables[i]);
|
tableNames[i] = TableName.valueOf(tables[i]);
|
||||||
}
|
}
|
||||||
try (final BackupAdminImpl admin = new BackupAdminImpl(conn);) {
|
try (final BackupAdminImpl admin = new BackupAdminImpl(conn)) {
|
||||||
admin.addToBackupSet(setName, tableNames);
|
admin.addToBackupSet(setName, tableNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ public class BackupManifest {
|
|||||||
new Path(HBackupFileSystem.getBackupPath(backupImage.getRootDir(),
|
new Path(HBackupFileSystem.getBackupPath(backupImage.getRootDir(),
|
||||||
backupImage.getBackupId()), MANIFEST_FILE_NAME);
|
backupImage.getBackupId()), MANIFEST_FILE_NAME);
|
||||||
try (FSDataOutputStream out =
|
try (FSDataOutputStream out =
|
||||||
manifestFilePath.getFileSystem(conf).create(manifestFilePath, true);) {
|
manifestFilePath.getFileSystem(conf).create(manifestFilePath, true)) {
|
||||||
out.write(data);
|
out.write(data);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new BackupException(e.getMessage());
|
throw new BackupException(e.getMessage());
|
||||||
|
@ -176,8 +176,7 @@ public final class BackupSystemTable implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkSystemTable() throws IOException {
|
private void checkSystemTable() throws IOException {
|
||||||
try (Admin admin = connection.getAdmin();) {
|
try (Admin admin = connection.getAdmin()) {
|
||||||
|
|
||||||
verifyNamespaceExists(admin);
|
verifyNamespaceExists(admin);
|
||||||
|
|
||||||
if (!admin.tableExists(tableName)) {
|
if (!admin.tableExists(tableName)) {
|
||||||
@ -317,7 +316,7 @@ public final class BackupSystemTable implements Closeable {
|
|||||||
LOG.debug("found bulk loaded file : " + tbl + " " + Bytes.toString(fam) + " " + path);
|
LOG.debug("found bulk loaded file : " + tbl + " " + Bytes.toString(fam) + " " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return mapForSrc;
|
return mapForSrc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1546,7 +1545,7 @@ public final class BackupSystemTable implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void snapshot(Connection conn) throws IOException {
|
public static void snapshot(Connection conn) throws IOException {
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
Configuration conf = conn.getConfiguration();
|
Configuration conf = conn.getConfiguration();
|
||||||
admin.snapshot(BackupSystemTable.getSnapshotName(conf), BackupSystemTable.getTableName(conf));
|
admin.snapshot(BackupSystemTable.getSnapshotName(conf), BackupSystemTable.getTableName(conf));
|
||||||
}
|
}
|
||||||
@ -1555,7 +1554,7 @@ public final class BackupSystemTable implements Closeable {
|
|||||||
public static void restoreFromSnapshot(Connection conn) throws IOException {
|
public static void restoreFromSnapshot(Connection conn) throws IOException {
|
||||||
Configuration conf = conn.getConfiguration();
|
Configuration conf = conn.getConfiguration();
|
||||||
LOG.debug("Restoring " + BackupSystemTable.getTableNameAsString(conf) + " from snapshot");
|
LOG.debug("Restoring " + BackupSystemTable.getTableNameAsString(conf) + " from snapshot");
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
String snapshotName = BackupSystemTable.getSnapshotName(conf);
|
String snapshotName = BackupSystemTable.getSnapshotName(conf);
|
||||||
if (snapshotExists(admin, snapshotName)) {
|
if (snapshotExists(admin, snapshotName)) {
|
||||||
admin.disableTable(BackupSystemTable.getTableName(conf));
|
admin.disableTable(BackupSystemTable.getTableName(conf));
|
||||||
@ -1589,7 +1588,7 @@ public final class BackupSystemTable implements Closeable {
|
|||||||
public static void deleteSnapshot(Connection conn) throws IOException {
|
public static void deleteSnapshot(Connection conn) throws IOException {
|
||||||
Configuration conf = conn.getConfiguration();
|
Configuration conf = conn.getConfiguration();
|
||||||
LOG.debug("Deleting " + BackupSystemTable.getSnapshotName(conf) + " from the system");
|
LOG.debug("Deleting " + BackupSystemTable.getSnapshotName(conf) + " from the system");
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
String snapshotName = BackupSystemTable.getSnapshotName(conf);
|
String snapshotName = BackupSystemTable.getSnapshotName(conf);
|
||||||
if (snapshotExists(admin, snapshotName)) {
|
if (snapshotExists(admin, snapshotName)) {
|
||||||
admin.deleteSnapshot(snapshotName);
|
admin.deleteSnapshot(snapshotName);
|
||||||
|
@ -121,8 +121,7 @@ public class FullTableBackupClient extends TableBackupClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws IOException {
|
public void execute() throws IOException {
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
|
|
||||||
// Begin BACKUP
|
// Begin BACKUP
|
||||||
beginBackup(backupManager, backupInfo);
|
beginBackup(backupManager, backupInfo);
|
||||||
String savedStartCode = null;
|
String savedStartCode = null;
|
||||||
|
@ -92,11 +92,9 @@ public class IncrementalBackupManager extends BackupManager {
|
|||||||
HashMap<String, String> props = new HashMap<String, String>();
|
HashMap<String, String> props = new HashMap<String, String>();
|
||||||
props.put("backupRoot", backupInfo.getBackupRootDir());
|
props.put("backupRoot", backupInfo.getBackupRootDir());
|
||||||
|
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
|
|
||||||
admin.execProcedure(LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_SIGNATURE,
|
admin.execProcedure(LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_SIGNATURE,
|
||||||
LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_NAME, props);
|
LogRollMasterProcedureManager.ROLLLOG_PROCEDURE_NAME, props);
|
||||||
|
|
||||||
}
|
}
|
||||||
newTimestamps = readRegionServerLastLogRollResult();
|
newTimestamps = readRegionServerLastLogRollResult();
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ public class IncrementalTableBackupClient extends TableBackupClient {
|
|||||||
|
|
||||||
|
|
||||||
protected boolean tableExists(TableName table, Connection conn) throws IOException {
|
protected boolean tableExists(TableName table, Connection conn) throws IOException {
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
return admin.tableExists(table);
|
return admin.tableExists(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class RestoreTablesClient {
|
|||||||
ArrayList<TableName> disabledTableList = new ArrayList<>();
|
ArrayList<TableName> disabledTableList = new ArrayList<>();
|
||||||
|
|
||||||
// check if the tables already exist
|
// check if the tables already exist
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
for (TableName tableName : tTableArray) {
|
for (TableName tableName : tTableArray) {
|
||||||
if (admin.tableExists(tableName)) {
|
if (admin.tableExists(tableName)) {
|
||||||
existTableList.add(tableName);
|
existTableList.add(tableName);
|
||||||
|
@ -146,7 +146,7 @@ public abstract class TableBackupClient {
|
|||||||
}
|
}
|
||||||
LOG.debug("Trying to delete snapshot: " + snapshotName);
|
LOG.debug("Trying to delete snapshot: " + snapshotName);
|
||||||
|
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
admin.deleteSnapshot(snapshotName);
|
admin.deleteSnapshot(snapshotName);
|
||||||
}
|
}
|
||||||
LOG.debug("Deleting the snapshot " + snapshotName + " for backup " + backupInfo.getBackupId()
|
LOG.debug("Deleting the snapshot " + snapshotName + " for backup " + backupInfo.getBackupId()
|
||||||
|
@ -298,7 +298,7 @@ public class MapReduceBackupCopyJob implements BackupCopyJob {
|
|||||||
long totalBytesExpected = 0;
|
long totalBytesExpected = 0;
|
||||||
int totalRecords = 0;
|
int totalRecords = 0;
|
||||||
Path fileListingPath = getFileListingPath();
|
Path fileListingPath = getFileListingPath();
|
||||||
try (SequenceFile.Writer writer = getWriter(fileListingPath);) {
|
try (SequenceFile.Writer writer = getWriter(fileListingPath)) {
|
||||||
List<Path> srcFiles = getSourceFiles();
|
List<Path> srcFiles = getSourceFiles();
|
||||||
if (srcFiles.size() == 0) {
|
if (srcFiles.size() == 0) {
|
||||||
return fileListingPath;
|
return fileListingPath;
|
||||||
|
@ -223,7 +223,7 @@ public class MapReduceBackupMergeJob implements BackupMergeJob {
|
|||||||
String backupRoot) throws IOException {
|
String backupRoot) throws IOException {
|
||||||
|
|
||||||
// Delete from backup system table
|
// Delete from backup system table
|
||||||
try (BackupSystemTable table = new BackupSystemTable(conn);) {
|
try (BackupSystemTable table = new BackupSystemTable(conn)) {
|
||||||
for (String backupId : backupIds) {
|
for (String backupId : backupIds) {
|
||||||
table.deleteBackupInfo(backupId);
|
table.deleteBackupInfo(backupId);
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ public class MapReduceBackupMergeJob implements BackupMergeJob {
|
|||||||
Set<TableName> allSet = new HashSet<TableName>();
|
Set<TableName> allSet = new HashSet<TableName>();
|
||||||
|
|
||||||
try (Connection conn = ConnectionFactory.createConnection(conf);
|
try (Connection conn = ConnectionFactory.createConnection(conf);
|
||||||
BackupSystemTable table = new BackupSystemTable(conn);) {
|
BackupSystemTable table = new BackupSystemTable(conn)) {
|
||||||
for (String backupId : backupIds) {
|
for (String backupId : backupIds) {
|
||||||
BackupInfo bInfo = table.readBackupInfo(backupId);
|
BackupInfo bInfo = table.readBackupInfo(backupId);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class RestoreTool {
|
|||||||
|
|
||||||
void modifyTableSync(Connection conn, TableDescriptor desc) throws IOException {
|
void modifyTableSync(Connection conn, TableDescriptor desc) throws IOException {
|
||||||
|
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
admin.modifyTable(desc);
|
admin.modifyTable(desc);
|
||||||
int attempt = 0;
|
int attempt = 0;
|
||||||
int maxAttempts = 600;
|
int maxAttempts = 600;
|
||||||
@ -156,7 +156,7 @@ public class RestoreTool {
|
|||||||
public void incrementalRestoreTable(Connection conn, Path tableBackupPath, Path[] logDirs,
|
public void incrementalRestoreTable(Connection conn, Path tableBackupPath, Path[] logDirs,
|
||||||
TableName[] tableNames, TableName[] newTableNames, String incrBackupId) throws IOException {
|
TableName[] tableNames, TableName[] newTableNames, String incrBackupId) throws IOException {
|
||||||
|
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
if (tableNames.length != newTableNames.length) {
|
if (tableNames.length != newTableNames.length) {
|
||||||
throw new IOException("Number of source tables and target tables does not match!");
|
throw new IOException("Number of source tables and target tables does not match!");
|
||||||
}
|
}
|
||||||
@ -474,7 +474,7 @@ public class RestoreTool {
|
|||||||
private void checkAndCreateTable(Connection conn, Path tableBackupPath, TableName tableName,
|
private void checkAndCreateTable(Connection conn, Path tableBackupPath, TableName tableName,
|
||||||
TableName targetTableName, ArrayList<Path> regionDirList, TableDescriptor htd,
|
TableName targetTableName, ArrayList<Path> regionDirList, TableDescriptor htd,
|
||||||
boolean truncateIfExists) throws IOException {
|
boolean truncateIfExists) throws IOException {
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
boolean createNew = false;
|
boolean createNew = false;
|
||||||
if (admin.tableExists(targetTableName)) {
|
if (admin.tableExists(targetTableName)) {
|
||||||
if (truncateIfExists) {
|
if (truncateIfExists) {
|
||||||
|
@ -194,7 +194,7 @@ public class TestBackupBase {
|
|||||||
public void execute() throws IOException
|
public void execute() throws IOException
|
||||||
{
|
{
|
||||||
// Get the stage ID to fail on
|
// Get the stage ID to fail on
|
||||||
try (Admin admin = conn.getAdmin();) {
|
try (Admin admin = conn.getAdmin()) {
|
||||||
// Begin BACKUP
|
// Begin BACKUP
|
||||||
beginBackup(backupManager, backupInfo);
|
beginBackup(backupManager, backupInfo);
|
||||||
failStageIf(Stage.stage_0);
|
failStageIf(Stage.stage_0);
|
||||||
|
@ -51,7 +51,7 @@ public class TestBackupDeleteRestore extends TestBackupBase {
|
|||||||
int numRows = TEST_UTIL.countRows(table1);
|
int numRows = TEST_UTIL.countRows(table1);
|
||||||
HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
|
||||||
// delete row
|
// delete row
|
||||||
try (Table table = TEST_UTIL.getConnection().getTable(table1);) {
|
try (Table table = TEST_UTIL.getConnection().getTable(table1)) {
|
||||||
Delete delete = new Delete("row0".getBytes());
|
Delete delete = new Delete("row0".getBytes());
|
||||||
table.delete(delete);
|
table.delete(delete);
|
||||||
hba.flush(table1);
|
hba.flush(table1);
|
||||||
|
@ -267,8 +267,7 @@ public class TestIncrementalBackupMergeWithFailures extends TestBackupBase {
|
|||||||
|
|
||||||
conf.set(FAILURE_PHASE_KEY, phase.toString());
|
conf.set(FAILURE_PHASE_KEY, phase.toString());
|
||||||
|
|
||||||
try (BackupAdmin bAdmin = new BackupAdminImpl(conn);)
|
try (BackupAdmin bAdmin = new BackupAdminImpl(conn)) {
|
||||||
{
|
|
||||||
String[] backups = new String[] { backupIdIncMultiple, backupIdIncMultiple2 };
|
String[] backups = new String[] { backupIdIncMultiple, backupIdIncMultiple2 };
|
||||||
bAdmin.mergeBackups(backups);
|
bAdmin.mergeBackups(backups);
|
||||||
Assert.fail("Expected IOException");
|
Assert.fail("Expected IOException");
|
||||||
@ -306,7 +305,7 @@ public class TestIncrementalBackupMergeWithFailures extends TestBackupBase {
|
|||||||
conf.unset(FAILURE_PHASE_KEY);
|
conf.unset(FAILURE_PHASE_KEY);
|
||||||
conf.unset(BackupRestoreFactory.HBASE_BACKUP_MERGE_IMPL_CLASS);
|
conf.unset(BackupRestoreFactory.HBASE_BACKUP_MERGE_IMPL_CLASS);
|
||||||
|
|
||||||
try (BackupAdmin bAdmin = new BackupAdminImpl(conn);) {
|
try (BackupAdmin bAdmin = new BackupAdminImpl(conn)) {
|
||||||
String[] backups = new String[] { backupIdIncMultiple, backupIdIncMultiple2 };
|
String[] backups = new String[] { backupIdIncMultiple, backupIdIncMultiple2 };
|
||||||
bAdmin.mergeBackups(backups);
|
bAdmin.mergeBackups(backups);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user