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);
}
}
}
Aggregations