Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
import org.apache.hadoop.hbase.backup.BackupType;
import org.apache.hadoop.hbase.backup.util.BackupUtils;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.BufferedMutator;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
Expand Down Expand Up @@ -414,7 +416,7 @@ public void writePathsPostBulkLoad(TableName tabName, byte[] region,
}
try (Table table = connection.getTable(bulkLoadTableName)) {
List<Put> puts = BackupSystemTable.createPutForCommittedBulkload(tabName, region, finalPaths);
table.put(puts);
executeBufferedMutations(table, puts);
LOG.debug("written " + puts.size() + " rows for bulk load of " + tabName);
}
}
Expand Down Expand Up @@ -453,7 +455,7 @@ public void deleteBulkLoadedRows(List<byte[]> rows) throws IOException {
lstDels.add(del);
LOG.debug("orig deleting the row: " + Bytes.toString(row));
}
table.delete(lstDels);
executeBufferedMutations(table, lstDels);
LOG.debug("deleted " + rows.size() + " original bulkload rows");
}
}
Expand Down Expand Up @@ -558,7 +560,7 @@ public void writeBulkLoadedFiles(List<TableName> sTableList, Map<byte[], List<Pa
}
}
if (!puts.isEmpty()) {
table.put(puts);
executeBufferedMutations(table, puts);
}
}
}
Expand Down Expand Up @@ -918,7 +920,7 @@ public void writeRegionServerLogTimestamp(Set<TableName> tables, Map<String, Lon
puts.add(put);
}
try (Table table = connection.getTable(tableName)) {
table.put(puts);
executeBufferedMutations(table, puts);
}
}

Expand Down Expand Up @@ -1885,6 +1887,13 @@ private String cellKeyToBackupSetName(Cell current) {
return Bytes.toString(data).substring(SET_KEY_PREFIX.length());
}

private void executeBufferedMutations(Table table, List<? extends Mutation> mutations)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper function is now kinda weird. I think that you can replace all the above try (Table table = ...) { ... } with try (BufferedMutator bm = ...) { ... }. On quick glance, you never use the table instance other than to get the name in order to create the BufferedMutator instance.

throws IOException {
try (BufferedMutator bufferedMutator = connection.getBufferedMutator(table.getName())) {
bufferedMutator.mutate(mutations);
}
}

private static byte[] rowkey(String s, String... other) {
StringBuilder sb = new StringBuilder(s);
for (String ss : other) {
Expand Down