Search in sources :

Example 1 with WriteMode

use of org.apache.flink.core.fs.FileSystem.WriteMode in project flink by apache.

the class FileOutputFormat method initializeGlobal.

/**
	 * Initialization of the distributed file system if it is used.
	 *
	 * @param parallelism The task parallelism.
	 */
@Override
public void initializeGlobal(int parallelism) throws IOException {
    final Path path = getOutputFilePath();
    final FileSystem fs = path.getFileSystem();
    // only distributed file systems can be initialized at start-up time.
    if (fs.isDistributedFS()) {
        final WriteMode writeMode = getWriteMode();
        final OutputDirectoryMode outDirMode = getOutputDirectoryMode();
        if (parallelism == 1 && outDirMode == OutputDirectoryMode.PARONLY) {
            // prepare distributed output path
            if (!fs.initOutPathDistFS(path, writeMode, false)) {
                // output preparation failed! Cancel task.
                throw new IOException("Output path could not be initialized.");
            }
        } else {
            // only distributed file systems can be initialized at start-up time.
            if (!fs.initOutPathDistFS(path, writeMode, true)) {
                throw new IOException("Output directory could not be created.");
            }
        }
    }
}
Also used : Path(org.apache.flink.core.fs.Path) FileSystem(org.apache.flink.core.fs.FileSystem) IOException(java.io.IOException) WriteMode(org.apache.flink.core.fs.FileSystem.WriteMode)

Aggregations

IOException (java.io.IOException)1 FileSystem (org.apache.flink.core.fs.FileSystem)1 WriteMode (org.apache.flink.core.fs.FileSystem.WriteMode)1 Path (org.apache.flink.core.fs.Path)1