use of org.apache.accumulo.tserver.TabletStatsKeeper.Operation in project accumulo by apache.
the class Tablet method importMapFiles.
public void importMapFiles(long tid, Map<TabletFile, MapFileInfo> fileMap, boolean setTime) throws IOException {
Map<TabletFile, DataFileValue> entries = new HashMap<>(fileMap.size());
List<String> files = new ArrayList<>();
for (Entry<TabletFile, MapFileInfo> entry : fileMap.entrySet()) {
entries.put(entry.getKey(), new DataFileValue(entry.getValue().estimatedSize, 0L));
files.add(entry.getKey().getPathStr());
}
// 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 unneeded 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 for " + extent);
}
List<TabletFile> alreadyImported = bulkImported.get(tid);
if (alreadyImported != null) {
for (TabletFile entry : alreadyImported) {
if (fileMap.remove(entry) != null) {
log.trace("Ignoring import of bulk file already imported: {}", entry);
}
}
}
fileMap.keySet().removeIf(file -> {
if (bulkImporting.contains(file)) {
log.info("Ignoring import of bulk file currently importing: " + file);
return true;
}
return false;
});
if (fileMap.isEmpty()) {
return;
}
incrementWritesInProgress();
// prevent other threads from processing this file while its added to the metadata table.
bulkImporting.addAll(fileMap.keySet());
}
try {
tabletServer.updateBulkImportState(files, BulkImportState.LOADING);
var storedTabletFile = getDatafileManager().importMapFiles(tid, entries, setTime);
lastMapFileImportTime = System.currentTimeMillis();
if (needsSplit()) {
getTabletServer().executeSplit(this);
} else {
compactable.filesAdded(false, storedTabletFile);
}
} finally {
synchronized (this) {
decrementWritesInProgress();
if (!bulkImporting.removeAll(fileMap.keySet())) {
throw new AssertionError("Likely bug in code, always expect to remove something. Please open an Accumulo issue.");
}
try {
bulkImported.computeIfAbsent(tid, k -> new ArrayList<>()).addAll(fileMap.keySet());
} catch (Exception ex) {
log.info(ex.toString(), ex);
}
tabletServer.removeBulkImportState(files);
}
}
}
Aggregations