/** * Convenience method for {@link #create(TachyonURI, CreateOptions)} with default options. */ public TachyonFile create(TachyonURI path) throws IOException, TachyonException, FileAlreadyExistsException, InvalidPathException { return create(path, CreateOptions.defaults()); }
public static void createFiles() throws TachyonException, IOException { final long startTimeMs = CommonUtils.getCurrentMs(); for (int k = 0; k < sFiles; k ++) { TachyonFile file = sTFS.create(new TachyonURI(sFileName + (k + sBaseFileNumber))); long fileId = file.getFileId(); LOG.info( FormatUtils.formatTimeTakenMs(startTimeMs, "user_createFiles with fileId " + fileId)); } }
private long createFile(TachyonFileSystem tachyonFileSystem) throws IOException, TachyonException { LOG.debug("Creating file..."); long startTimeMs = CommonUtils.getCurrentMs(); CreateOptions createOptions = (new CreateOptions.Builder(ClientContext.getConf())) .setBlockSizeBytes(mWriteOptions.getBlockSizeBytes()).setRecursive(true) .setTTL(mWriteOptions.getTTL()) .setUnderStorageType(mWriteOptions.getUnderStorageType()).build(); TachyonFile tFile = tachyonFileSystem.create(mFilePath, createOptions); long fileId = tFile.getFileId(); LOG.info(FormatUtils.formatTimeTakenMs(startTimeMs, "createFile with fileId " + fileId)); return fileId; }
/** * Creates a file and gets the {@link FileOutStream} for the specified file. If the parent * directories do not exist, they will be created. This should only be called to write a file that * does not exist. Once close is called on the output stream, the file will be completed. Append * or update of a completed file is currently not supported. * * @param path the Tachyon path of the file * @param options the set of options specific to this operation * @return an output stream to write the file * @throws IOException if a non-Tachyon exception occurs * @throws TachyonException if an unexpected Tachyon exception is thrown * @throws FileAlreadyExistsException if there is already a file at the given path * @throws InvalidPathException if the path is invalid */ public FileOutStream getOutStream(TachyonURI path, OutStreamOptions options) throws IOException, TachyonException, FileAlreadyExistsException, InvalidPathException { CreateOptions createOptions = new CreateOptions.Builder(ClientContext.getConf()) .setBlockSizeBytes(options.getBlockSizeBytes()) .setRecursive(true) .setTTL(options.getTTL()) .setUnderStorageType(options.getUnderStorageType()) .build(); TachyonFile tFile = create(path, createOptions); long fileId = tFile.getFileId(); return new FileOutStream(fileId, options); }