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

The following examples show how to use org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID. These examples are extracted from open source projects. 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 Project: flink   Source File: IOManager.java    License: 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 Project: flink   Source File: IOManagerTest.java    License: 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 3
Source Project: flink   Source File: FileChannelManagerImpl.java    License: 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 4
Source Project: flink   Source File: IOManager.java    License: 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 5
Source Project: flink   Source File: IOManagerTest.java    License: 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 Project: Flink-CEPplus   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public ChannelWithBlockCount(ID channel, int blockCount) {
	this.channel = channel;
	this.blockCount = blockCount;
}
 
Example 7
Source Project: Flink-CEPplus   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public FileIOChannel.ID getChannel() {
	return channel;
}
 
Example 8
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void channelEnumerator() throws IOException {
	IOManager ioMan = null;

	try {
		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];

		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]);
		}
	}
	finally {
		if (ioMan != null) {
			ioMan.shutdown();
		}
	}
}
 
Example 9
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriter<MemorySegment> createBlockChannelWriter(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example 10
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriterWithCallback<MemorySegment> createBlockChannelWriter(ID channelID, RequestDoneCallback<MemorySegment> callback) {
	throw new UnsupportedOperationException();
}
 
Example 11
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelReader<MemorySegment> createBlockChannelReader(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example 12
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileWriter createBufferFileWriter(ID channelID) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example 13
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: 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 Project: Flink-CEPplus   Source File: IOManagerTest.java    License: 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 15
Source Project: Flink-CEPplus   Source File: IOManagerTest.java    License: 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 16
Source Project: flink   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public ChannelWithBlockCount(ID channel, int blockCount) {
	this.channel = channel;
	this.blockCount = blockCount;
}
 
Example 17
Source Project: flink   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public FileIOChannel.ID getChannel() {
	return channel;
}
 
Example 18
Source Project: flink   Source File: FileChannelManagerImpl.java    License: 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 19
Source Project: flink   Source File: IOManager.java    License: Apache License 2.0 4 votes vote down vote up
public abstract BufferFileReader createBufferFileReader(
ID channelID,
RequestDoneCallback<Buffer> callback) throws IOException;
 
Example 20
Source Project: flink   Source File: IOManager.java    License: Apache License 2.0 4 votes vote down vote up
public abstract BufferFileSegmentReader createBufferFileSegmentReader(
ID channelID,
RequestDoneCallback<FileSegment> callback) throws IOException;
 
Example 21
Source Project: flink   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriter<MemorySegment> createBlockChannelWriter(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example 22
Source Project: flink   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelWriterWithCallback<MemorySegment> createBlockChannelWriter(ID channelID, RequestDoneCallback<MemorySegment> callback) {
	throw new UnsupportedOperationException();
}
 
Example 23
Source Project: flink   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BlockChannelReader<MemorySegment> createBlockChannelReader(ID channelID, LinkedBlockingQueue<MemorySegment> returnQueue) {
	throw new UnsupportedOperationException();
}
 
Example 24
Source Project: flink   Source File: IOManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public BufferFileWriter createBufferFileWriter(ID channelID) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example 25
Source Project: flink   Source File: IOManagerTest.java    License: 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 26
Source Project: flink   Source File: IOManagerTest.java    License: 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 27
Source Project: flink   Source File: IOManagerTest.java    License: 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 28
Source Project: flink   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public ChannelWithBlockCount(ID channel, int blockCount) {
	this.channel = channel;
	this.blockCount = blockCount;
}
 
Example 29
Source Project: flink   Source File: UnilateralSortMerger.java    License: Apache License 2.0 4 votes vote down vote up
public FileIOChannel.ID getChannel() {
	return channel;
}
 
Example 30
Source Project: flink   Source File: IOManager.java    License: Apache License 2.0 4 votes vote down vote up
public abstract BufferFileReader createBufferFileReader(
ID channelID,
RequestDoneCallback<Buffer> callback) throws IOException;