Skip to content

Commit 01f1c9e

Browse files
author
Ray Mattingly
committed
Partition BackupSystemTable queries
1 parent 8ff8748 commit 01f1c9e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupSystemTable.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.apache.hadoop.hbase.client.Put;
6363
import org.apache.hadoop.hbase.client.Result;
6464
import org.apache.hadoop.hbase.client.ResultScanner;
65+
import org.apache.hadoop.hbase.client.Row;
6566
import org.apache.hadoop.hbase.client.Scan;
6667
import org.apache.hadoop.hbase.client.SnapshotDescription;
6768
import org.apache.hadoop.hbase.client.Table;
@@ -76,6 +77,7 @@
7677

7778
import org.apache.hbase.thirdparty.com.google.common.base.Splitter;
7879
import org.apache.hbase.thirdparty.com.google.common.collect.Iterators;
80+
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
7981

8082
import org.apache.hadoop.hbase.shaded.protobuf.generated.BackupProtos;
8183
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
@@ -101,6 +103,7 @@
101103
public final class BackupSystemTable implements Closeable {
102104

103105
private static final Logger LOG = LoggerFactory.getLogger(BackupSystemTable.class);
106+
private static final int BATCH_SIZE = 1000;
104107

105108
static class WALItem {
106109
String backupId;
@@ -414,7 +417,7 @@ public void writePathsPostBulkLoad(TableName tabName, byte[] region,
414417
}
415418
try (Table table = connection.getTable(bulkLoadTableName)) {
416419
List<Put> puts = BackupSystemTable.createPutForCommittedBulkload(tabName, region, finalPaths);
417-
table.put(puts);
420+
executePartitionedBatches(table, puts);
418421
LOG.debug("written " + puts.size() + " rows for bulk load of " + tabName);
419422
}
420423
}
@@ -453,7 +456,7 @@ public void deleteBulkLoadedRows(List<byte[]> rows) throws IOException {
453456
lstDels.add(del);
454457
LOG.debug("orig deleting the row: " + Bytes.toString(row));
455458
}
456-
table.delete(lstDels);
459+
executePartitionedBatches(table, lstDels);
457460
LOG.debug("deleted " + rows.size() + " original bulkload rows");
458461
}
459462
}
@@ -558,7 +561,7 @@ public void writeBulkLoadedFiles(List<TableName> sTableList, Map<byte[], List<Pa
558561
}
559562
}
560563
if (!puts.isEmpty()) {
561-
table.put(puts);
564+
executePartitionedBatches(table, puts);
562565
}
563566
}
564567
}
@@ -918,7 +921,7 @@ public void writeRegionServerLogTimestamp(Set<TableName> tables, Map<String, Lon
918921
puts.add(put);
919922
}
920923
try (Table table = connection.getTable(tableName)) {
921-
table.put(puts);
924+
executePartitionedBatches(table, puts);
922925
}
923926
}
924927

@@ -1902,4 +1905,19 @@ private static void ensureTableEnabled(Admin admin, TableName tableName) throws
19021905
}
19031906
}
19041907
}
1908+
1909+
/**
1910+
* Executes the given operations in partitioned batches of size {@link #BATCH_SIZE}
1911+
*/
1912+
private static void executePartitionedBatches(Table table, List<? extends Row> operations)
1913+
throws IOException {
1914+
List<? extends List<? extends Row>> operationBatches = Lists.partition(operations, BATCH_SIZE);
1915+
for (List<? extends Row> batch : operationBatches) {
1916+
try {
1917+
table.batch(batch, new Object[batch.size()]);
1918+
} catch (InterruptedException e) {
1919+
throw new RuntimeException(e);
1920+
}
1921+
}
1922+
}
19051923
}

0 commit comments

Comments
 (0)