parentPath = curPath;
}
assert parentPath != null;
GridGgfsFileInfo parentInfo = infos.get(parentPath);
// Delegate to the secondary file system.
out = simpleCreate ? fs.create(path, overwrite) :
fs.create(path, bufSize, overwrite, replication, blockSize, props);
GridGgfsPath parent0 = path.parent();
assert parent0 != null : "path.parent() is null (are we creating ROOT?): " + path;
// If some of the parent directories were missing, synchronize again.
if (!parentPath.equals(parent0)) {
parentInfo = synchronize(fs, parentPath, parentInfo, parent0, true, null);
// Fire notification about missing directories creation.
if (evts.isRecordable(EVT_GGFS_DIR_CREATED)) {
GridGgfsPath evtPath = parent0;
while (!parentPath.equals(evtPath)) {
pendingEvts.addFirst(new GridGgfsEvent(evtPath, locNode, EVT_GGFS_DIR_CREATED));
evtPath = evtPath.parent();
assert evtPath != null; // If this fails, then ROOT does not exist.
}
}
}
// Get created file info.
GridGgfsFile status = fs.info(path);
if (status == null)
throw new GridGgfsException("Failed to open output stream to the file created in " +
"the secondary file system because it no longer exists: " + path);
else if (status.isDirectory())
throw new GridGgfsException("Failed to open output stream to the file created in " +
"the secondary file system because the path points to a directory: " + path);
GridGgfsFileInfo newInfo = new GridGgfsFileInfo(status.blockSize(), status.length(), affKey,
GridUuid.randomUuid(), ggfsCtx.ggfs().evictExclude(path, false), status.properties());
// Add new file info to the listing optionally removing the previous one.
GridUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
if (oldId != null) {
GridGgfsFileInfo oldInfo = info(oldId);
id2InfoPrj.removex(oldId); // Remove the old one.
id2InfoPrj.putx(newInfo.id(), newInfo); // Put the new one.
id2InfoPrj.transform(parentInfo.id(),