Search in sources :

Example 21 with IgfsPath

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

the class IgfsAbstractSelfTest method testMoveRenameFileSourceParentRoot.

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

Example 22 with IgfsPath

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

the class DefaultIgfsSecondaryFileSystemTestAdapter method openOutputStream.

/** {@inheritDoc} */
@Override
public OutputStream openOutputStream(String path, boolean append) throws IOException {
    IgfsPath igfsPath = new IgfsPath(path);
    final IgfsOutputStream igfsOutputStream;
    if (append)
        igfsOutputStream = igfsEx.append(igfsPath, true);
    else
        igfsOutputStream = igfsEx.create(igfsPath, true);
    return igfsOutputStream;
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgfsOutputStream(org.apache.ignite.igfs.IgfsOutputStream)

Example 23 with IgfsPath

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

the class IgfsAbstractSelfTest method testMoveDirectory.

/**
     * Test move in case both local and remote file systems have the same folder structure and the path being renamed is
     * a directory.
     *
     * @throws Exception If failed.
     */
public void testMoveDirectory() throws Exception {
    create(igfs, paths(DIR, SUBDIR, SUBSUBDIR, DIR_NEW, SUBDIR_NEW), null);
    igfs.rename(SUBSUBDIR, SUBDIR_NEW);
    checkExist(igfs, igfsSecondary, new IgfsPath(SUBDIR_NEW, SUBSUBDIR.name()));
    checkNotExist(igfs, igfsSecondary, SUBSUBDIR);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Example 24 with IgfsPath

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

the class IgfsAbstractSelfTest method testCreateConsistency.

/**
     * Ensure consistency of data during file creation.
     *
     * @throws Exception If failed.
     */
public void testCreateConsistency() throws Exception {
    final AtomicInteger ctr = new AtomicInteger();
    final AtomicReference<Exception> err = new AtomicReference<>();
    final int threadCnt = 10;
    multithreaded(new Runnable() {

        @Override
        public void run() {
            int idx = ctr.incrementAndGet();
            final IgfsPath path = new IgfsPath("/file" + idx);
            try {
                for (int i = 0; i < REPEAT_CNT; i++) {
                    IgfsOutputStream os = igfs.create(path, 128, true, /*overwrite*/
                    null, 0, 256, null);
                    os.write(chunk);
                    os.close();
                    assert igfs.exists(path);
                }
                awaitFileClose(igfs, path);
                checkFileContent(igfs, path, chunk);
            } catch (IOException | IgniteCheckedException e) {
                // Log the very first error.
                err.compareAndSet(null, e);
            }
        }
    }, threadCnt);
    if (err.get() != null)
        throw err.get();
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicReference(java.util.concurrent.atomic.AtomicReference) IgfsOutputStream(org.apache.ignite.igfs.IgfsOutputStream) IgfsParentNotDirectoryException(org.apache.ignite.igfs.IgfsParentNotDirectoryException) IgfsDirectoryNotEmptyException(org.apache.ignite.igfs.IgfsDirectoryNotEmptyException) IgfsException(org.apache.ignite.igfs.IgfsException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

Example 25 with IgfsPath

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

the class IgfsAbstractSelfTest method testMoveFileDestinationRoot.

/**
     * Test file move when destination is the root.
     *
     * @throws Exception If failed.
     */
public void testMoveFileDestinationRoot() throws Exception {
    create(igfs, paths(DIR, SUBDIR), paths(FILE));
    igfs.rename(FILE, IgfsPath.ROOT);
    checkExist(igfs, igfsSecondary, new IgfsPath("/" + FILE.name()));
    checkNotExist(igfs, igfsSecondary, FILE);
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath)

Aggregations

IgfsPath (org.apache.ignite.igfs.IgfsPath)161 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)23 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 IgfsInputStream (org.apache.ignite.igfs.IgfsInputStream)10 Map (java.util.Map)9 Path (org.apache.hadoop.fs.Path)9 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)9 FileNotFoundException (java.io.FileNotFoundException)6 OutputStream (java.io.OutputStream)6 IgfsDirectoryNotEmptyException (org.apache.ignite.igfs.IgfsDirectoryNotEmptyException)6 IgfsParentNotDirectoryException (org.apache.ignite.igfs.IgfsParentNotDirectoryException)6