Source:
public boolean sync(JournalContext context, ExecutorService service) throws IOException { AtomicBoolean updated = new AtomicBoolean(false); DatabaseInfo newDbInfo = mUdb.getDatabaseInfo(); if (!newDbInfo.equals(mDatabaseInfo)) { applyAndJournal(context, Journal.JournalEntry.newBuilder() .setUpdateDatabaseInfo(toJournalProto(newDbInfo, mName)).build()); updated.set(true); } Set<String> udbTableNames = new HashSet<>(mUdb.getTableNames()); List<Callable<Void>> tasks = new ArrayList<>(udbTableNames.size()); final Database thisDb = this; for (String tableName : udbTableNames) { tasks.add(() -> { Table previousTable = mTables.get(tableName); UdbTable udbTable = mUdb.getTable(tableName); Table newTable = Table.create(thisDb, udbTable, previousTable); if (newTable != null) { alluxio.proto.journal.Table.AddTableEntry addTableEntry = newTable.toJournalProto(); Journal.JournalEntry entry = Journal.JournalEntry.newBuilder().setAddTable(addTableEntry).build(); applyAndJournal(context, entry); updated.set(true); } return null; }); } try { CommonUtils.invokeAll(tasks, 10 * Constants.MINUTE_MS); } catch (Exception e) { throw new IOException("Failed to sync database " + mName, e); } for (Table existingTable : mTables.values()) { if (!udbTableNames.contains(existingTable.getName())) { alluxio.proto.journal.Table.RemoveTableEntry removeTableEntry = alluxio.proto.journal.Table.RemoveTableEntry.newBuilder() .setDbName(mName) .setTableName(existingTable.getName()) .setVersion(existingTable.getVersion()) .build(); Journal.JournalEntry entry = Journal.JournalEntry.newBuilder() .setRemoveTable(removeTableEntry) .build(); applyAndJournal(context, entry); updated.set(true); } } return updated.get(); }

Target:
public boolean sync(JournalContext context, ExecutorService service) throws IOException { AtomicBoolean updated = new AtomicBoolean(false); DatabaseInfo newDbInfo = mUdb.getDatabaseInfo(); if (!newDbInfo.equals(mDatabaseInfo)) { applyAndJournal(context, Journal.JournalEntry.newBuilder() .setUpdateDatabaseInfo(toJournalProto(newDbInfo, mName)).build()); updated.set(true); } Set<String> udbTableNames = new HashSet<>(mUdb.getTableNames()); List<Callable<Void>> tasks = new ArrayList<>(udbTableNames.size()); final Database thisDb = this; for (String tableName : udbTableNames) { tasks.add(() -> { Table previousTable = mTables.get(tableName); UdbTable udbTable = mUdb.getTable(tableName); Table newTable = Table.create(thisDb, udbTable, previousTable); if (newTable != null) { alluxio.proto.journal.Table.AddTableEntry addTableEntry = newTable.toJournalProto(); Journal.JournalEntry entry = Journal.JournalEntry.newBuilder().setAddTable(addTableEntry).build(); applyAndJournal(context, entry); updated.set(true); } return null; }); } try { CommonUtils.invokeAll(service, tasks, 10 * Constants.MINUTE_MS); } catch (Exception e) { throw new IOException("Failed to sync database " + mName, e); } for (Table existingTable : mTables.values()) { if (!udbTableNames.contains(existingTable.getName())) { alluxio.proto.journal.Table.RemoveTableEntry removeTableEntry = alluxio.proto.journal.Table.RemoveTableEntry.newBuilder() .setDbName(mName) .setTableName(existingTable.getName()) .setVersion(existingTable.getVersion()) .build(); Journal.JournalEntry entry = Journal.JournalEntry.newBuilder() .setRemoveTable(removeTableEntry) .build(); applyAndJournal(context, entry); updated.set(true); } } return updated.get(); }