Search in sources :

Example 1 with MapFileInfo

use of org.apache.accumulo.core.data.thrift.MapFileInfo in project accumulo by apache.

the class Tablet method importMapFiles.

public void importMapFiles(long tid, Map<FileRef, MapFileInfo> fileMap, boolean setTime) throws IOException {
    Map<FileRef, DataFileValue> entries = new HashMap<>(fileMap.size());
    List<String> files = new ArrayList<>();
    for (Entry<FileRef, MapFileInfo> entry : fileMap.entrySet()) {
        entries.put(entry.getKey(), new DataFileValue(entry.getValue().estimatedSize, 0l));
        files.add(entry.getKey().path().toString());
    }
    // Clients timeout and will think that this operation failed.
    // Don't do it if we spent too long waiting for the lock
    long now = System.currentTimeMillis();
    synchronized (this) {
        if (isClosed()) {
            throw new IOException("tablet " + extent + " is closed");
        }
        // TODO check seems uneeded now - ACCUMULO-1291
        long lockWait = System.currentTimeMillis() - now;
        if (lockWait > getTabletServer().getConfiguration().getTimeInMillis(Property.GENERAL_RPC_TIMEOUT)) {
            throw new IOException("Timeout waiting " + (lockWait / 1000.) + " seconds to get tablet lock");
        }
        List<FileRef> alreadyImported = bulkImported.getIfPresent(tid);
        if (alreadyImported != null) {
            for (FileRef entry : alreadyImported) {
                if (fileMap.remove(entry) != null) {
                    log.info("Ignoring import of bulk file already imported: " + entry);
                }
            }
        }
        if (fileMap.isEmpty()) {
            return;
        }
        if (writesInProgress < 0) {
            throw new IllegalStateException("writesInProgress < 0 " + writesInProgress);
        }
        writesInProgress++;
    }
    tabletServer.updateBulkImportState(files, BulkImportState.LOADING);
    try {
        getDatafileManager().importMapFiles(tid, entries, setTime);
        lastMapFileImportTime = System.currentTimeMillis();
        if (needsSplit()) {
            getTabletServer().executeSplit(this);
        } else {
            initiateMajorCompaction(MajorCompactionReason.NORMAL);
        }
    } finally {
        synchronized (this) {
            if (writesInProgress < 1)
                throw new IllegalStateException("writesInProgress < 1 " + writesInProgress);
            writesInProgress--;
            if (writesInProgress == 0)
                this.notifyAll();
            try {
                bulkImported.get(tid, new Callable<List<FileRef>>() {

                    @Override
                    public List<FileRef> call() throws Exception {
                        return new ArrayList<>();
                    }
                }).addAll(fileMap.keySet());
            } catch (Exception ex) {
                log.info(ex.toString(), ex);
            }
            tabletServer.removeBulkImportState(files);
        }
    }
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) HashMap(java.util.HashMap) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MapFileInfo(org.apache.accumulo.core.data.thrift.MapFileInfo) IOException(java.io.IOException) Callable(java.util.concurrent.Callable) DecoderException(org.apache.commons.codec.DecoderException) IterationInterruptedException(org.apache.accumulo.core.iterators.IterationInterruptedException) IOException(java.io.IOException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) TConstraintViolationException(org.apache.accumulo.tserver.TConstraintViolationException) FileNotFoundException(java.io.FileNotFoundException) CompactionCanceledException(org.apache.accumulo.tserver.tablet.Compactor.CompactionCanceledException) TooManyFilesException(org.apache.accumulo.tserver.TooManyFilesException) KeeperException(org.apache.zookeeper.KeeperException) FileRef(org.apache.accumulo.server.fs.FileRef)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Callable (java.util.concurrent.Callable)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 MapFileInfo (org.apache.accumulo.core.data.thrift.MapFileInfo)1 IterationInterruptedException (org.apache.accumulo.core.iterators.IterationInterruptedException)1 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)1 FileRef (org.apache.accumulo.server.fs.FileRef)1 TConstraintViolationException (org.apache.accumulo.tserver.TConstraintViolationException)1 TooManyFilesException (org.apache.accumulo.tserver.TooManyFilesException)1 CompactionCanceledException (org.apache.accumulo.tserver.tablet.Compactor.CompactionCanceledException)1 DecoderException (org.apache.commons.codec.DecoderException)1 KeeperException (org.apache.zookeeper.KeeperException)1 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)1