storable = _storableConverter.encodeInlined(key0, creationTime,
stdMetadata, customMetadata, data);
} else {
// otherwise, need to create file and all that fun...
final long fileCreationTime = _timeMaster.currentTimeMillis();
FileReference fileRef = _fileManager.createStorageFile(key0,
stdMetadata.compression, fileCreationTime);
try {
final long nanoStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
_throttler.performFileWrite(source, fileCreationTime, key0, fileRef.getFile(),
new FileOperationCallback<Void>() {
@Override
public Void perform(long operationTime, StorableKey key, Storable value, File externalFile)
throws IOException, StoreException {
final long fsStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
IOUtil.writeFile(externalFile, data);
if (diag != null) {
diag.addFileWriteAccess(nanoStart, fsStart, _timeMaster, data.byteLength());
}
return null;
}
});
} catch (IOException e) {
// better remove the file, if one exists...
fileRef.getFile().delete();
throw new StoreException.IO(key0,
"Failed to write storage file of "+data.byteLength()+" bytes: "+e.getMessage(), e);
}
// but modtime better be taken only now, as above may have taken some time (I/O bound)
creationTime = _timeMaster.currentTimeMillis();