Java Code Examples for org.apache.flink.runtime.fs.hdfs.HadoopFileSystem

The following examples show how to use org.apache.flink.runtime.fs.hdfs.HadoopFileSystem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Flink-CEPplus   Source File: YarnFileStageTestS3ITCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that nested directories are properly copied with to the given S3 path (using the
 * appropriate file system) during resource uploads for YARN.
 *
 * @param scheme
 * 		file system scheme
 * @param pathSuffix
 * 		test path suffix which will be the test's target path
 */
private void testRecursiveUploadForYarn(String scheme, String pathSuffix) throws Exception {
	++numRecursiveUploadTests;

	final Path basePath = new Path(S3TestCredentials.getTestBucketUriWithScheme(scheme) + TEST_DATA_DIR);
	final HadoopFileSystem fs = (HadoopFileSystem) basePath.getFileSystem();

	assumeFalse(fs.exists(basePath));

	try {
		final Path directory = new Path(basePath, pathSuffix);

		YarnFileStageTest.testCopyFromLocalRecursive(fs.getHadoopFileSystem(),
			new org.apache.hadoop.fs.Path(directory.toUri()), tempFolder, true);
	} finally {
		// clean up
		fs.delete(basePath, true);
	}
}
 
Example 2
Source Project: flink   Source File: YarnFileStageTestS3ITCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that nested directories are properly copied with to the given S3 path (using the
 * appropriate file system) during resource uploads for YARN.
 *
 * @param scheme
 * 		file system scheme
 * @param pathSuffix
 * 		test path suffix which will be the test's target path
 */
private void testRecursiveUploadForYarn(String scheme, String pathSuffix) throws Exception {
	++numRecursiveUploadTests;

	final Path basePath = new Path(S3TestCredentials.getTestBucketUriWithScheme(scheme) + TEST_DATA_DIR);
	final HadoopFileSystem fs = (HadoopFileSystem) basePath.getFileSystem();

	assumeFalse(fs.exists(basePath));

	try {
		final Path directory = new Path(basePath, pathSuffix);

		YarnFileStageTest.testCopyFromLocalRecursive(fs.getHadoopFileSystem(),
			new org.apache.hadoop.fs.Path(directory.toUri()), tempFolder, true);
	} finally {
		// clean up
		fs.delete(basePath, true);
	}
}
 
Example 3
Source Project: flink   Source File: YarnFileStageTestS3ITCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that nested directories are properly copied with to the given S3 path (using the
 * appropriate file system) during resource uploads for YARN.
 *
 * @param scheme
 * 		file system scheme
 * @param pathSuffix
 * 		test path suffix which will be the test's target path
 */
private void testRecursiveUploadForYarn(String scheme, String pathSuffix) throws Exception {
	++numRecursiveUploadTests;

	final Path basePath = new Path(S3TestCredentials.getTestBucketUriWithScheme(scheme) + TEST_DATA_DIR);
	final HadoopFileSystem fs = (HadoopFileSystem) basePath.getFileSystem();

	assumeFalse(fs.exists(basePath));

	try {
		final Path directory = new Path(basePath, pathSuffix);

		YarnFileStageTest.testRegisterMultipleLocalResources(fs.getHadoopFileSystem(),
			new org.apache.hadoop.fs.Path(directory.toUri()), Path.CUR_DIR, tempFolder, false, false);
	} finally {
		// clean up
		fs.delete(basePath, true);
	}
}
 
Example 4
private String pathToObjectName(final Path path) {
	org.apache.hadoop.fs.Path hadoopPath = HadoopFileSystem.toHadoopPath(path);
	if (!hadoopPath.isAbsolute()) {
		hadoopPath = new org.apache.hadoop.fs.Path(fs.getWorkingDirectory(), hadoopPath);
	}

	return hadoopPath.toUri().getScheme() != null && hadoopPath.toUri().getPath().isEmpty()
			? ""
			: hadoopPath.toUri().getPath().substring(1);
}
 
Example 5
Source Project: flink   Source File: S3RecoverableMultipartUploadFactory.java    License: Apache License 2.0 5 votes vote down vote up
private String pathToObjectName(final Path path) {
	org.apache.hadoop.fs.Path hadoopPath = HadoopFileSystem.toHadoopPath(path);
	if (!hadoopPath.isAbsolute()) {
		hadoopPath = new org.apache.hadoop.fs.Path(fs.getWorkingDirectory(), hadoopPath);
	}

	return hadoopPath.toUri().getScheme() != null && hadoopPath.toUri().getPath().isEmpty()
			? ""
			: hadoopPath.toUri().getPath().substring(1);
}
 
Example 6
Source Project: flink   Source File: S3RecoverableMultipartUploadFactory.java    License: Apache License 2.0 5 votes vote down vote up
private String pathToObjectName(final Path path) {
	org.apache.hadoop.fs.Path hadoopPath = HadoopFileSystem.toHadoopPath(path);
	if (!hadoopPath.isAbsolute()) {
		hadoopPath = new org.apache.hadoop.fs.Path(fs.getWorkingDirectory(), hadoopPath);
	}

	return hadoopPath.toUri().getScheme() != null && hadoopPath.toUri().getPath().isEmpty()
			? ""
			: hadoopPath.toUri().getPath().substring(1);
}
 
Example 7
Source Project: flink   Source File: AbstractAzureFSFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileSystem create(URI fsUri) throws IOException {
	checkNotNull(fsUri, "passed file system URI object should not be null");
	LOG.info("Trying to load and instantiate Azure File System");
	return new HadoopFileSystem(createInitializedAzureFS(fsUri, flinkConfig));
}
 
Example 8
Source Project: flink   Source File: HadoopFileSystemFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileSystem create(URI uri) throws IOException {
	return new HadoopFileSystem(new Path(uri).getFileSystem(jobConfWrapper.conf()));
}
 
Example 9
Source Project: flink   Source File: HiveOutputFormatFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HiveOutputFormat createOutputFormat(Path path) {
	return new HiveOutputFormat(
			factory.createRecordWriter(HadoopFileSystem.toHadoopPath(path)),
			factory.createRowConverter());
}
 
Example 10
Source Project: flink   Source File: AbstractAzureFSFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileSystem create(URI fsUri) throws IOException {
	checkNotNull(fsUri, "passed file system URI object should not be null");
	LOG.info("Trying to load and instantiate Azure File System");
	return new HadoopFileSystem(createInitializedAzureFS(fsUri, flinkConfig));
}