本文整理匯總了Java中org.apache.flink.runtime.io.disk.iomanager.IOManager.createChannel方法的典型用法代碼示例。如果您正苦於以下問題:Java IOManager.createChannel方法的具體用法?Java IOManager.createChannel怎麽用?Java IOManager.createChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.flink.runtime.io.disk.iomanager.IOManager
的用法示例。
在下文中一共展示了IOManager.createChannel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCloseAndDeleteOutputView
import org.apache.flink.runtime.io.disk.iomanager.IOManager; //導入方法依賴的package包/類
@Test
public void testCloseAndDeleteOutputView() {
final IOManager ioManager = new IOManagerAsync();
try {
MemoryManager memMan = new MemoryManager(4 * 16*1024, 1, 16*1024, MemoryType.HEAP, true);
List<MemorySegment> memory = new ArrayList<MemorySegment>();
memMan.allocatePages(new DummyInvokable(), memory, 4);
FileIOChannel.ID channel = ioManager.createChannel();
BlockChannelWriter<MemorySegment> writer = ioManager.createBlockChannelWriter(channel);
FileChannelOutputView out = new FileChannelOutputView(writer, memMan, memory, memMan.getPageSize());
new StringValue("Some test text").write(out);
// close for the first time, make sure all memory returns
out.close();
assertTrue(memMan.verifyEmpty());
// close again, should not cause an exception
out.close();
// delete, make sure file is removed
out.closeAndDelete();
assertFalse(new File(channel.getPath()).exists());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
finally {
ioManager.shutdown();
}
}
示例2: testCloseAndDeleteInputView
import org.apache.flink.runtime.io.disk.iomanager.IOManager; //導入方法依賴的package包/類
@Test
public void testCloseAndDeleteInputView() {
final IOManager ioManager = new IOManagerAsync();
try {
MemoryManager memMan = new MemoryManager(4 * 16*1024, 1, 16*1024, MemoryType.HEAP, true);
List<MemorySegment> memory = new ArrayList<MemorySegment>();
memMan.allocatePages(new DummyInvokable(), memory, 4);
FileIOChannel.ID channel = ioManager.createChannel();
// add some test data
try (FileWriter wrt = new FileWriter(channel.getPath())) {
wrt.write("test data");
}
BlockChannelReader<MemorySegment> reader = ioManager.createBlockChannelReader(channel);
FileChannelInputView in = new FileChannelInputView(reader, memMan, memory, 9);
// read just something
in.readInt();
// close for the first time, make sure all memory returns
in.close();
assertTrue(memMan.verifyEmpty());
// close again, should not cause an exception
in.close();
// delete, make sure file is removed
in.closeAndDelete();
assertFalse(new File(channel.getPath()).exists());
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
finally {
ioManager.shutdown();
}
}