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