Search in sources :

Example 46 with IgfsPath

use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.

the class IgfsDualAbstractSelfTest method testMoveDirectorySourceParentRootDestinationMissing.

/**
 * Test directory move when source parent is the root and destination is missing.
 *
 * @throws Exception If failed.
 */
public void testMoveDirectorySourceParentRootDestinationMissing() throws Exception {
    IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name());
    create(igfsSecondary, paths(DIR_NEW, SUBDIR_NEW, dir), null);
    create(igfs, null, null);
    igfs.rename(dir, SUBDIR_NEW);
    checkExist(igfs, DIR_NEW, SUBDIR_NEW);
    checkExist(igfs, igfsSecondary, new IgfsPath(SUBDIR_NEW, SUBSUBDIR.name()));
    checkNotExist(igfs, igfsSecondary, dir);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Example 47 with IgfsPath

use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.

the class IgfsDualAbstractSelfTest method testMoveFileDestinationMissingPartially.

/**
 * Test move in case destination exists partially and the path being renamed is a file.
 *
 * @throws Exception If failed.
 */
public void testMoveFileDestinationMissingPartially() throws Exception {
    create(igfsSecondary, paths(DIR, SUBDIR, DIR_NEW, SUBDIR_NEW), paths(FILE));
    create(igfs, paths(DIR, SUBDIR, DIR_NEW), paths(FILE));
    igfs.rename(FILE, SUBDIR_NEW);
    checkExist(igfs, SUBDIR_NEW);
    checkExist(igfs, igfsSecondary, new IgfsPath(SUBDIR_NEW, FILE.name()));
    checkNotExist(igfs, igfsSecondary, FILE);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Example 48 with IgfsPath

use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.

the class IgfsLocalSecondaryFileSystemDualAbstractSelfTest method testSymlinkToFile.

/**
 * @throws Exception If failed.
 */
public void testSymlinkToFile() throws Exception {
    if (U.isWindows())
        return;
    createSymlinks();
    checkFileContent(igfs, new IgfsPath("/file"), chunk);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Example 49 with IgfsPath

use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.

the class IgfsLocalSecondaryFileSystemProxySelfTest method testSymlinkToFile.

/**
 * @throws Exception If failed.
 */
public void testSymlinkToFile() throws Exception {
    if (U.isWindows())
        return;
    createSymlinks();
    checkFileContent(igfs, new IgfsPath("/file"), chunk);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Example 50 with IgfsPath

use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.

the class IgfsLocalSecondaryFileSystemProxySelfTest method testAffinityMaxLen.

/**
 * @throws Exception If failed.
 */
public void testAffinityMaxLen() throws Exception {
    awaitPartitionMapExchange();
    long fileSize = 32 * 1024 * 1024;
    IgfsPath filePath = new IgfsPath("/file");
    try (OutputStream os = igfs.create(filePath, true)) {
        for (int i = 0; i < fileSize / chunk.length; ++i) os.write(chunk);
    }
    Collection<IgfsBlockLocation> blocks;
    long len = igfs.info(filePath).length();
    int start = 0;
    // Check default maxLen (maxLen = 0)
    for (int i = 0; i < igfs.context().data().groupBlockSize() / 1024; i++) {
        Collection<IgfsBlockLocation> blocks0 = igfs.affinity(filePath, start, len, 0);
        blocks = igfs.affinity(filePath, start, len, Long.MAX_VALUE);
        assertTrue(blocks0.size() > 1);
        assertEquals(blocks0.size(), blocks.size());
        assertEquals(F.first(blocks).start(), start);
        assertEquals(start + len, F.last(blocks).start() + F.last(blocks).length());
        assertEquals(blocks0, blocks);
        len -= 1024 * 2;
        start += 1024;
    }
    len = igfs.info(filePath).length();
    start = 0;
    long maxLen = igfs.context().data().groupBlockSize() * 2;
    // Different cases of start, len and maxLen
    for (int i = 0; i < igfs.context().data().groupBlockSize() / 1024; i++) {
        blocks = igfs.affinity(filePath, start, len, maxLen);
        assertEquals(F.first(blocks).start(), start);
        assertEquals(start + len, F.last(blocks).start() + F.last(blocks).length());
        long totalLen = 0;
        for (IgfsBlockLocation block : blocks) {
            totalLen += block.length();
            assert block.length() <= maxLen : "block.length() <= maxLen. [block.length=" + block.length() + ", maxLen=" + maxLen + ']';
            assert block.length() + block.start() <= start + len : "block.length() + block.start() < start + len. [block.length=" + block.length() + ", block.start()=" + block.start() + ", start=" + start + ", len=" + len + ']';
            for (IgfsBlockLocation block0 : blocks) if (!block0.equals(block))
                assert block.start() < block0.start() && block.start() + block.length() <= block0.start() || block.start() > block0.start() && block0.start() + block0.length() <= block.start() : "Blocks cross each other: block0=" + block + ", block1= " + block0;
        }
        assert totalLen == len : "Summary length of blocks must be: " + len + " actual: " + totalLen;
        len -= 1024 * 2;
        start += 1024;
        maxLen -= igfs.context().data().groupBlockSize() * 2 / 1024;
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation)

Aggregations

IgfsPath (org.apache.ignite.igfs.IgfsPath)161 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)24 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)15 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)14 HashMap (java.util.HashMap)13 IgniteException (org.apache.ignite.IgniteException)13 IgniteFileSystem (org.apache.ignite.IgniteFileSystem)13 IgfsFile (org.apache.ignite.igfs.IgfsFile)13 IgfsException (org.apache.ignite.igfs.IgfsException)12 IgniteUuid (org.apache.ignite.lang.IgniteUuid)11 IgfsBlockLocation (org.apache.ignite.igfs.IgfsBlockLocation)10 Map (java.util.Map)9 Path (org.apache.hadoop.fs.Path)9 IgfsInputStream (org.apache.ignite.igfs.IgfsInputStream)9 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)8 FileNotFoundException (java.io.FileNotFoundException)6 OutputStream (java.io.OutputStream)6 IgfsDirectoryNotEmptyException (org.apache.ignite.igfs.IgfsDirectoryNotEmptyException)6 IgfsParentNotDirectoryException (org.apache.ignite.igfs.IgfsParentNotDirectoryException)6