当前位置: 首页>>代码示例>>Java>>正文


Java FileSystem.getFileStatus方法代码示例

本文整理汇总了Java中org.apache.flink.core.fs.FileSystem.getFileStatus方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.getFileStatus方法的具体用法?Java FileSystem.getFileStatus怎么用?Java FileSystem.getFileStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.fs.FileSystem的用法示例。


在下文中一共展示了FileSystem.getFileStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFiles

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
protected List<FileStatus> getFiles() throws IOException {
	// get all the files that are involved in the splits
	List<FileStatus> files = new ArrayList<FileStatus>();

	final FileSystem fs = this.filePath.getFileSystem();
	final FileStatus pathFile = fs.getFileStatus(this.filePath);

	if (pathFile.isDir()) {
		// input is directory. list all contained files
		final FileStatus[] partials = fs.listStatus(this.filePath);
		for (FileStatus partial : partials) {
			if (!partial.isDir()) {
				files.add(partial);
			}
		}
	} else {
		files.add(pathFile);
	}

	return files;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:BinaryInputFormat.java

示例2: getFileStats

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
protected FileBaseStatistics getFileStats(FileBaseStatistics cachedStats, Path filePath, FileSystem fs,
		ArrayList<FileStatus> files) throws IOException {
	
	// get the file info and check whether the cached statistics are still valid.
	final FileStatus file = fs.getFileStatus(filePath);
	long totalLength = 0;

	// enumerate all files
	if (file.isDir()) {
		totalLength += addFilesInDir(file.getPath(), files, false);
	} else {
		files.add(file);
		testForUnsplittable(file);
		totalLength += file.getLen();
	}

	// check the modification time stamp
	long latestModTime = 0;
	for (FileStatus f : files) {
		latestModTime = Math.max(f.getModificationTime(), latestModTime);
	}

	// check whether the cached statistics are still valid, if we have any
	if (cachedStats != null && latestModTime <= cachedStats.getLastModificationTime()) {
		return cachedStats;
	}

	// sanity check
	if (totalLength <= 0) {
		totalLength = BaseStatistics.SIZE_UNKNOWN;
	}
	return new FileBaseStatistics(latestModTime, totalLength, BaseStatistics.AVG_RECORD_BYTES_UNKNOWN);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:34,代码来源:FileInputFormat.java

示例3: loadSavepointWithHandle

import org.apache.flink.core.fs.FileSystem; //导入方法依赖的package包/类
/**
 * Loads the savepoint at the specified path. This methods returns the savepoint, as well as the
 * handle to the metadata.
 *
 * @param savepointFileOrDirectory Path to the parent savepoint directory or the meta data file.
 * @param classLoader The class loader used to resolve serialized classes from legacy savepoint formats.
 * @return The loaded savepoint
 *
 * @throws IOException Failures during load are forwarded
 */
public static Tuple2<Savepoint, StreamStateHandle> loadSavepointWithHandle(
		String savepointFileOrDirectory,
		ClassLoader classLoader) throws IOException {
	
	checkNotNull(savepointFileOrDirectory, "savepointFileOrDirectory");
	checkNotNull(classLoader, "classLoader");

	Path path = new Path(savepointFileOrDirectory);

	LOG.info("Loading savepoint from {}", path);

	FileSystem fs = FileSystem.get(path.toUri());

	FileStatus status = fs.getFileStatus(path);

	// If this is a directory, we need to find the meta data file
	if (status.isDir()) {
		Path candidatePath = new Path(path, SAVEPOINT_METADATA_FILE);
		if (fs.exists(candidatePath)) {
			path = candidatePath;
			LOG.info("Using savepoint file in {}", path);
		} else {
			throw new IOException("Cannot find meta data file in directory " + path
					+ ". Please try to load the savepoint directly from the meta data file "
					+ "instead of the directory.");
		}
	}

	// load the savepoint
	final Savepoint savepoint;
	try (DataInputStream dis = new DataInputViewStreamWrapper(fs.open(path))) {
		int magicNumber = dis.readInt();

		if (magicNumber == MAGIC_NUMBER) {
			int version = dis.readInt();

			SavepointSerializer<?> serializer = SavepointSerializers.getSerializer(version);
			savepoint = serializer.deserialize(dis, classLoader);
		} else {
			throw new RuntimeException("Unexpected magic number. This can have multiple reasons: " +
					"(1) You are trying to load a Flink 1.0 savepoint, which is not supported by this " +
					"version of Flink. (2) The file you were pointing to is not a savepoint at all. " +
					"(3) The savepoint file has been corrupted.");
		}
	}

	// construct the stream handle to the metadata file
	// we get the size best-effort
	long size = 0;
	try {
		size = fs.getFileStatus(path).getLen();
	}
	catch (Exception ignored) {
		// we don't know the size, but we don't want to fail the savepoint loading for that
	}
	StreamStateHandle metadataHandle = new FileStateHandle(path, size);

	return new Tuple2<>(savepoint, metadataHandle);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:70,代码来源:SavepointStore.java


注:本文中的org.apache.flink.core.fs.FileSystem.getFileStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。