Search in sources :

Example 1 with LoadMappingIterator

use of org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator in project accumulo by apache.

the class PrepBulkImport method checkForMerge.

private void checkForMerge(final long tid, final Manager manager) throws Exception {
    VolumeManager fs = manager.getVolumeManager();
    final Path bulkDir = new Path(bulkInfo.sourceDir);
    int maxTablets = Integer.parseInt(manager.getContext().getTableConfiguration(bulkInfo.tableId).get(Property.TABLE_BULK_MAX_TABLETS));
    try (LoadMappingIterator lmi = BulkSerialize.readLoadMapping(bulkDir.toString(), bulkInfo.tableId, fs::open)) {
        TabletIterFactory tabletIterFactory = startRow -> TabletsMetadata.builder(manager.getContext()).forTable(bulkInfo.tableId).overlapping(startRow, null).checkConsistency().fetch(PREV_ROW).build().stream().map(TabletMetadata::getExtent).iterator();
        sanityCheckLoadMapping(bulkInfo.tableId.canonical(), lmi, tabletIterFactory, maxTablets, tid);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) TableId(org.apache.accumulo.core.data.TableId) TabletsMetadata(org.apache.accumulo.core.metadata.schema.TabletsMetadata) LoggerFactory(org.slf4j.LoggerFactory) Text(org.apache.hadoop.io.Text) HashMap(java.util.HashMap) BulkImport(org.apache.accumulo.core.clientImpl.bulk.BulkImport) FileStatus(org.apache.hadoop.fs.FileStatus) Function(java.util.function.Function) TabletMetadata(org.apache.accumulo.core.metadata.schema.TabletMetadata) Repo(org.apache.accumulo.fate.Repo) Manager(org.apache.accumulo.manager.Manager) Map(java.util.Map) UniqueNameAllocator(org.apache.accumulo.server.tablets.UniqueNameAllocator) Path(org.apache.hadoop.fs.Path) TableOperationExceptionType(org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType) PREV_ROW(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator) Property(org.apache.accumulo.core.conf.Property) AcceptableThriftTableOperationException(org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ServerContext(org.apache.accumulo.server.ServerContext) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) IOException(java.io.IOException) TransactionWatcher(org.apache.accumulo.server.zookeeper.TransactionWatcher) Constants(org.apache.accumulo.core.Constants) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) TableOperation(org.apache.accumulo.core.clientImpl.thrift.TableOperation) List(java.util.List) TreeMap(java.util.TreeMap) BulkSerialize(org.apache.accumulo.core.clientImpl.bulk.BulkSerialize) Utils(org.apache.accumulo.manager.tableOps.Utils) UtilWaitThread.sleepUninterruptibly(org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly) VisibleForTesting(com.google.common.annotations.VisibleForTesting) FilenameUtils(org.apache.commons.io.FilenameUtils) ManagerRepo(org.apache.accumulo.manager.tableOps.ManagerRepo) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator)

Example 2 with LoadMappingIterator

use of org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator in project accumulo by apache.

the class PrepBulkImportTest method createLoadMappingIter.

private LoadMappingIterator createLoadMappingIter(Map<KeyExtent, String> loadRanges) throws IOException {
    SortedMap<KeyExtent, Bulk.Files> mapping = new TreeMap<>();
    loadRanges.forEach((extent, files) -> {
        Bulk.Files testFiles = new Bulk.Files();
        long c = 0L;
        for (String f : files.split(" ")) {
            c++;
            testFiles.add(new Bulk.FileInfo(f, c, c));
        }
        mapping.put(extent, testFiles);
    });
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BulkSerialize.writeLoadMapping(mapping, "/some/dir", p -> baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    LoadMappingIterator lmi = BulkSerialize.readLoadMapping("/some/dir", TableId.of("1"), p -> bais);
    return lmi;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TreeMap(java.util.TreeMap) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Bulk(org.apache.accumulo.core.clientImpl.bulk.Bulk)

Example 3 with LoadMappingIterator

use of org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator in project accumulo by apache.

the class LoadFiles method isReady.

@Override
public long isReady(long tid, Manager manager) throws Exception {
    if (manager.onlineTabletServers().isEmpty()) {
        log.warn("There are no tablet server to process bulkDir import, waiting (tid = " + FateTxId.formatTid(tid) + ")");
        return 100;
    }
    VolumeManager fs = manager.getVolumeManager();
    final Path bulkDir = new Path(bulkInfo.bulkDir);
    manager.updateBulkImportStatus(bulkInfo.sourceDir, BulkImportState.LOADING);
    try (LoadMappingIterator lmi = BulkSerialize.getUpdatedLoadMapping(bulkDir.toString(), bulkInfo.tableId, fs::open)) {
        return loadFiles(bulkInfo.tableId, bulkDir, lmi, manager, tid);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) LoadMappingIterator(org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator)

Aggregations

LoadMappingIterator (org.apache.accumulo.core.clientImpl.bulk.LoadMappingIterator)3 TreeMap (java.util.TreeMap)2 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)2 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)2 Path (org.apache.hadoop.fs.Path)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 TimeUnit (java.util.concurrent.TimeUnit)1 Function (java.util.function.Function)1 Constants (org.apache.accumulo.core.Constants)1 AcceptableThriftTableOperationException (org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException)1 Bulk (org.apache.accumulo.core.clientImpl.bulk.Bulk)1 BulkImport (org.apache.accumulo.core.clientImpl.bulk.BulkImport)1