Search in sources :

Example 96 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method createDirectory.

@Test
public void createDirectory() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    params.put("persisted", "false");
    params.put("recursive", "false");
    params.put("allowExists", "false");
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.CREATE_DIRECTORY), params, HttpMethod.POST, null).run();
    Assert.assertTrue(mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults()).isEmpty());
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 97 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method unmount.

@Test
public void unmount() throws Exception {
    AlluxioURI uri = new AlluxioURI("/mount");
    mFileSystemMaster.mount(uri, new AlluxioURI(mFolder.newFolder().getAbsolutePath()), MountOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.UNMOUNT), params, HttpMethod.POST, null).run();
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 98 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method scheduleAsyncPersist.

@Test
public void scheduleAsyncPersist() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    mFileSystemMaster.createFile(uri, CreateFileOptions.defaults());
    mFileSystemMaster.completeFile(uri, CompleteFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.SCHEDULE_ASYNC_PERSIST), params, HttpMethod.POST, null).run();
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 99 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method rename.

@Test
public void rename() throws Exception {
    AlluxioURI uri1 = new AlluxioURI("/file1");
    AlluxioURI uri2 = new AlluxioURI("/file2");
    mFileSystemMaster.createFile(uri1, CreateFileOptions.defaults());
    mFileSystemMaster.completeFile(uri1, CompleteFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("srcPath", uri1.toString());
    params.put("dstPath", uri2.toString());
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.RENAME), params, HttpMethod.POST, null).run();
    try {
        mFileSystemMaster.getFileInfo(uri1);
        Assert.fail("file should have been removed");
    } catch (FileDoesNotExistException e) {
    // Expected
    }
    mFileSystemMaster.getFileInfo(uri2);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 100 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method ttlCreateFile.

@Test
public void ttlCreateFile() throws Exception {
    mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
    long ttl = 100;
    CreateFileOptions options = CreateFileOptions.defaults().setTtl(ttl);
    options.setTtlAction(TtlAction.FREE);
    try (LockedInodePath inodePath = mInodeTree.lockInodePath(new AlluxioURI("/testFolder/testFile"), InodeTree.LockMode.WRITE)) {
        mFsMaster.createFileInternal(inodePath, options);
    }
    FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile")));
    Assert.assertEquals(ttl, folderInfo.getTtl());
    Assert.assertEquals(TtlAction.FREE, folderInfo.getTtlAction());
}
Also used : CreateFileOptions(alluxio.master.file.options.CreateFileOptions) LockedInodePath(alluxio.master.file.meta.LockedInodePath) FileInfo(alluxio.wire.FileInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62