本文整理汇总了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();
}
}
}
示例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();
}
}
示例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);
}