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


Java FSDataOutputStream.close方法代码示例

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


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

示例1: readStateData

import org.apache.flink.core.fs.FSDataOutputStream; //导入方法依赖的package包/类
private void readStateData(
	Path restoreFilePath,
	StreamStateHandle remoteFileHandle) throws IOException {

	FileSystem restoreFileSystem = restoreFilePath.getFileSystem();

	FSDataInputStream inputStream = null;
	FSDataOutputStream outputStream = null;

	try {
		inputStream = remoteFileHandle.openInputStream();
		stateBackend.cancelStreamRegistry.registerCloseable(inputStream);

		outputStream = restoreFileSystem.create(restoreFilePath, FileSystem.WriteMode.OVERWRITE);
		stateBackend.cancelStreamRegistry.registerCloseable(outputStream);

		byte[] buffer = new byte[8 * 1024];
		while (true) {
			int numBytes = inputStream.read(buffer);
			if (numBytes == -1) {
				break;
			}

			outputStream.write(buffer, 0, numBytes);
		}
	} finally {
		if (inputStream != null && stateBackend.cancelStreamRegistry.unregisterCloseable(inputStream)) {
			inputStream.close();
		}

		if (outputStream != null && stateBackend.cancelStreamRegistry.unregisterCloseable(outputStream)) {
			outputStream.close();
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:36,代码来源:RocksDBKeyedStateBackend.java

示例2: close

import org.apache.flink.core.fs.FSDataOutputStream; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
	final FSDataOutputStream s = this.stream;
	if (s != null) {
		this.stream = null;
		s.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:FileOutputFormat.java

示例3: createAndReadFileTest

import org.apache.flink.core.fs.FSDataOutputStream; //导入方法依赖的package包/类
/**
 * Creates and reads a file with the given size in S3. The test file is generated according to a specific pattern.
 * During the read phase the incoming data stream is also checked against this pattern.
 * 
 * @param fileSize
 *        the size of the file to be generated in bytes
 * @throws IOException
 *         thrown if an I/O error occurs while writing or reading the test file
 */
private void createAndReadFileTest(final int fileSize) throws IOException {

	if (!testActivated()) {
		return;
	}

	final String bucketName = getRandomName();
	final String objectName = getRandomName();
	final Path bucketPath = new Path(S3_BASE_URI + bucketName + Path.SEPARATOR);
	final Path objectPath = new Path(S3_BASE_URI + bucketName + Path.SEPARATOR + objectName);

	FileSystem fs = bucketPath.getFileSystem();

	// Create test bucket
	fs.mkdirs(bucketPath);

	// Write test file to S3
	final FSDataOutputStream outputStream = fs.create(objectPath, false);
	generateTestData(outputStream, fileSize);
	outputStream.close();

	// Now read the same file back from S3
	final FSDataInputStream inputStream = fs.open(objectPath);
	testReceivedData(inputStream, fileSize);
	inputStream.close();

	// Delete test bucket
	fs.delete(bucketPath, true);
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:39,代码来源:S3FileSystemTest.java


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