use of org.apache.accumulo.core.clientImpl.bulk.Bulk in project accumulo by apache.
the class LoadFiles method loadFiles.
/**
* Make asynchronous load calls to each overlapping Tablet in the bulk mapping. Return a sleep
* time to isReady based on a factor of the TabletServer with the most Tablets. This method will
* scan the metadata table getting Tablet range and location information. It will return 0 when
* all files have been loaded.
*/
private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMapIter, Manager manager, long tid) throws Exception {
PeekingIterator<Map.Entry<KeyExtent, Bulk.Files>> lmi = new PeekingIterator<>(loadMapIter);
Map.Entry<KeyExtent, Bulk.Files> loadMapEntry = lmi.peek();
Text startRow = loadMapEntry.getKey().prevEndRow();
Iterator<TabletMetadata> tabletIter = TabletsMetadata.builder(manager.getContext()).forTable(tableId).overlapping(startRow, null).checkConsistency().fetch(PREV_ROW, LOCATION, LOADED).build().iterator();
Loader loader;
if (bulkInfo.tableState == TableState.ONLINE) {
loader = new OnlineLoader();
} else {
loader = new OfflineLoader();
}
loader.start(bulkDir, manager, tid, bulkInfo.setTime);
long t1 = System.currentTimeMillis();
while (lmi.hasNext()) {
loadMapEntry = lmi.next();
List<TabletMetadata> tablets = findOverlappingTablets(loadMapEntry.getKey(), tabletIter);
loader.load(tablets, loadMapEntry.getValue());
}
long sleepTime = loader.finish();
if (sleepTime > 0) {
long scanTime = Math.min(System.currentTimeMillis() - t1, 30000);
sleepTime = Math.max(sleepTime, scanTime * 2);
}
return sleepTime;
}
Aggregations