Search in sources :

Example 1 with ID

use of org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID in project flink by apache.

the class IOManagerTest method channelEnumerator.

@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]);
        }
    }
}
Also used : ID(org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 ID (org.apache.flink.runtime.io.disk.iomanager.FileIOChannel.ID)1 Test (org.junit.Test)1