org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID Java Examples

The following examples show how to use org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID. 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 File: IOManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes the file underlying the given channel. If the channel is still open, this
 * call may fail.
 *
 * @param channel The channel to be deleted.
 */
public static void deleteChannel(ID channel) {
	if (channel != null) {
		if (channel.getPathFile().exists() && !channel.getPathFile().delete()) {
			LOG.warn("IOManager failed to delete temporary file {}", channel.getPath());
		}
	}
}
 
Example #2
Source File: FileChannelManagerImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ID createChannel() {
	checkState(!isShutdown.get(), "File channel manager has shutdown.");

	int num = getNextPathNum();
	return new ID(paths[num], num, random);
}
 
Example #3
Source File: IOManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes the file underlying the given channel. If the channel is still open, this
 * call may fail.
 *
 * @param channel The channel to be deleted.
 */
public static void deleteChannel(ID channel) {
	if (channel != null) {
		if (channel.getPathFile().exists() && !channel.getPathFile().delete()) {
			LOG.warn("IOManager failed to delete temporary file {}", channel.getPath());
		}
	}
}
 
Example #4
Source File: IOManagerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void channelEnumerator() throws Exception {
	File tempPath = temporaryFolder.newFolder();

	String[] tempDirs = new String[]{
		new File(tempPath, "a").getAbsolutePath(),
		new File(tempPath, "b").getAbsolutePath(),
		new File(tempPath, "c").getAbsolutePath(),
		new File(tempPath, "d").getAbsolutePath(),
		new File(tempPath, "e").getAbsolutePath(),
	};

	int[] counters = new int[tempDirs.length];
	try (IOManager ioMan = new TestIOManager(tempDirs) ) {
		FileIOChannel.Enumerator enumerator = ioMan.createChannelEnumerator();

		for (int i = 0; i < 3 * tempDirs.length; i++) {
			FileIOChannel.ID id = enumerator.next();

			File path = id.getPathFile();

			assertTrue("Channel IDs must name an absolute path.", path.isAbsolute());
			assertFalse("Channel IDs must name a file, not a directory.", path.isDirectory());

			assertTrue("Path is not in the temp directory.",
					tempPath.equals(path.getParentFile().getParentFile().getParentFile()));

			for (int k = 0; k < tempDirs.length; k++) {
				if (path.getParentFile().getParent().equals(tempDirs[k])) {
					counters[k]++;
				}
			}
		}

		for (int k = 0; k < tempDirs.length; k++) {
			assertEquals(3, counters[k]);
		}
	}
}
 
Example #5
Source File: IOManagerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void channelEnumerator() throws Exception {
	File tempPath = temporaryFolder.newFolder();

	String[] tempDirs = new String[]{
		new File(tempPath, "a").getAbsolutePath(),
		new File(tempPath, "b").getAbsolutePath(),
		new File(tempPath, "c").getAbsolutePath(),
		new File(tempPath, "d").getAbsolutePath(),
		new File(tempPath, "e").getAbsolutePath(),
	};

	int[] counters = new int[tempDirs.length];
	try (IOManager ioMan = new TestIOManager(tempDirs) ) {
		FileIOChannel.Enumerator enumerator = ioMan.createChannelEnumerator();

		for (int i = 0; i < 3 * tempDirs.length; i++) {
			FileIOChannel.ID id = enumerator.next();

			File path = id.getPathFile();

			assertTrue("Channel IDs must name an absolute path.", path.isAbsolute());
			assertFalse("Channel IDs must name a file, not a directory.", path.isDirectory());

			assertTrue("Path is not in the temp directory.",
					tempPath.equals(path.getParentFile().getParentFile().getParentFile()));

			for (int k = 0; k < tempDirs.length; k++) {
				if (path.getParentFile().getParent().equals(tempDirs[k])) {
					counters[k]++;
				}
			}
		}

		for (int k = 0; k < tempDirs.length; k++) {
			assertEquals(3, counters[k]);
		}
	}
}
 
Example #6
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileReader createBufferFileReader(ID channelID, RequestDoneCallback<Buffer> callback) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #7
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BulkBlockChannelReader createBulkBlockChannelReader(ID channelID, List<MemorySegment> targetSegments, int numBlocks) {
	throw new UnsupportedOperationException();
}
 
Example #8
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileWriter createBufferFileWriter(ID channelID) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #9
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelReader<MemorySegment> createBlockChannelReader(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example #10
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriter<MemorySegment> createBlockChannelWriter(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example #11
Source File: IOManager.java    From flink with Apache License 2.0 4 votes vote down vote up
public abstract BufferFileSegmentReader createBufferFileSegmentReader(
ID channelID,
RequestDoneCallback<FileSegment> callback) throws IOException;
 
Example #12
Source File: IOManager.java    From flink with Apache License 2.0 4 votes vote down vote up
public abstract BufferFileReader createBufferFileReader(
ID channelID,
RequestDoneCallback<Buffer> callback) throws IOException;
 
Example #13
Source File: IOManagerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileReader createBufferFileReader(ID channelID, RequestDoneCallback<Buffer> callback) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #14
Source File: IOManagerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileWriter createBufferFileWriter(ID channelID) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #15
Source File: FileChannelManagerImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public ID createChannel() {
	int num = getNextPathNum();
	return new ID(paths[num], num, random);
}
 
Example #16
Source File: UnilateralSortMerger.java    From flink with Apache License 2.0 4 votes vote down vote up
public FileIOChannel.ID getChannel() {
	return channel;
}
 
Example #17
Source File: IOManagerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public BulkBlockChannelReader createBulkBlockChannelReader(ID channelID, List<MemorySegment> targetSegments, int numBlocks) {
	throw new UnsupportedOperationException();
}
 
Example #18
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileSegmentReader createBufferFileSegmentReader(ID channelID, RequestDoneCallback<FileSegment> callback) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #19
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriterWithCallback<MemorySegment> createBlockChannelWriter(ID channelID, RequestDoneCallback<MemorySegment> callback) {
	throw new UnsupportedOperationException();
}
 
Example #20
Source File: UnilateralSortMerger.java    From flink with Apache License 2.0 4 votes vote down vote up
public ChannelWithBlockCount(ID channel, int blockCount) {
	this.channel = channel;
	this.blockCount = blockCount;
}
 
Example #21
Source File: UnilateralSortMerger.java    From flink with Apache License 2.0 4 votes vote down vote up
public FileIOChannel.ID getChannel() {
	return channel;
}
 
Example #22
Source File: IOManager.java    From flink with Apache License 2.0 4 votes vote down vote up
public abstract BufferFileReader createBufferFileReader(
ID channelID,
RequestDoneCallback<Buffer> callback) throws IOException;
 
Example #23
Source File: IOManager.java    From flink with Apache License 2.0 4 votes vote down vote up
public abstract BufferFileSegmentReader createBufferFileSegmentReader(
ID channelID,
RequestDoneCallback<FileSegment> callback) throws IOException;
 
Example #24
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriter<MemorySegment> createBlockChannelWriter(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example #25
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriterWithCallback<MemorySegment> createBlockChannelWriter(ID channelID, RequestDoneCallback<MemorySegment> callback) {
	throw new UnsupportedOperationException();
}
 
Example #26
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelReader<MemorySegment> createBlockChannelReader(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example #27
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileWriter createBufferFileWriter(ID channelID) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #28
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileReader createBufferFileReader(ID channelID, RequestDoneCallback<Buffer> callback) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #29
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileSegmentReader createBufferFileSegmentReader(ID channelID, RequestDoneCallback<FileSegment> callback) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #30
Source File: IOManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public BulkBlockChannelReader createBulkBlockChannelReader(ID channelID, List<MemorySegment> targetSegments, int numBlocks) {
	throw new UnsupportedOperationException();
}