if (!mTFS.delete(path, false)) {
throw new IOException("Failed to delete existing data " + cPath);
}
}
int fileId = mTFS.createFile(path, blockSize);
TachyonFile file = mTFS.getFile(fileId);
file.setUFSConf(getConf());
return new FSDataOutputStream(file.getOutStream(UserConf.get().DEFAULT_WRITE_TYPE), null);
}
if (cPath.toString().contains(FIRST_COM_PATH) && !cPath.toString().contains("SUCCESS")) {
TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath));
mTFS.createFile(path, blockSize);
String depPath = path.getPath();
depPath = depPath.substring(depPath.indexOf(FIRST_COM_PATH) + FIRST_COM_PATH.length());
depPath = depPath.substring(0, depPath.indexOf(TachyonURI.SEPARATOR));
int depId = Integer.parseInt(depPath);
LOG.info("create(" + cPath + ") : " + depPath + " " + depId);
depPath = path.getPath();
depPath = depPath.substring(depPath.indexOf("part-") + 5);
int index = Integer.parseInt(depPath);
ClientDependencyInfo info = mTFS.getClientDependencyInfo(depId);
int fileId = info.getChildren().get(index);
LOG.info("create(" + cPath + ") : " + depPath + " " + index + " " + info + " " + fileId);
TachyonFile file = mTFS.getFile(fileId);
file.setUFSConf(getConf());
// if (file.getBlockSizeByte() != blockSize) {
// throw new IOException("File already exist with a different blocksize "
// file.getBlockSizeByte() + " != " + blockSize);
// }
return new FSDataOutputStream(file.getOutStream(WriteType.ASYNC_THROUGH), null);
}
if (cPath.toString().contains(RECOMPUTE_PATH) && !cPath.toString().contains("SUCCESS")) {
TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath));
mTFS.createFile(path, blockSize);
String depPath = path.getPath();
depPath = depPath.substring(depPath.indexOf(RECOMPUTE_PATH) + RECOMPUTE_PATH.length());
depPath = depPath.substring(0, depPath.indexOf(TachyonURI.SEPARATOR));
int depId = Integer.parseInt(depPath);
LOG.info("create(" + cPath + ") : " + depPath + " " + depId);
depPath = path.getPath();
depPath = depPath.substring(depPath.indexOf("part-") + 5);
int index = Integer.parseInt(depPath);
ClientDependencyInfo info = mTFS.getClientDependencyInfo(depId);
int fileId = info.getChildren().get(index);
LOG.info("create(" + cPath + ") : " + depPath + " " + index + " " + info + " " + fileId);
TachyonFile file = mTFS.getFile(fileId);
file.setUFSConf(getConf());
// if (file.getBlockSizeByte() != blockSize) {
// throw new IOException("File already exist with a different blocksize "
// file.getBlockSizeByte() + " != " + blockSize);
// }
return new FSDataOutputStream(file.getOutStream(WriteType.ASYNC_THROUGH), null);
} else {
TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath));
int fileId;
WriteType type = UserConf.get().DEFAULT_WRITE_TYPE;
if (mTFS.exist(path)) {
fileId = mTFS.getFileId(path);
type = WriteType.MUST_CACHE;
} else {
fileId = mTFS.createFile(path, blockSize);
}
TachyonFile file = mTFS.getFile(fileId);
file.setUFSConf(getConf());
// if (file.getBlockSizeByte() != blockSize) {
// throw new IOException("File already exist with a different blocksize "
// file.getBlockSizeByte() + " != " + blockSize);
// }
return new FSDataOutputStream(file.getOutStream(type), null);
}
}