@Override public boolean apply(BackupInfo info) { if (tableName == null) { return true; } List<TableName> names = info.getTableNames(); return names.contains(tableName); } };
public List<TableName> getTablesForBackupType(BackupType type) throws IOException { Set<TableName> names = new HashSet<>(); List<BackupInfo> infos = getBackupHistory(true); for (BackupInfo info : infos) { if (info.getType() == type) { names.addAll(info.getTableNames()); } } return new ArrayList<>(names); }
/** * Get history for a table * @param name table name * @return history for a table * @throws IOException if getting the backup history fails */ public List<BackupInfo> getBackupHistoryForTable(TableName name) throws IOException { List<BackupInfo> history = getBackupHistory(); List<BackupInfo> tableHistory = new ArrayList<>(); for (BackupInfo info : history) { List<TableName> tables = info.getTableNames(); if (tables.contains(name)) { tableHistory.add(info); } } return tableHistory; }
protected TableName[] getTableNamesInBackupImages(String[] backupIds) throws IOException { Set<TableName> allSet = new HashSet<>(); try (Connection conn = ConnectionFactory.createConnection(conf); BackupSystemTable table = new BackupSystemTable(conn)) { for (String backupId : backupIds) { BackupInfo bInfo = table.readBackupInfo(backupId); allSet.addAll(bInfo.getTableNames()); } } TableName[] ret = new TableName[allSet.size()]; return allSet.toArray(ret); }
private boolean isLastBackupSession(BackupSystemTable table, TableName tn, long startTime) throws IOException { List<BackupInfo> history = table.getBackupHistory(); for (BackupInfo info : history) { List<TableName> tables = info.getTableNames(); if (!tables.contains(tn)) { continue; } return info.getStartTs() <= startTime; } return false; }
public Map<TableName, ArrayList<BackupInfo>> getBackupHistoryForTableSet(Set<TableName> set, String backupRoot) throws IOException { List<BackupInfo> history = getBackupHistory(backupRoot); Map<TableName, ArrayList<BackupInfo>> tableHistoryMap = new HashMap<>(); for (Iterator<BackupInfo> iterator = history.iterator(); iterator.hasNext();) { BackupInfo info = iterator.next(); if (!backupRoot.equals(info.getBackupRootDir())) { continue; } List<TableName> tables = info.getTableNames(); for (TableName tableName : tables) { if (set.contains(tableName)) { ArrayList<BackupInfo> list = tableHistoryMap.get(tableName); if (list == null) { list = new ArrayList<>(); tableHistoryMap.put(tableName, list); } list.add(info); } } } return tableHistoryMap; }
private List<BackupInfo> getAffectedBackupSessions(BackupInfo backupInfo, TableName tn, BackupSystemTable table) throws IOException { LOG.debug("GetAffectedBackupInfos for: " + backupInfo.getBackupId() + " table=" + tn); long ts = backupInfo.getStartTs(); List<BackupInfo> list = new ArrayList<>(); List<BackupInfo> history = table.getBackupHistory(backupInfo.getBackupRootDir()); // Scan from most recent to backupInfo // break when backupInfo reached for (BackupInfo info : history) { if (info.getStartTs() == ts) { break; } List<TableName> tables = info.getTableNames(); if (tables.contains(tn)) { BackupType bt = info.getType(); if (bt == BackupType.FULL) { // Clear list if we encounter FULL backup list.clear(); } else { LOG.debug("GetAffectedBackupInfos for: " + backupInfo.getBackupId() + " table=" + tn + " added " + info.getBackupId() + " tables=" + info.getTableListAsString()); list.add(info); } } } return list; }
private void removeTableFromBackupImage(BackupInfo info, TableName tn, BackupSystemTable sysTable) throws IOException { List<TableName> tables = info.getTableNames(); LOG.debug("Remove " + tn + " from " + info.getBackupId() + " tables=" + info.getTableListAsString()); if (tables.contains(tn)) { tables.remove(tn); if (tables.isEmpty()) { LOG.debug("Delete backup info " + info.getBackupId()); sysTable.deleteBackupInfo(info.getBackupId()); // Idempotent operation BackupUtils.cleanupBackupData(info, conn.getConfiguration()); } else { info.setTables(tables); sysTable.updateBackupInfo(info); // Now, clean up directory for table (idempotent) cleanupBackupDir(info, tn, conn.getConfiguration()); } } }
allTables.addAll(bInfo.getTableNames()); long time = bInfo.getStartTs(); if (time < minTime) { List<TableName> tables = info.getTableNames(); return !Collections.disjoint(allTables, tables); };
List<TableName> tables = backupInfo.getTableNames(); long startTime = backupInfo.getStartTs(); for (TableName tn : tables) {
allTablesMap.put(rootDir, allTables); allTables.addAll(info.getTableNames()); totalDeleted += deleteBackup(backupIds[i], sysTable);
.withRootDir(backup.getBackupRootDir()).withTableList(backup.getTableNames()) .withStartTime(backup.getStartTs()).withCompleteTime(backup.getCompleteTs()).build();
/** * Construct manifest for a ongoing backup. * @param backup The ongoing backup info */ public BackupManifest(BackupInfo backup) { BackupImage.Builder builder = BackupImage.newBuilder(); this.backupImage = builder.withBackupId(backup.getBackupId()).withType(backup.getType()) .withRootDir(backup.getBackupRootDir()).withTableList(backup.getTableNames()) .withStartTime(backup.getStartTs()).withCompleteTime(backup.getCompleteTs()).build(); }
backupManager.writeBackupStartCode(newStartCode); handleBulkLoad(backupInfo.getTableNames());
List<TableName> names = image.getTableNames(); return names.contains(table1); }; boolean success = true; for (BackupInfo info : history) { if (!info.getTableNames().contains(table1)) { success = false; break; success = true; for (BackupInfo info : history) { if (!info.getTableNames().contains(table1)) { success = false; break;
if (backupId.equals(backupIdInc5)) { assertTrue(info.getTables().size() == 1); assertEquals(table3, info.getTableNames().get(0)); found = true;
backupManager.writeBackupStartCode(newStartCode); handleBulkLoad(backupInfo.getTableNames()); failStageIf(Stage.stage_4);