List of usage examples for org.apache.hadoop.fs FSDataOutputStream hsync
@Override public void hsync() throws IOException
From source file:org.kitesdk.data.spi.filesystem.AvroAppender.java
License:Apache License
@Override public void sync() throws IOException { flush(); Hadoop.FSDataOutputStream.hsync.invoke(out); }
From source file:org.kitesdk.data.spi.filesystem.CSVAppender.java
License:Apache License
@Override public void sync() throws IOException { flush(); Hadoop.FSDataOutputStream.hsync.invoke(outgoing); }
From source file:org.mule.modules.hdfs.HDFSConnector.java
License:Open Source License
/** * Write the current payload to the designated path, either creating a new file or appending to an existing one. * * @param path/*w w w .ja v a2 s . co m*/ * the path of the file to write to. * @param permission * the file system permission to use if a new file is created, either in octal or symbolic format (umask). * @param overwrite * if a pre-existing file should be overwritten with the new content. * @param bufferSize * the buffer size to use when appending to the file. * @param replication * block replication for the file. * @param blockSize * the buffer size to use when appending to the file. * @param ownerUserName * the username owner of the file. * @param ownerGroupName * the group owner of the file. * @param payload * the payload to write to the file. * @throws HDFSConnectorException * if any issue occurs during the execution. */ @Processor(friendlyName = "Write to path") public void write(final String path, // NOSONAR @Default("700") final String permission, @Default("true") final boolean overwrite, @Default("4096") final int bufferSize, @Default("1") final int replication, @Default("1048576") final long blockSize, @Optional final String ownerUserName, @Optional final String ownerGroupName, @Default("#[payload]") final InputStream payload) throws HDFSConnectorException { try { runHdfsPathAction(path, new VoidHdfsPathAction() { public void run(final Path hdfsPath) throws Exception { // NOSONAR final FSDataOutputStream fsDataOutputStream = fileSystem.create(hdfsPath, getFileSystemPermission(permission), overwrite, bufferSize, (short) replication, blockSize, null); IOUtils.copyLarge(payload, fsDataOutputStream); fsDataOutputStream.hsync(); IOUtils.closeQuietly(fsDataOutputStream); if ((isNotBlank(ownerUserName)) || (isNotBlank(ownerGroupName))) { fileSystem.setOwner(hdfsPath, ownerUserName, ownerGroupName); } } }); } catch (Exception e) { throw new HDFSConnectorException(e); } }