Search in sources :

Example 1 with Bulk

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;
}
Also used : Text(org.apache.hadoop.io.Text) PeekingIterator(org.apache.accumulo.core.util.PeekingIterator) Bulk(org.apache.accumulo.core.clientImpl.bulk.Bulk) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TabletMetadata(org.apache.accumulo.core.metadata.schema.TabletMetadata) Files(org.apache.accumulo.core.clientImpl.bulk.Bulk.Files) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Bulk (org.apache.accumulo.core.clientImpl.bulk.Bulk)1 Files (org.apache.accumulo.core.clientImpl.bulk.Bulk.Files)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)1 TabletMetadata (org.apache.accumulo.core.metadata.schema.TabletMetadata)1 PeekingIterator (org.apache.accumulo.core.util.PeekingIterator)1 Text (org.apache.hadoop.io.Text)1